Skip to content

Commit 5448ae4

Browse files
authored
ci: write filtered Scorecard SARIF separately
Write Scorecard SARIF filtering output to a new file so Docker-owned results.sarif does not need to be overwritten before upload.
1 parent 5f53f66 commit 5448ae4

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env node
22
import { readFileSync, writeFileSync } from "node:fs";
33

4-
const [file = "results.sarif"] = process.argv.slice(2);
5-
const sarif = JSON.parse(readFileSync(file, "utf8"));
4+
const [inputFile = "results.sarif", outputFile = inputFile] = process.argv.slice(2);
5+
const sarif = JSON.parse(readFileSync(inputFile, "utf8"));
66

77
for (const run of sarif.runs ?? []) {
88
if (!Array.isArray(run.results)) {
@@ -12,4 +12,4 @@ for (const run of sarif.runs ?? []) {
1212
run.results = run.results.filter((result) => result.ruleId !== "SASTID");
1313
}
1414

15-
writeFileSync(file, `${JSON.stringify(sarif)}\n`);
15+
writeFileSync(outputFile, `${JSON.stringify(sarif)}\n`);

.github/workflows/scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ jobs:
4343
# CodeQL uploads the real SAST results. Scorecard's SAST meta-check is
4444
# noisy for multi-commit pushes because checks attach to the head commit.
4545
- name: Drop Scorecard SAST meta-alert
46-
run: node .github/scripts/filter-scorecard-sarif.mjs results.sarif
46+
run: node .github/scripts/filter-scorecard-sarif.mjs results.sarif results.filtered.sarif
4747

4848
- name: Upload SARIF
4949
uses: github/codeql-action/upload-sarif@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4
5050
with:
51-
sarif_file: results.sarif
51+
sarif_file: results.filtered.sarif

0 commit comments

Comments
 (0)