Skip to content

Commit d8fd3d8

Browse files
chore(ci): convert hypatia-scan.yml to wrapper of standards reusable (#10)
* chore(ci): convert hypatia-scan.yml to thin wrapper of standards reusable Replaces ~416 lines of duplicated Hypatia scan plumbing with a 29-line wrapper calling hyperpolymath/standards/.github/workflows/hypatia-scan-reusable.yml at SHA 2569c10e831e293f9dd6580d82a494aca039deee (standards#191 HEAD). Behaviour-preserving: same triggers, same concurrency group, same permissions, same secrets passthrough. Refs standards#191. * chore(ci): retarget hypatia-scan wrapper to standards#193 HEAD Standards #191 was closed in favour of #193 (parallel-session implementation with simpler API: zero inputs except runs-on). Repointing the wrapper at #193 HEAD 97df762107501909f50bb770e9bc200b6c415600 so it picks up the merged reusable once #193 lands. Refs standards#193. * ci(sweep): codeql actions matrix - Replace codeql.yml `javascript-typescript` matrix entry with `actions` (repo has no JS/TS source). Matches the canonical fix in rsr-template-repo#71 / mtpc#8 / thunderbird#75.
1 parent 7a84a1d commit d8fd3d8

2 files changed

Lines changed: 20 additions & 220 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ jobs:
3030
fail-fast: false
3131
matrix:
3232
include:
33-
- language: javascript-typescript
33+
# Repo source is not JS/TS; scan workflow files via the
34+
# actions extractor (every repo has those). See hypatia rule
35+
# codeql_language_matrix_mismatch.
36+
- language: actions
3437
build-mode: none
3538

3639
steps:

.github/workflows/hypatia-scan.yml

Lines changed: 16 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -1,232 +1,29 @@
11
# SPDX-License-Identifier: MPL-2.0
2-
# Hypatia Neurosymbolic CI/CD Security Scan
2+
# Thin wrapper around hyperpolymath/standards hypatia-scan-reusable.yml.
3+
# See standards#191 for the reusable's purpose and design.
4+
35
name: Hypatia Security Scan
46

57
on:
68
push:
7-
branches: [ main, master, develop ]
9+
branches: [main, master, develop]
810
pull_request:
9-
branches: [ main, master ]
11+
branches: [main, master]
1012
schedule:
11-
- cron: '0 0 * * 0' # Weekly on Sunday
13+
- cron: '0 0 * * 0'
1214
workflow_dispatch:
1315

16+
# Estate guardrail: cancel superseded runs so re-pushes don't pile up.
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
1421
permissions:
1522
contents: read
16-
# security-events: read lets the built-in GITHUB_TOKEN query this
17-
# repo\'s own Dependabot alerts via the Hypatia DependabotAlerts rule.
18-
security-events: read
23+
security-events: write
24+
pull-requests: write
1925

2026
jobs:
21-
scan:
22-
name: Hypatia Neurosymbolic Analysis
23-
runs-on: ubuntu-latest
24-
25-
steps:
26-
- name: Checkout repository
27-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
28-
with:
29-
fetch-depth: 0 # Full history for better pattern analysis
30-
31-
- name: Setup Elixir for Hypatia scanner
32-
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1.18.2
33-
with:
34-
elixir-version: '1.19.4'
35-
otp-version: '28.3'
36-
37-
- name: Clone Hypatia
38-
run: |
39-
if [ ! -d "$HOME/hypatia" ]; then
40-
git clone https://github.com/hyperpolymath/hypatia.git "$HOME/hypatia"
41-
fi
42-
43-
- name: Build Hypatia scanner (if needed)
44-
run: |
45-
cd "$HOME/hypatia"
46-
if [ ! -f hypatia ]; then
47-
echo "Building hypatia scanner..."
48-
mix deps.get
49-
mix escript.build
50-
fi
51-
52-
- name: Run Hypatia scan
53-
id: scan
54-
env:
55-
# Suppress the Dependabot "GITHUB_TOKEN not set" warning.
56-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57-
run: |
58-
echo "Scanning repository: ${{ github.repository }}"
59-
60-
# Run scanner (exits non-zero when findings exist — suppress to continue)
61-
HYPATIA_FORMAT=json "$HOME/hypatia/hypatia-cli.sh" scan . --exit-zero > hypatia-findings.json || true
62-
63-
# Count findings
64-
FINDING_COUNT=$(jq '. | length' hypatia-findings.json 2>/dev/null || echo 0)
65-
echo "findings_count=$FINDING_COUNT" >> $GITHUB_OUTPUT
66-
67-
# Extract severity counts
68-
CRITICAL=$(jq '[.[] | select(.severity == "critical")] | length' hypatia-findings.json)
69-
HIGH=$(jq '[.[] | select(.severity == "high")] | length' hypatia-findings.json)
70-
MEDIUM=$(jq '[.[] | select(.severity == "medium")] | length' hypatia-findings.json)
71-
72-
echo "critical=$CRITICAL" >> $GITHUB_OUTPUT
73-
echo "high=$HIGH" >> $GITHUB_OUTPUT
74-
echo "medium=$MEDIUM" >> $GITHUB_OUTPUT
75-
76-
echo "## Hypatia Scan Results" >> $GITHUB_STEP_SUMMARY
77-
echo "- Total findings: $FINDING_COUNT" >> $GITHUB_STEP_SUMMARY
78-
echo "- Critical: $CRITICAL" >> $GITHUB_STEP_SUMMARY
79-
echo "- High: $HIGH" >> $GITHUB_STEP_SUMMARY
80-
echo "- Medium: $MEDIUM" >> $GITHUB_STEP_SUMMARY
81-
82-
- name: Upload findings artifact
83-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
84-
with:
85-
name: hypatia-findings
86-
path: hypatia-findings.json
87-
retention-days: 90
88-
89-
- name: Submit findings to gitbot-fleet (Phase 2)
90-
if: steps.scan.outputs.findings_count > 0
91-
# Phase 2 is the collaborative LEARNING side-channel ("bots share
92-
# findings via gitbot-fleet"), not the security gate. The gate is
93-
# the baseline-aware "Check for critical or high-severity issues"
94-
# step below. A fleet-side regression (e.g. the submit script being
95-
# moved/removed) must NEVER hard-fail every consuming repo's scan.
96-
# Same reasoning as the "Comment on PR with findings" step.
97-
# See hyperpolymath/hypatia#213 (gate decoupling) and the exit-127
98-
# estate-wide breakage when gitbot-fleet/scripts/submit-finding.sh
99-
# no longer existed on the default branch.
100-
continue-on-error: true
101-
env:
102-
# All GitHub context values surface as env vars so the run
103-
# block never interpolates `${{ … }}` inline (closes the
104-
# workflow_audit/unsafe_curl_payload + actions_expression_injection
105-
# findings).
106-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107-
FLEET_PUSH_TOKEN: ${{ secrets.HYPATIA_DISPATCH_PAT }}
108-
FLEET_DISPATCH_TOKEN: ${{ secrets.HYPATIA_DISPATCH_PAT }}
109-
GITHUB_REPOSITORY: ${{ github.repository }}
110-
GITHUB_SHA: ${{ github.sha }}
111-
FINDINGS_COUNT: ${{ steps.scan.outputs.findings_count }}
112-
run: |
113-
echo "📤 Submitting $FINDINGS_COUNT findings to gitbot-fleet..."
114-
115-
# Clone gitbot-fleet to temp directory. A clone failure (network,
116-
# repo gone) is non-fatal: learning submission is best-effort.
117-
FLEET_DIR="/tmp/gitbot-fleet-$$"
118-
if ! git clone --depth 1 https://github.com/hyperpolymath/gitbot-fleet.git "$FLEET_DIR"; then
119-
echo "::warning::Could not clone gitbot-fleet — skipping Phase 2 learning submission (non-fatal)."
120-
exit 0
121-
fi
122-
123-
# The submission script's location in gitbot-fleet has drifted
124-
# before (it was absent from the default branch, which exit-127'd
125-
# every consuming repo's scan). Probe known locations rather than
126-
# hard-coding one path, and skip gracefully if none is present.
127-
SUBMIT_SCRIPT=""
128-
for cand in \
129-
"$FLEET_DIR/scripts/submit-finding.sh" \
130-
"$FLEET_DIR/scripts/submit_finding.sh" \
131-
"$FLEET_DIR/bin/submit-finding.sh" \
132-
"$FLEET_DIR/submit-finding.sh"; do
133-
if [ -f "$cand" ]; then
134-
SUBMIT_SCRIPT="$cand"
135-
break
136-
fi
137-
done
138-
139-
if [ -z "$SUBMIT_SCRIPT" ]; then
140-
echo "::warning::gitbot-fleet submit-finding script not found at any known path — skipping Phase 2 learning submission (non-fatal). Findings are still uploaded as an artifact and gated below."
141-
rm -rf "$FLEET_DIR"
142-
exit 0
143-
fi
144-
145-
# Run submission script. Pass the findings path as ABSOLUTE —
146-
# the script cd's into its own working dir before reading the
147-
# file, so a relative path would resolve to the wrong place.
148-
# A submission-script failure is logged but non-fatal.
149-
if bash "$SUBMIT_SCRIPT" "$GITHUB_WORKSPACE/hypatia-findings.json"; then
150-
echo "✅ Finding submission complete"
151-
else
152-
echo "::warning::gitbot-fleet submission script exited non-zero — Phase 2 learning submission skipped (non-fatal)."
153-
fi
154-
155-
# Cleanup
156-
rm -rf "$FLEET_DIR"
157-
158-
- name: Check for critical issues
159-
if: steps.scan.outputs.critical > 0
160-
run: |
161-
echo "⚠️ Critical security issues found!"
162-
echo "Review hypatia-findings.json for details"
163-
# Don't fail the build yet - just warn
164-
# exit 1
165-
166-
- name: Generate scan report
167-
run: |
168-
cat << EOF > hypatia-report.md
169-
# Hypatia Security Scan Report
170-
171-
**Repository:** ${{ github.repository }}
172-
**Scan Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
173-
**Commit:** ${{ github.sha }}
174-
175-
## Summary
176-
177-
| Severity | Count |
178-
|----------|-------|
179-
| Critical | ${{ steps.scan.outputs.critical }} |
180-
| High | ${{ steps.scan.outputs.high }} |
181-
| Medium | ${{ steps.scan.outputs.medium }} |
182-
| **Total**| ${{ steps.scan.outputs.findings_count }} |
183-
184-
## Next Steps
185-
186-
1. Review findings in the artifact: hypatia-findings.json
187-
2. Auto-fixable issues will be addressed by robot-repo-automaton (Phase 3)
188-
3. Manual review required for complex issues
189-
190-
## Learning
191-
192-
These findings feed Hypatia's learning engine to improve future rules.
193-
194-
---
195-
*Powered by [Hypatia](https://github.com/hyperpolymath/hypatia) - Neurosymbolic CI/CD Intelligence*
196-
EOF
197-
198-
cat hypatia-report.md >> $GITHUB_STEP_SUMMARY
199-
200-
- name: Comment on PR with findings
201-
if: github.event_name == 'pull_request' && steps.scan.outputs.findings_count > 0
202-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v7
203-
with:
204-
script: |
205-
const fs = require('fs');
206-
const findings = JSON.parse(fs.readFileSync('hypatia-findings.json', 'utf8'));
207-
208-
const critical = findings.filter(f => f.severity === 'critical').length;
209-
const high = findings.filter(f => f.severity === 'high').length;
210-
211-
let comment = `## 🔍 Hypatia Security Scan\n\n`;
212-
comment += `**Findings:** ${findings.length} issues detected\n\n`;
213-
comment += `| Severity | Count |\n|----------|-------|\n`;
214-
comment += `| 🔴 Critical | ${critical} |\n`;
215-
comment += `| 🟠 High | ${high} |\n`;
216-
comment += `| 🟡 Medium | ${findings.length - critical - high} |\n\n`;
217-
218-
if (critical > 0) {
219-
comment += `⚠️ **Action Required:** Critical security issues found!\n\n`;
220-
}
221-
222-
comment += `<details><summary>View findings</summary>\n\n`;
223-
comment += `\`\`\`json\n${JSON.stringify(findings.slice(0, 10), null, 2)}\n\`\`\`\n`;
224-
comment += `</details>\n\n`;
225-
comment += `*Powered by Hypatia Neurosymbolic CI/CD Intelligence*`;
226-
227-
github.rest.issues.createComment({
228-
owner: context.repo.owner,
229-
repo: context.repo.repo,
230-
issue_number: context.issue.number,
231-
body: comment
232-
});
27+
hypatia:
28+
uses: hyperpolymath/standards/.github/workflows/hypatia-scan-reusable.yml@97df762107501909f50bb770e9bc200b6c415600
29+
secrets: inherit

0 commit comments

Comments
 (0)