1010 schedule :
1111 - cron : ' 0 0 * * 0' # Weekly on Sunday
1212 workflow_dispatch :
13+ # Estate guardrail: cancel superseded runs so re-pushes don't pile up
14+ # queued runs across the estate. Safe here because this workflow only
15+ # performs read-only checks/lint/test/scan with no publish or mutation.
16+ concurrency :
17+ group : ${{ github.workflow }}-${{ github.ref }}
18+ cancel-in-progress : true
1319
1420permissions :
1521 contents : read
22+ # security-events: read lets the built-in GITHUB_TOKEN query this
23+ # repo's own Dependabot alerts via the Hypatia DependabotAlerts rule
24+ # (DA001-DA004). Without this, `scan_from_path` gets HTTP 403 and
25+ # the rule silently returns no findings.
26+ # See 007-lang/audits/audit-dependabot-automation-gap-2026-04-17.md.
27+ security-events : read
28+ # pull-requests: write lets the advisory "Comment on PR with findings"
29+ # step post its summary. Without it the built-in GITHUB_TOKEN gets
30+ # "Resource not accessible by integration" and (absent continue-on-error)
31+ # hard-fails the scan — exactly what the gate-decoupling design forbids.
32+ pull-requests : write
1633
1734jobs :
1835 scan :
@@ -21,36 +38,53 @@ jobs:
2138
2239 steps :
2340 - name : Checkout repository
24- uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
41+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2542 with :
2643 fetch-depth : 0 # Full history for better pattern analysis
2744
45+ - name : Setup Elixir for Hypatia scanner
46+ uses : erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1.18.2
47+ with :
48+ elixir-version : ' 1.19.4'
49+ otp-version : ' 28.3'
50+
2851 - name : Clone Hypatia
2952 run : |
3053 if [ ! -d "$HOME/hypatia" ]; then
3154 git clone https://github.com/hyperpolymath/hypatia.git "$HOME/hypatia"
3255 fi
33- chmod +x "$HOME/hypatia/hypatia-cli.sh"
56+
57+ - name : Build Hypatia scanner (if needed)
58+ run : |
59+ cd "$HOME/hypatia"
60+ if [ ! -f hypatia ]; then
61+ echo "Building hypatia scanner..."
62+ mix deps.get
63+ mix escript.build
64+ fi
3465
3566 - name : Run Hypatia scan
3667 id : scan
3768 env :
38- # Suppress the Dependabot "GITHUB_TOKEN not set" warning.
69+ # Pass the built-in Actions token through to Hypatia so the
70+ # DependabotAlerts rule can query this repo's own alerts.
71+ # For cross-repo scanning (fleet-coordinator scan-supervised),
72+ # a PAT with `security_events` scope is required instead.
3973 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4074 run : |
4175 echo "Scanning repository: ${{ github.repository }}"
4276
43- # Run scanner (exits non-zero when findings exist, which is expected )
77+ # Run scanner (exits non-zero when findings exist — suppress to continue )
4478 HYPATIA_FORMAT=json "$HOME/hypatia/hypatia-cli.sh" scan . --exit-zero > hypatia-findings.json || true
4579
46- # Count findings (handle both flat array and nested structures)
47- FINDING_COUNT=$(jq 'if type == "array" then length else 0 end ' hypatia-findings.json 2>/dev/null || echo 0)
80+ # Count findings
81+ FINDING_COUNT=$(jq '. | length' hypatia-findings.json 2>/dev/null || echo 0)
4882 echo "findings_count=$FINDING_COUNT" >> $GITHUB_OUTPUT
4983
50- # Extract severity counts (flatten if nested, filter by .severity)
51- CRITICAL=$(jq '[.. | objects | select(.severity? == "critical")] | length' hypatia-findings.json 2>/dev/null || echo 0 )
52- HIGH=$(jq '[.. | objects | select(.severity? == "high")] | length' hypatia-findings.json 2>/dev/null || echo 0 )
53- MEDIUM=$(jq '[.. | objects | select(.severity? == "medium")] | length' hypatia-findings.json 2>/dev/null || echo 0 )
84+ # Extract severity counts
85+ CRITICAL=$(jq '[.[] | select(.severity == "critical")] | length' hypatia-findings.json)
86+ HIGH=$(jq '[.[] | select(.severity == "high")] | length' hypatia-findings.json)
87+ MEDIUM=$(jq '[.[] | select(.severity == "medium")] | length' hypatia-findings.json)
5488
5589 echo "critical=$CRITICAL" >> $GITHUB_OUTPUT
5690 echo "high=$HIGH" >> $GITHUB_OUTPUT
@@ -182,7 +216,12 @@ jobs:
182216
183217 - name : Comment on PR with findings
184218 if : github.event_name == 'pull_request' && steps.scan.outputs.findings_count > 0
185- uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
219+ # Advisory only — posting findings as a PR comment must never gate
220+ # the scan (hypatia#213 gate decoupling). Belt-and-braces alongside
221+ # the pull-requests: write permission above: a token/API hiccup or
222+ # a fork PR (read-only token) skips the comment, not the check.
223+ continue-on-error : true
224+ uses : actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v7
186225 with :
187226 script : |
188227 const fs = require('fs');
@@ -212,4 +251,4 @@ jobs:
212251 repo: context.repo.repo,
213252 issue_number: context.issue.number,
214253 body: comment
215- });
254+ });
0 commit comments