Skip to content

Commit da4cc71

Browse files
msukkariclaude
andcommitted
fix: prevent jq empty from dropping Dependabot alerts without CVE IDs
The jq extraction used `// empty` for cve_id and ghsa_id fields, which silently drops the entire alert object when the field is null. Many Dependabot alerts (especially in Go repos) only have a GHSA ID and no CVE ID, causing all such alerts to be filtered out. Changed to `// null` to preserve all alerts regardless of which ID fields are populated. Also added debug logging to the fetch step. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 79280d5 commit da4cc71

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

.github/workflows/vulnerability-triage.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,22 +286,25 @@ jobs:
286286
-H "Authorization: Bearer $DEPENDABOT_PAT" \
287287
"$URL")
288288
289+
echo "Dependabot API response: HTTP $HTTP_CODE"
289290
if [ "$HTTP_CODE" != "200" ]; then
290291
echo "::warning::Failed to fetch Dependabot alerts (HTTP $HTTP_CODE). Writing empty results."
292+
echo "Response body: $(cat /tmp/dependabot-body.json | head -c 500)"
291293
echo "[]" > dependabot-alerts.json
292294
exit 0
293295
fi
294296
295297
BODY=$(cat /tmp/dependabot-body.json)
296298
COUNT=$(echo "$BODY" | jq 'length')
299+
echo "Page returned $COUNT alert(s)"
297300
if [ "$COUNT" -eq 0 ]; then
298301
break
299302
fi
300303
301304
EXTRACTED=$(echo "$BODY" | jq '[.[] | {
302305
id: (.security_advisory.cve_id // .security_advisory.ghsa_id // ""),
303-
cve_id: (.security_advisory.cve_id // empty),
304-
ghsa_id: (.security_advisory.ghsa_id // empty),
306+
cve_id: (.security_advisory.cve_id // null),
307+
ghsa_id: (.security_advisory.ghsa_id // null),
305308
severity: (.security_advisory.severity // "medium"),
306309
summary: (.security_advisory.summary // ""),
307310
description: (.security_advisory.description // ""),
@@ -312,14 +315,17 @@ jobs:
312315
first_patched_version: (.security_vulnerability.first_patched_version.identifier // "")
313316
}]')
314317
318+
EXTRACTED_COUNT=$(echo "$EXTRACTED" | jq 'length')
319+
echo "Extracted $EXTRACTED_COUNT alert(s) after parsing"
320+
315321
ALL_ALERTS=$(echo "$ALL_ALERTS" "$EXTRACTED" | jq -s '.[0] + .[1]')
316322
317323
# Parse Link header for next page URL (cursor-based pagination)
318324
URL=$(sed -n 's/.*<\([^>]*\)>; *rel="next".*/\1/p' /tmp/dependabot-headers.txt || true)
319325
done
320326
321327
ALERT_COUNT=$(echo "$ALL_ALERTS" | jq 'length')
322-
echo "Fetched $ALERT_COUNT Dependabot alert(s)"
328+
echo "Fetched $ALERT_COUNT Dependabot alert(s) total"
323329
echo "$ALL_ALERTS" > dependabot-alerts.json
324330
325331
- name: Write Dependabot fetch summary

0 commit comments

Comments
 (0)