test(installer): root-secure the guarded-exec test fixtures so the suite runs as uid 0 (#2623) - #66
Conversation
…ite runs as uid 0 (#2623) Fix the fixture LOCATION, never the verify: add `sources::root_secure_fixture_root()`, which honours `DIG_TEST_FIXTURE_ROOT` (the baked-container path) and otherwise, as root, provisions a root-owned `0755` directory directly beneath `/` (whose only judged ancestor is `/` itself). Unprivileged it is exactly `fixture_root()`, so the CI runs are byte-for-byte unchanged. A world-writable leaf a test sets itself is still refused; only the incidental `/tmp` ancestor is removed — so all ten tests now run FOR REAL as root (no skips, no coverage loss) and every security assertion stays live. Tests routed through the new helper (all previously root-only-failing): - secure::root_refuses_to_exec_a_binary_from_a_group_writable_dir (positive control arm) - guardedcmd::a_refused_directory_yields_no_command_at_all (positive control arm) - dns::doctor 7 spawn/poll tests (via tmp_subdir + the missing-binary case) - dns::verify_existing_reports_installed_true_and_live_when_the_service_answers (via tmp_subdir) Version: PATCH 0.42.3 -> 0.42.4 (test-only, behaviour-preserving); gui Cargo.lock re-pinned. Verified as root: cargo test --lib -> 898 passed / 0 failed (was 888/10-failed); cargo fmt --all --check clean; cargo clippy --all-targets -D warnings clean. Co-Authored-By: Claude <noreply@anthropic.com>
… unrelated relock) (#2623) The gui lock sync ran without --offline and picked up unrelated transitive bumps (windows-sys 0.60->0.61, getrandom 0.3->0.4). Restore the gui lock from main and re-pin ONLY dig-installer 0.42.3->0.42.4, keeping this test-only PR's diff scoped. Co-Authored-By: Claude <noreply@anthropic.com>
Correctness gate — PASS (loop-reviewer); non-gating findings addressedTest-only + behavior-preserving change → single correctness gate (§1.10). loop-reviewer — PASS, verified empirically (not trusted from the maker): Non-gating findings:
Follow-up (Low, to file post-merge): fold the self-provisioning into The Generated by Claude Code |
What & why
Closes DIG-Network/dig_ecosystem#2623. 10 lib tests fail when the suite runs as root (uid 0), green on the non-root CI runner — noisy for local/agent runs in root containers and a place real regressions could hide.
Root cause (single, shared — not "unprivileged-only asserts"): the root-exec guard (
rootchain::verify, viasecure::root_exec_guard/guardedcmd::GuardedCommand::for_installed_binary) walks every ancestor of a fixture dir up to/and refuses any level with group/other write.sources::fixture_root()defaults to/tmp(sticky1777), so as root the guard correctly refuses fixtures there; on the non-root CI runner the guard is inert, so the tests pass — masking the breakage. (Thefixture_root()doc already anticipated this viaDIG_TEST_FIXTURE_ROOT.)Fix — split (run for real under root), not skip
Added
sources::root_secure_fixture_root(): honoursDIG_TEST_FIXTURE_ROOT, else (as root) provisions a root-owned0755dir directly beneath/— whose only judged ancestor is/itself — and unprivileged returns exactlyfixture_root(), so CI runs are byte-for-byte unchanged. Routed the 10 tests' fixture dirs through it. A world-writable leaf a test sets itself is still refused (only the incidental/tmpancestor is removed). 10 split / 0 skipped → 0 coverage loss; every security assertion stays live and runs for real under root.How verified
cargo test --lib→ 898 passed / 0 failed (was 888 / 10-failed).fixture_root()→ reproduced exactly the same 10 failures; restored (tree clean).cargo fmt --all -- --checkclean;cargo clippy --all-targets -- -D warningsclean.Blast radius
Test-only + behavior-preserving. No product code path changed — only test fixture locations and the new test helper.
fixture_root()(50 sites/16 files) is untouched; only the 10 root-guard-PASS tests route through the new helper. No non-root assertion weakened.Version
0.42.3 → 0.42.4(patch — test infra, behavior-preserving). Rides the nightly (apps §3.6-A).DEVELOPMENT_LOG.mdrecords the root-secure-fixture convention;gui/app/src-tauri/Cargo.lockre-pinned dig-installer 0.42.4.Closes DIG-Network/dig_ecosystem#2623
Generated by Claude Code