Skip to content

Commit ec0dd4e

Browse files
committed
fix: preserve CodeQL issues when scans are unavailable
1 parent 97626c3 commit ec0dd4e

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

.github/scripts/classify-vulnerability-issues.jq

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ def finding_id($prefix):
1212
| .findingId as $findingId
1313
| if .findingId == "" then
1414
. + { action: "ignore" }
15+
elif ($skipCodeql and (.findingId | startswith("codeql:"))) then
16+
. + { action: "ignore" }
1517
elif ($currentIds | index($findingId)) != null then
1618
. + { action: "keep" }
1719
else

.github/scripts/test-vulnerability-triage.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,17 @@ OPEN_ISSUES='[
201201
}
202202
]'
203203

204-
CLASSIFIED="$(jq -c --arg prefix "$PREFIX" --slurpfile findings <(printf '%s\n' "$FINDINGS") -f "$CLASSIFY_FILTER" <<<"$OPEN_ISSUES")"
204+
CLASSIFIED="$(jq -c --arg prefix "$PREFIX" --argjson skipCodeql false --slurpfile findings <(printf '%s\n' "$FINDINGS") -f "$CLASSIFY_FILTER" <<<"$OPEN_ISSUES")"
205205
assert_json "keeps every exact current finding" "$(jq -c '[.[] | select(.action == "keep") | .id]' <<<"$CLASSIFIED")" '["keep-cve","keep-codeql"]'
206206
assert_json "closes only resolved managed findings" "$(jq -c '[.[] | select(.action == "close") | .id]' <<<"$CLASSIFIED")" '["close-cve","close-prefix-collision"]'
207207
assert_json "ignores unrelated titles and repositories" "$(jq -c '[.[] | select(.action == "ignore") | .id]' <<<"$CLASSIFIED")" '["ignore-other-repo","ignore-unmanaged"]'
208208

209209
EMPTY_FINDINGS='{"cves":[]}'
210-
CLASSIFIED_EMPTY="$(jq -c --arg prefix "$PREFIX" --slurpfile findings <(printf '%s\n' "$EMPTY_FINDINGS") -f "$CLASSIFY_FILTER" <<<"$OPEN_ISSUES")"
210+
CLASSIFIED_EMPTY="$(jq -c --arg prefix "$PREFIX" --argjson skipCodeql false --slurpfile findings <(printf '%s\n' "$EMPTY_FINDINGS") -f "$CLASSIFY_FILTER" <<<"$OPEN_ISSUES")"
211211
assert_json "closes all managed issues when a complete scan is clean" "$(jq -c '[.[] | select(.action == "close") | .id]' <<<"$CLASSIFIED_EMPTY")" '["keep-cve","keep-codeql","close-cve","close-prefix-collision"]'
212212

213+
CLASSIFIED_WITH_CODEQL_SKIPPED="$(jq -c --arg prefix "$PREFIX" --argjson skipCodeql true --slurpfile findings <(printf '%s\n' "$EMPTY_FINDINGS") -f "$CLASSIFY_FILTER" <<<"$OPEN_ISSUES")"
214+
assert_json "preserves CodeQL issues when CodeQL is unavailable" "$(jq -c '[.[] | select(.action == "ignore") | .id]' <<<"$CLASSIFIED_WITH_CODEQL_SKIPPED")" '["keep-codeql","ignore-other-repo","ignore-unmanaged"]'
215+
assert_json "still closes resolved non-CodeQL issues when CodeQL is unavailable" "$(jq -c '[.[] | select(.action == "close") | .id]' <<<"$CLASSIFIED_WITH_CODEQL_SKIPPED")" '["keep-cve","close-cve","close-prefix-collision"]'
216+
213217
echo "All vulnerability triage reconciliation tests passed."

.github/workflows/vulnerability-triage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ jobs:
937937
REPOSITORY: ${{ github.repository }}
938938
TEAM_UUID: ${{ steps.match.outputs.team_uuid }}
939939
DONE_STATE_ID: ${{ steps.match.outputs.done_state_id }}
940+
SKIP_CODEQL: ${{ inputs.skip_codeql }}
940941
run: |
941942
set -euo pipefail
942943
# The job only reaches this step after every configured scanner
@@ -985,6 +986,7 @@ jobs:
985986
986987
jq \
987988
--arg prefix "$PREFIX" \
989+
--argjson skipCodeql "$SKIP_CODEQL" \
988990
--slurpfile findings findings.json \
989991
-f .vulnerability-triage-workflow/.github/scripts/classify-vulnerability-issues.jq \
990992
/tmp/open-issues.json > /tmp/classified-issues.json

0 commit comments

Comments
 (0)