fix: reject --fix combined with --sarif or --cdx - #903
Conversation
sonukapoor
left a comment
There was a problem hiding this comment.
Nice catch @Ayush7614, this is a real silent failure, not just a cosmetic guard. I traced it: writeOutputs() only runs in the non-fix branch (src/index.ts:624), so --fix --sarif and --fix --cdx really did apply fixes, exit 0, and quietly write nothing. Good that you verified --fix --report is fine (that write is unconditional, further down) and left it alone.
The placement is exactly right: grouped with the existing --fix cannot be used with --json check, same thrown-Error style, same stderr and exit-1 path, and the message wording matches our convention. Docs and the e2e conflict table are updated too.
One small thing before it goes in: in tests/validate.test.ts you added a "does not throw when --sarif is used without --fix" case but no matching one for --cdx alone. Every other conflict block in that file has the symmetric negative test, so could you add a does not throw when --cdx is used without --fix case to keep it consistent? Tiny ask, everything else looks solid.
|
Addressed review: added the matching |
--fix already rejects --json because writeOutputs only runs on the non-fix path. --sarif/--cdx were accepted but never wrote artifacts. Fail fast with the same incompatibility style as --fix --json.
Match the symmetric "without --fix" coverage already present for --sarif.
2f28a7b to
ddd1388
Compare
|
@sonukapoor thanks for the review — addressed:
Also rebased this branch onto latest |
Summary
--fix --sarifand--fix --cdxnow fail validation with a clear error (same pattern as--fix --json).writeOutputsonly runs on the non---fixpath.Why
Silent incomplete wiring: CI that ran
cve-lite . --fix --sarifgot a successful exit with no artifact, unlike--fix --jsonwhich already fails fast.Test plan
npm test -- tests/validate.test.ts--fix --sarif/--fix --cdxnpm run build