fix: --exit-code no longer fails a passing scan on the INFO URL_SCAN_LIMITED note#36
Open
dmchaledev wants to merge 1 commit into
Open
fix: --exit-code no longer fails a passing scan on the INFO URL_SCAN_LIMITED note#36dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
Scanning a secure https://wss:// endpoint with --exit-code printed PASSED but exited 1: the run counted the informational URL_SCAN_LIMITED note (INFO severity) as a finding via `report.findings.length > 0`. This broke the documented CI gate on the advertised URL-scan path and contradicted the #27 fix that made secure endpoints pass. --exit-code now fails only on actionable findings (severity above INFO); INFO notes never fail the gate. The exit-code decision is extracted into a pure, side-effect-free shouldFailExit() helper (mirroring the args.ts / cli.ts split) with focused unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ELkzDvarG6hoXSsuKdz5SR
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
Scanning a secure
https:///wss://endpoint with--exit-codeprintsPASSEDbut exits1— a false CI-gate failure on the advertised URL-scan path, and a regression of the intent behind the just-landed #27 fix (make secure endpoints pass).The cause is in
src/cli.ts. The exit decision counted every entry inreport.findings:In URL mode a secure endpoint produces exactly one finding — the INFO
URL_SCAN_LIMITEDnote. That note is documented as "Not a vulnerability — INFO severity, never fails a gate" (src/types.ts), and the report correctly setspassed: true(score 0, no critical). Butreport.findings.length > 0is true because of the note, so--exit-codeexits1anyway.Repro (built CLI, before fix)
Fix
--exit-codenow fails only on actionable findings (severity aboveINFO); INFO notes never fail the gate. The decision was extracted into a pure, side-effect-freeshouldFailExit()helper insrc/exit-policy.ts— mirroring the existingargs.ts/cli.tssplit — so it is unit-testable withoutprocess.exit.Behavior after fix (verified against built CLI)
--exit-codehttps://URL1❌0✅wss://URL1❌0✅http://URL (realMISSING_TLS)11✅11✅00✅INFO-plus-real-finding still fails (the real finding drives the exit), so the change is scoped strictly to the "only an INFO note" case.
Tests
src/__tests__/exit-policy.test.tscovering: not-passed always fails; clean report without--exit-codepasses; actionable finding +--exit-codefails; the secure-URL INFO-only case does not fail; INFO + real finding still fails.tsc --noEmit,eslint --max-warnings 0, andnpm testall pass.Files changed
src/exit-policy.ts— new pureshouldFailExit()helpersrc/cli.ts— use the helper instead of inlinefindings.length > 0src/__tests__/exit-policy.test.ts— new testsCHANGELOG.md— note under Unreleased → Fixed🤖 Generated with Claude Code
https://claude.ai/code/session_01ELkzDvarG6hoXSsuKdz5SR
Generated by Claude Code