feat(cross): --offline-strict with fail-closed network-namespace enforcement#101
Merged
Conversation
A rootless netns wrapper (unshare --net --map-root-user, loopback up), a capability probe, and a policy that fails closed under strict mode when isolation is unavailable and degrades with a warning otherwise. Signed-off-by: Joel Winarske <joel.winarske@linux.com>
Add --offline-strict (implies --offline): resolve the enforcement level once a build is about to run and refuse to build when a network namespace is unavailable, rather than trusting a subprocess to honor --offline. Cargo module builds run wrapped in the namespace when isolation is available. Document both flags in the README and extend the cspell dictionary. Signed-off-by: Joel Winarske <joel.winarske@linux.com>
This was referenced Jul 4, 2026
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.
Strengthens
--offlineso a build subprocess can't quietly reach the network. Builds on #98/#100.Why
--offlinedenies emb's own egress (cached inputs,CARGO_NET_OFFLINE) but trusts a build subprocess — a crate build script, a CMakeFetchContent— to honor it.--offline-strictremoves that trust.What
--offline-strict(implies--offline): runs build subprocesses inside a rootless network namespace (unshare --net --map-root-user, loopback brought up), so an off-host connection is denied outright.unshare, or unprivileged user namespaces disabled (common on locked-down CI runners and in containers) —--offline-strictrefuses to build rather than silently downgrading. Plain--offlinedegrades with a warning.unshareinherits cwd and env, soCARGO_HOME/CARGO_NET_OFFLINEstill reach cargo.Structure
New
lib/src/cross/offline_enforcement.dart:OfflineMode, thenetnsWrapargv builder, anetnsAvailablecapability probe, andresolveOfflineEnforcement(the fail-closed/degrade policy) — all unit-tested with a fake runner.emb crossresolves the enforcement once, before the build.Test
dart analyze lib testclean;dart format --set-exit-if-changedclean; cspell dictionary extended.offline_enforcement_test.dart(argv wrap, probe outcomes, strict-fails-closed / deny-degrades / off-noop).real dpkg-deb/real debugfsenv failures.Scope / follow-ups
CrossBuilder) and the future hook runner is the next step.