Skip to content

test(corpus): make the CORPUS_DIR and committed-fixture gates report when they skip - #4

Merged
h4x0r merged 2 commits into
mainfrom
testgate/loud-skips
Aug 5, 2026
Merged

test(corpus): make the CORPUS_DIR and committed-fixture gates report when they skip#4
h4x0r merged 2 commits into
mainfrom
testgate/loud-skips

Conversation

@h4x0r

@h4x0r h4x0r commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Dependency form — resolved

The forensic-testgate dev-dependency was a path dep pointing at a machine-local scratch
directory
, so cargo metadata failed on every other machine and every CI job died at manifest
load before running a single check.

forensic-testgate 0.1.0 published to crates.io on
2026-08-02, so the dep is now the registry form this PR originally promised:

forensic-testgate = "0.1"

A git-pinned revision was the alternative, and was rejected. A git dep carries no publisher record,
so cargo-vet would need an [[exemptions]] entry where a trust entry applies — the weaker
mechanism, which ADR-0018 treats as a defect when a stronger one is available — and the dep would
have had to be swapped a second time once the registry version landed.

Supply chain: the crate is ours and published by h4x0r, which is ADR-0018 mechanism (2), so it
gets [[trusted.forensic-testgate]] scoped to safe-to-run (it is a dev-dependency).

The loud-skip contract is unchanged — with CORPUS_DIR unset the tests still announce the skip by
name, and FORENSIC_TESTGATE_STRICT=1 still turns each skip into a failure.

Why

core/tests/corpus.rs stacked two silent skips in every corpus test:

let Some(dir) = corpus_dir() else { return };   // CORPUS_DIR unset  — silent
let path = dir.join("dynamic.vhdx");
if !path.exists() { return; }                    // fixture absent   — silent

cargo test prints ok whether the VHDX reader was validated against the real corpus or never opened a file. Those are not the same claim, and the suite could not tell you which one you got.

This is one instance of a fleet-wide pattern: a sweep found 216 env-gated test skip sites that produce no output at all. This exact corpus_dir() helper is cloned verbatim in qcow2-forensic, vhd-forensic, and vmdk-forensic; this is the vhdx instance. Companion PRs: SecurityRonin/qcow2-forensic#4, SecurityRonin/vhd-forensic#3.

What changed

1. The CORPUS_DIR gates. Both halves now resolve through forensic_testgate::gated_file. The notice is emitted by the resolver, on the library side of the seam, so there is no quiet variant to reach for and a later edit cannot drop it.

CORPUS_DIR Behaviour
unset notice naming the variable, skip, exit 0
set, fixture absent notice naming the directory and the fixture, skip
set to a missing path FAILS, naming the variable and showing the value

The third is the deliberate design call: setting the variable is the operator saying run this test, so a path that is not there is a misconfiguration, not a skip.

2. A committed-fixture skip in core/tests/bounded.rs. assert_open_matches_from_bytes guarded its input with if !path.exists() { return; }. Those fixtures (ext2.vhdx, qemu_fixed.vhdx, fat-parent.vhdx, dfvfs_ext2.vhdx) are tracked in gitgit ls-files tests/data lists them — so their absence is a broken checkout, not a skip. As written, the entire from_bytes vs open differential could validate nothing and still report ok. It now asserts.

Verification

$ cargo test -p vhdx-core --test corpus -- --nocapture
SKIP [forensic-testgate]: CORPUS_DIR is unset — this test did not run. Set CORPUS_DIR to the fixture it gates on to run it.
SKIP [forensic-testgate]: CORPUS_DIR is unset — this test did not run. Set CORPUS_DIR to the fixture it gates on to run it.
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Full suite: 195 passed. clippy --all-targets --all-features -D warnings clean.

Separate finding — a gate that has never fired in CI

Not fixed here, to keep this diff reviewable. core/tests/corpus_differential.rs:12 hardcodes the oracle path:

const QEMU_IMG: &str = "/opt/homebrew/bin/qemu-img";
if !Path::new(QEMU_IMG).exists() || !corpus.exists() { return; }

That is the macOS-ARM Homebrew path only, so on the Linux CI runner it never exists and the qemu differential tests silently skip on every CI run. The file's own doc comment concedes it — "these tests skip automatically if qemu-img is not installed, so they run in CI only on machines with QEMU available (the dev machine)" — which describes a differential oracle that has never validated anything in CI.

qcow2-forensic/core/tests/real_images.rs already fixed this exact bug by searching /opt/homebrew, /usr/local and /usr/bin. The same defect is live in vhd-forensic and qcow2-forensic's forensic/ crate.

Worth its own PR, along with a loud tool-resolution gate so the next occurrence announces itself.

🤖 Generated with Claude Code

h4x0r and others added 2 commits August 2, 2026 03:16
…when they skip

core/tests/corpus.rs stacked two silent skips in every corpus test:

    let Some(dir) = corpus_dir() else { return };   // CORPUS_DIR unset
    let path = dir.join("dynamic.vhdx");
    if !path.exists() { return; }                    // fixture absent

Neither says anything. `cargo test` prints ok whether the VHDX reader was validated
against the corpus or never opened a file, and those two outcomes are not the same
claim.

Both halves now go through forensic-testgate::gated_file, which emits the notice
from inside the resolver — there is no quiet variant to reach for, so the notice
cannot be dropped in a later edit. A CORPUS_DIR pointing at a path that does not
exist now FAILS rather than skipping: setting the variable is the operator saying
"run this test", so a missing corpus is a misconfiguration.

Separately, core/tests/bounded.rs guarded its fixtures with
`if !path.exists() { return; }`. Those fixtures live under tests/data/ and are
tracked in git, so their absence is a broken checkout rather than a skip — the
whole from_bytes/open differential could quietly validate nothing. It now asserts.

This `corpus_dir()` helper is cloned verbatim across qcow2/vhd/vhdx/vmdk; this is
the vhdx instance.

195 tests pass; clippy --all-targets --all-features -D warnings clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The `forensic-testgate` dev-dependency pointed at a machine-local scratch
directory. `cargo metadata` failed on every other machine, so every CI job
died at manifest load before running a single check.

`forensic-testgate 0.1.0` published to crates.io on 2026-08-02, so the
registry form the TODO was waiting on is now available and the TODO is
removed rather than reworded — its blocker no longer exists. A git-pinned
revision was the alternative, and was rejected: a git dep carries no
publisher record, so cargo-vet would need an `[[exemptions]]` entry where a
`trust` entry applies, and the dep would have to be swapped a second time
once the registry version landed.

Supply chain: the crate is ours and published by h4x0r, which is ADR-0018
mechanism (2), so it gets `[[trusted.forensic-testgate]]` scoped to
`safe-to-run` (it is a dev-dependency) rather than the weaker exemption.

The loud-skip contract is unchanged — with the gating variable unset the
tests still announce the skip by name, and `FORENSIC_TESTGATE_STRICT=1`
still turns each skip into a failure.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedforensic-testgate@​0.1.010010093100100

View full report

@h4x0r
h4x0r marked this pull request as ready for review August 5, 2026 20:27
@h4x0r
h4x0r merged commit 82c14f6 into main Aug 5, 2026
10 checks passed
@h4x0r
h4x0r deleted the testgate/loud-skips branch August 9, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant