3434 run : |
3535 # Try to fetch the latest release binary from the org
3636 PA_URL="https://github.com/${REPO_OWNER}/panic-attack/releases/latest/download/panic-attack-linux-x86_64"
37+ mkdir -p "$HOME/.local/bin"
3738 if curl -fsSL --head "$PA_URL" >/dev/null 2>&1; then
38- curl -fsSL -o /usr/local/bin/panic-attack "$PA_URL"
39- chmod +x /usr/local/bin/panic-attack
39+ curl -fsSL -o "$HOME/.local/bin/panic-attack" "$PA_URL"
40+ chmod +x "$HOME/.local/bin/panic-attack"
41+ echo "$HOME/.local/bin" >> "$GITHUB_PATH"
4042 echo "installed=true" >> "$GITHUB_OUTPUT"
4143 else
4244 echo "::notice::panic-attack binary not available — skipping assail"
@@ -48,20 +50,22 @@ jobs:
4850 if : steps.install.outputs.installed == 'true'
4951 run : |
5052 set +e
51- panic-attack assail --format json . > panic-attack-findings.json 2>&1
53+ panic-attack assail . --output panic-attack-findings.raw. json --output-format json --quiet
5254 PA_EXIT=$?
5355 set -e
5456
55- if [ ! -s panic-attack-findings.json ]; then
56- echo "[]" > panic-attack-findings.json
57+ if [ ! -s panic-attack-findings.raw. json ] || ! jq empty panic-attack-findings.raw.json >/dev/null 2>&1 ; then
58+ echo '{"weak_points":[]}' > panic-attack-findings.raw .json
5759 fi
5860
61+ jq '.weak_points // []' panic-attack-findings.raw.json > panic-attack-findings.json
62+
5963 # Parse finding counts
6064 TOTAL=$(jq '. | length' panic-attack-findings.json 2>/dev/null || echo 0)
61- CRITICAL=$(jq '[.[] | select(.severity == "critical")] | length' panic-attack-findings.json 2>/dev/null || echo 0)
62- HIGH=$(jq '[.[] | select(.severity == "high")] | length' panic-attack-findings.json 2>/dev/null || echo 0)
63- MEDIUM=$(jq '[.[] | select(.severity == "medium")] | length' panic-attack-findings.json 2>/dev/null || echo 0)
64- LOW=$(jq '[.[] | select(.severity == "low")] | length' panic-attack-findings.json 2>/dev/null || echo 0)
65+ CRITICAL=$(jq '[.[] | select(( .severity // "" | ascii_downcase) == "critical")] | length' panic-attack-findings.json 2>/dev/null || echo 0)
66+ HIGH=$(jq '[.[] | select(( .severity // "" | ascii_downcase) == "high")] | length' panic-attack-findings.json 2>/dev/null || echo 0)
67+ MEDIUM=$(jq '[.[] | select(( .severity // "" | ascii_downcase) == "medium")] | length' panic-attack-findings.json 2>/dev/null || echo 0)
68+ LOW=$(jq '[.[] | select(( .severity // "" | ascii_downcase) == "low")] | length' panic-attack-findings.json 2>/dev/null || echo 0)
6569
6670 echo "total=$TOTAL" >> "$GITHUB_OUTPUT"
6771 echo "critical=$CRITICAL" >> "$GITHUB_OUTPUT"
@@ -74,13 +78,13 @@ jobs:
7478 if : steps.install.outputs.installed == 'true'
7579 run : |
7680 # Convert JSON findings into GitHub Actions annotations
77- jq -r '.[] | select(.file != null) |
78- if .severity == "critical" then
79- "::error file=\(.file),line=\(.line // 1) ::[panic-attack] \(.message )"
80- elif .severity == "high" then
81- "::error file=\(.file),line=\(.line // 1) ::[panic-attack] \(.message )"
81+ jq -r '.[] | select(.location != null) |
82+ if ( .severity // "" | ascii_downcase) == "critical" then
83+ "::error file=\(.location) ::[panic-attack] \(.description )"
84+ elif ( .severity // "" | ascii_downcase) == "high" then
85+ "::error file=\(.location) ::[panic-attack] \(.description )"
8286 else
83- "::warning file=\(.file),line=\(.line // 1) ::[panic-attack] \(.message )"
87+ "::warning file=\(.location) ::[panic-attack] \(.description )"
8488 end
8589 ' panic-attack-findings.json || true
8690
@@ -115,7 +119,7 @@ jobs:
115119 retention-days : 90
116120
117121 - name : Fail on critical findings
118- if : steps.install.outputs.installed == 'true' && steps.assail.outputs.critical > 0
122+ if : github.event_name == 'push' && steps.install.outputs.installed == 'true' && steps.assail.outputs.critical > 0
119123 run : |
120124 echo "::error::panic-attack found ${{ steps.assail.outputs.critical }} critical issue(s) — blocking merge"
121125 exit 1
@@ -250,9 +254,11 @@ jobs:
250254 id : install
251255 run : |
252256 PA_URL="https://github.com/${REPO_OWNER}/panic-attack/releases/latest/download/panic-attack-linux-x86_64"
257+ mkdir -p "$HOME/.local/bin"
253258 if curl -fsSL --head "$PA_URL" >/dev/null 2>&1; then
254- curl -fsSL -o /usr/local/bin/panic-attack "$PA_URL"
255- chmod +x /usr/local/bin/panic-attack
259+ curl -fsSL -o "$HOME/.local/bin/panic-attack" "$PA_URL"
260+ chmod +x "$HOME/.local/bin/panic-attack"
261+ echo "$HOME/.local/bin" >> "$GITHUB_PATH"
256262 echo "installed=true" >> "$GITHUB_OUTPUT"
257263 else
258264 echo "::notice::panic-attack binary not available — skipping Patch Bridge"
0 commit comments