Skip to content

Commit 80f5246

Browse files
authored
feat: allow --sarif and --report together for dual CI output (#696)
* feat: allow --sarif and --report together for dual CI output Lifts the mutual exclusion between --sarif and --report. The two code paths write to independent files and have no technical conflict. Enables CI workflows that upload SARIF to GitHub Code Scanning and simultaneously produce an HTML report as a downloadable artifact. Closes #681 * docs: update sarif and cli-reference to reflect --sarif + --report support
1 parent 301dc24 commit 80f5246

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/cli/args.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,6 @@ export function parseArgs(argv: string[]): {
276276
throw new Error(`Unexpected argument: ${arg}`);
277277
}
278278

279-
if (options.sarif && options.report) {
280-
throw new Error("cannot combine --sarif and --report");
281-
}
282-
283279
if (options.cdx && options.report) {
284280
throw new Error("cannot combine --cdx and --report");
285281
}

tests/helpers.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ describe("parseArgs", () => {
168168
expect(result.options.sarif).toBe(true);
169169
});
170170

171+
it("allows --sarif combined with --report for dual CI output", () => {
172+
const result = parseArgs(["--sarif", "--report", "./cve-report", "--no-open"]);
173+
expect(result.options.sarif).toBe(true);
174+
expect(result.options.report).toBe("./cve-report");
175+
expect(result.options.noOpen).toBe(true);
176+
});
177+
171178
it("parses --ratchet flag", () => {
172179
const { options } = parseArgs([".", "--ratchet"]);
173180
expect(options.ratchet).toBe(true);

website/docs/cli-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cve-lite install-skill
3333
|---|---|---|---|
3434
| `--verbose` | off | Full output: severity table, fix plan, findings table, coverage notes | `cve-lite . --verbose` |
3535
| `--json` | off | Machine-readable JSON output (suppresses all other output) | `cve-lite . --json` |
36-
| `--sarif` | off | Write SARIF 2.1.0 output to a timestamped `.sarif` file; can be combined with `--json`; cannot be combined with `--report` | `cve-lite . --sarif` |
36+
| `--sarif` | off | Write SARIF 2.1.0 output to a timestamped `.sarif` file; can be combined with `--json` and `--report` | `cve-lite . --sarif` |
3737
| `--cdx` | off | Write CycloneDX 1.4 SBOM to a timestamped `.cdx.json` file; can be combined with `--json` and `--sarif`; cannot be combined with `--report` | `cve-lite . --cdx` |
3838
| `--report[=<path>]` | off / `./cve-report` | Generate an HTML report; optional path sets output directory (default `./cve-report`); opens in browser by default; cannot be used with `--json` | `cve-lite . --report`<br/>`cve-lite . --report ./reports` |
3939
| `--no-open` | off | Generate the HTML report without opening it in the browser | `cve-lite . --report --no-open` |

website/docs/sarif.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This writes a timestamped file (`cve-lite-scan-<timestamp>.sarif`) to the curren
2222
cve-lite . --sarif --json
2323
```
2424

25-
`--sarif` cannot be combined with `--report`.
25+
`--sarif` can be combined with `--report --no-open` to write both a SARIF file and an HTML report in one scan - useful for CI pipelines that upload to GitHub Code Scanning and also attach an HTML artifact for human review.
2626

2727
## GitHub Code Scanning integration
2828

0 commit comments

Comments
 (0)