Allow disabling melange runner network (capabilities.networking)#2546
Open
falcorocks wants to merge 2 commits into
Open
Allow disabling melange runner network (capabilities.networking)#2546falcorocks wants to merge 2 commits into
falcorocks wants to merge 2 commits into
Conversation
59a2351 to
a9a5cd9
Compare
The capabilities.networking flag was only wired into the bubblewrap runner. On docker and qemu it was silently ignored, so a config with networking: false still ran build/test steps with full network access (docker is the default runner on macOS). - docker: set HostConfig.NetworkMode to "none" when networking is disabled (loopback only, no route off-box). - qemu: add SLIRP restrict=on to the guest netdev when networking is disabled. This isolates the guest from the host and the outside world while leaving the hostfwd SSH control channel intact. Extract dockerNetworkMode and qemuNetdevArgs helpers and add unit tests covering the network decision for all three runners.
a9a5cd9 to
fba903f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an optional
capabilities.networkingboolean to melange YAML so callers candisable network access in the build/test runner sandbox. Honored by all three
runners: bubblewrap, docker, and qemu.
Motivation (security)
melange currently always enables networking for the sandbox runner, which makes
it harder to build packages in network-restricted environments. Disabling
networking at the runner boundary reduces supply-chain risk by preventing
exfiltration and remote fetches during build/test steps.
Behavior
Backward compatible. When
capabilities.networkingis omitted, melange keepsthe current behavior (network enabled). When set to
false, melange disablesnetwork in the runner sandbox:
--unshare-net(new network namespace, loopback only)NetworkMode=none(loopback only, no route off-box)restrict=on(guest isolated from host and the outside world,while the hostfwd SSH control channel melange uses to drive the guest stays
intact)
Usage
Tests
Unit tests cover the network decision for each runner (
dockerNetworkMode,qemuNetdevArgs, and the bubblewrap arg construction). Also verifiedend-to-end: a probe package whose pipeline curls an external host fails the
build when reachability does not match the flag, run across all three runners.
go test ./...