Skip to content

Guard the one CLI test that passes for the wrong reason - #36

Open
Dharundp6 wants to merge 1 commit into
cloudflare:mainfrom
Dharundp6:fix/guard-vacuous-cli-path-test
Open

Dharundp6 wants to merge 1 commit into
cloudflare:mainfrom
Dharundp6:fix/guard-vacuous-cli-path-test

Conversation

@Dharundp6

Copy link
Copy Markdown

Summary

Both validators intentionally refuse all input where the OS does not provide O_NOFOLLOW/O_NONBLOCK. Every CLI-invoking test in both suites is guarded for that — by the { skip: !HAS_SAFE_INPUT_OPEN } option or by an inline early return — with exactly one exception in each file: does not reflect controls from a failed CLI input path.

It is unguarded in both suites, and it passes there regardless. The safe-open check fires before the missing path is ever opened, and all three of its assertions hold for that rejection just as they do for a missing file:

  • exit status 1 ✅ (safe-open rejection also exits 1)
  • /Failed to read .../ ✅ (both paths share the prefix)
  • no injected control bytes ✅ (the rejection message contains none)

So it reports green without ever exercising the missing-path branch it is named for.

Fix

Apply the same guard the sibling CLI tests already use, in both files, so it skips honestly where it cannot run.

platform without the flags:  vacuous pass  ->  skip
platform with the flags:     unchanged (runs and passes)

Test plan

  • node --test skills/security-audit/validate-coverage-ledger.test.cjs — 0 failures; skips go 7 → 8
  • node --test skills/security-audit/validate-findings.test.cjs — this test now skips instead of passing vacuously
  • Verified the guard polarity by forcing HAS_SAFE_INPUT_OPEN = true in a scratch copy: both tests are then attempted and pass rather than skipped, so nothing is disabled where the flags exist

Relationship to #31

Independent and non-overlapping. #31 guards 7 other tests in validate-findings.test.cjs; it does not touch this test or the coverage-ledger suite. These merge in either order.

Both validators refuse all input where the OS does not provide O_NOFOLLOW and
O_NONBLOCK, which is intentional. Every CLI-invoking test in both suites is
guarded for that, by option or inline, except "does not reflect controls from
a failed CLI input path".

That test is unguarded in both suites, and it passes there anyway: the
safe-open check fires before the missing path is ever opened, and its three
assertions -- exit 1, the "Failed to read" prefix, and no control bytes --
hold for the safe-open rejection just as they do for a missing file. So it
reports green without exercising the missing-path branch it is named for.

Guard it with the same option the sibling CLI tests use, so it skips honestly
where it cannot run. No change on platforms that provide the flags, where it
continues to run and pass.
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