Skip to content

Commit 987aef5

Browse files
hyperpolymathclaude
andcommitted
fix(ci): make hypatia jq parsing resilient to output format
Use recursive descent (..) to find severity fields regardless of nesting depth, and add 2>/dev/null fallbacks to all jq calls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e105087 commit 987aef5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

.github/workflows/hypatia-scan.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ jobs:
3939
# Run scanner (exits non-zero when findings exist, which is expected)
4040
HYPATIA_FORMAT=json "$HOME/hypatia/hypatia-cli.sh" scan . > hypatia-findings.json || true
4141
42-
# Count findings
43-
FINDING_COUNT=$(jq '. | length' hypatia-findings.json 2>/dev/null || echo 0)
42+
# Count findings (handle both flat array and nested structures)
43+
FINDING_COUNT=$(jq 'if type == "array" then length else 0 end' hypatia-findings.json 2>/dev/null || echo 0)
4444
echo "findings_count=$FINDING_COUNT" >> $GITHUB_OUTPUT
4545
46-
# Extract severity counts
47-
CRITICAL=$(jq '[.[] | select(.severity == "critical")] | length' hypatia-findings.json)
48-
HIGH=$(jq '[.[] | select(.severity == "high")] | length' hypatia-findings.json)
49-
MEDIUM=$(jq '[.[] | select(.severity == "medium")] | length' hypatia-findings.json)
46+
# Extract severity counts (flatten if nested, filter by .severity)
47+
CRITICAL=$(jq '[.. | objects | select(.severity? == "critical")] | length' hypatia-findings.json 2>/dev/null || echo 0)
48+
HIGH=$(jq '[.. | objects | select(.severity? == "high")] | length' hypatia-findings.json 2>/dev/null || echo 0)
49+
MEDIUM=$(jq '[.. | objects | select(.severity? == "medium")] | length' hypatia-findings.json 2>/dev/null || echo 0)
5050
5151
echo "critical=$CRITICAL" >> $GITHUB_OUTPUT
5252
echo "high=$HIGH" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)