Skip to content

Commit b6eae5a

Browse files
chore(ci): convert hypatia-scan.yml to wrapper of standards reusable (#7)
* 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.
1 parent 544a39a commit b6eae5a

1 file changed

Lines changed: 18 additions & 218 deletions

File tree

.github/workflows/hypatia-scan.yml

Lines changed: 18 additions & 218 deletions
Original file line numberDiff line numberDiff line change
@@ -1,229 +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

14-
permissions: read-all
15-
16-
jobs:
17-
scan:
18-
name: Hypatia Neurosymbolic Analysis
19-
runs-on: ubuntu-latest
20-
21-
steps:
22-
- name: Checkout repository
23-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
24-
with:
25-
fetch-depth: 0 # Full history for better pattern analysis
26-
27-
- name: Setup Elixir for Hypatia scanner
28-
uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1.18.2
29-
with:
30-
elixir-version: '1.19.4'
31-
otp-version: '28.3'
32-
33-
- name: Clone Hypatia
34-
run: |
35-
if [ ! -d "$HOME/hypatia" ]; then
36-
git clone https://github.com/hyperpolymath/hypatia.git "$HOME/hypatia"
37-
fi
38-
39-
- name: Build Hypatia scanner (if needed)
40-
working-directory: /home/runner/hypatia
41-
run: |
42-
if [ ! -f hypatia-v2 ]; then
43-
echo "Building hypatia-v2 scanner..."
44-
mix deps.get
45-
mix escript.build
46-
mv hypatia ../hypatia-v2
47-
fi
48-
49-
- name: Run Hypatia scan
50-
id: scan
51-
env:
52-
# Suppress the Dependabot "GITHUB_TOKEN not set" warning.
53-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54-
run: |
55-
echo "Scanning repository: ${{ github.repository }}"
56-
57-
# Run scanner
58-
HYPATIA_FORMAT=json "$HOME/hypatia/hypatia-cli.sh" scan . --exit-zero > hypatia-findings.json
59-
60-
# Count findings
61-
FINDING_COUNT=$(jq '. | length' hypatia-findings.json 2>/dev/null || echo 0)
62-
echo "findings_count=$FINDING_COUNT" >> $GITHUB_OUTPUT
63-
64-
# Extract severity counts
65-
CRITICAL=$(jq '[.[] | select(.severity == "critical")] | length' hypatia-findings.json)
66-
HIGH=$(jq '[.[] | select(.severity == "high")] | length' hypatia-findings.json)
67-
MEDIUM=$(jq '[.[] | select(.severity == "medium")] | length' hypatia-findings.json)
68-
69-
echo "critical=$CRITICAL" >> $GITHUB_OUTPUT
70-
echo "high=$HIGH" >> $GITHUB_OUTPUT
71-
echo "medium=$MEDIUM" >> $GITHUB_OUTPUT
72-
73-
echo "## Hypatia Scan Results" >> $GITHUB_STEP_SUMMARY
74-
echo "- Total findings: $FINDING_COUNT" >> $GITHUB_STEP_SUMMARY
75-
echo "- Critical: $CRITICAL" >> $GITHUB_STEP_SUMMARY
76-
echo "- High: $HIGH" >> $GITHUB_STEP_SUMMARY
77-
echo "- Medium: $MEDIUM" >> $GITHUB_STEP_SUMMARY
78-
79-
- name: Upload findings artifact
80-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
81-
with:
82-
name: hypatia-findings
83-
path: hypatia-findings.json
84-
retention-days: 90
85-
86-
- name: Submit findings to gitbot-fleet (Phase 2)
87-
if: steps.scan.outputs.findings_count > 0
88-
# Phase 2 is the collaborative LEARNING side-channel ("bots share
89-
# findings via gitbot-fleet"), not the security gate. The gate is
90-
# the baseline-aware "Check for critical or high-severity issues"
91-
# step below. A fleet-side regression (e.g. the submit script being
92-
# moved/removed) must NEVER hard-fail every consuming repo's scan.
93-
# Same reasoning as the "Comment on PR with findings" step.
94-
# See hyperpolymath/hypatia#213 (gate decoupling) and the exit-127
95-
# estate-wide breakage when gitbot-fleet/scripts/submit-finding.sh
96-
# no longer existed on the default branch.
97-
continue-on-error: true
98-
env:
99-
# All GitHub context values surface as env vars so the run
100-
# block never interpolates `${{ … }}` inline (closes the
101-
# workflow_audit/unsafe_curl_payload + actions_expression_injection
102-
# findings).
103-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104-
FLEET_PUSH_TOKEN: ${{ secrets.HYPATIA_DISPATCH_PAT }}
105-
FLEET_DISPATCH_TOKEN: ${{ secrets.HYPATIA_DISPATCH_PAT }}
106-
GITHUB_REPOSITORY: ${{ github.repository }}
107-
GITHUB_SHA: ${{ github.sha }}
108-
FINDINGS_COUNT: ${{ steps.scan.outputs.findings_count }}
109-
run: |
110-
echo "📤 Submitting $FINDINGS_COUNT findings to gitbot-fleet..."
111-
112-
# Clone gitbot-fleet to temp directory. A clone failure (network,
113-
# repo gone) is non-fatal: learning submission is best-effort.
114-
FLEET_DIR="/tmp/gitbot-fleet-$$"
115-
if ! git clone --depth 1 https://github.com/hyperpolymath/gitbot-fleet.git "$FLEET_DIR"; then
116-
echo "::warning::Could not clone gitbot-fleet — skipping Phase 2 learning submission (non-fatal)."
117-
exit 0
118-
fi
119-
120-
# The submission script's location in gitbot-fleet has drifted
121-
# before (it was absent from the default branch, which exit-127'd
122-
# every consuming repo's scan). Probe known locations rather than
123-
# hard-coding one path, and skip gracefully if none is present.
124-
SUBMIT_SCRIPT=""
125-
for cand in \
126-
"$FLEET_DIR/scripts/submit-finding.sh" \
127-
"$FLEET_DIR/scripts/submit_finding.sh" \
128-
"$FLEET_DIR/bin/submit-finding.sh" \
129-
"$FLEET_DIR/submit-finding.sh"; do
130-
if [ -f "$cand" ]; then
131-
SUBMIT_SCRIPT="$cand"
132-
break
133-
fi
134-
done
135-
136-
if [ -z "$SUBMIT_SCRIPT" ]; then
137-
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."
138-
rm -rf "$FLEET_DIR"
139-
exit 0
140-
fi
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
14120

142-
# Run submission script. Pass the findings path as ABSOLUTE —
143-
# the script cd's into its own working dir before reading the
144-
# file, so a relative path would resolve to the wrong place.
145-
# A submission-script failure is logged but non-fatal.
146-
if bash "$SUBMIT_SCRIPT" "$GITHUB_WORKSPACE/hypatia-findings.json"; then
147-
echo "✅ Finding submission complete"
148-
else
149-
echo "::warning::gitbot-fleet submission script exited non-zero — Phase 2 learning submission skipped (non-fatal)."
150-
fi
21+
permissions:
22+
contents: read
23+
security-events: write
24+
pull-requests: write
15125

152-
# Cleanup
153-
rm -rf "$FLEET_DIR"
154-
155-
- name: Check for critical issues
156-
if: steps.scan.outputs.critical > 0
157-
run: |
158-
echo "⚠️ Critical security issues found!"
159-
echo "Review hypatia-findings.json for details"
160-
# Don't fail the build yet - just warn
161-
# exit 1
162-
163-
- name: Generate scan report
164-
run: |
165-
cat << EOF > hypatia-report.md
166-
# Hypatia Security Scan Report
167-
168-
**Repository:** ${{ github.repository }}
169-
**Scan Date:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
170-
**Commit:** ${{ github.sha }}
171-
172-
## Summary
173-
174-
| Severity | Count |
175-
|----------|-------|
176-
| Critical | ${{ steps.scan.outputs.critical }} |
177-
| High | ${{ steps.scan.outputs.high }} |
178-
| Medium | ${{ steps.scan.outputs.medium }} |
179-
| **Total**| ${{ steps.scan.outputs.findings_count }} |
180-
181-
## Next Steps
182-
183-
1. Review findings in the artifact: hypatia-findings.json
184-
2. Auto-fixable issues will be addressed by robot-repo-automaton (Phase 3)
185-
3. Manual review required for complex issues
186-
187-
## Learning
188-
189-
These findings feed Hypatia's learning engine to improve future rules.
190-
191-
---
192-
*Powered by [Hypatia](https://github.com/hyperpolymath/hypatia) - Neurosymbolic CI/CD Intelligence*
193-
EOF
194-
195-
cat hypatia-report.md >> $GITHUB_STEP_SUMMARY
196-
197-
- name: Comment on PR with findings
198-
if: github.event_name == 'pull_request' && steps.scan.outputs.findings_count > 0
199-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v7
200-
with:
201-
script: |
202-
const fs = require('fs');
203-
const findings = JSON.parse(fs.readFileSync('hypatia-findings.json', 'utf8'));
204-
205-
const critical = findings.filter(f => f.severity === 'critical').length;
206-
const high = findings.filter(f => f.severity === 'high').length;
207-
208-
let comment = `## 🔍 Hypatia Security Scan\n\n`;
209-
comment += `**Findings:** ${findings.length} issues detected\n\n`;
210-
comment += `| Severity | Count |\n|----------|-------|\n`;
211-
comment += `| 🔴 Critical | ${critical} |\n`;
212-
comment += `| 🟠 High | ${high} |\n`;
213-
comment += `| 🟡 Medium | ${findings.length - critical - high} |\n\n`;
214-
215-
if (critical > 0) {
216-
comment += `⚠️ **Action Required:** Critical security issues found!\n\n`;
217-
}
218-
219-
comment += `<details><summary>View findings</summary>\n\n`;
220-
comment += `\`\`\`json\n${JSON.stringify(findings.slice(0, 10), null, 2)}\n\`\`\`\n`;
221-
comment += `</details>\n\n`;
222-
comment += `*Powered by Hypatia Neurosymbolic CI/CD Intelligence*`;
223-
224-
github.rest.issues.createComment({
225-
owner: context.repo.owner,
226-
repo: context.repo.repo,
227-
issue_number: context.issue.number,
228-
body: comment
229-
});
26+
jobs:
27+
hypatia:
28+
uses: hyperpolymath/standards/.github/workflows/hypatia-scan-reusable.yml@97df762107501909f50bb770e9bc200b6c415600
29+
secrets: inherit

0 commit comments

Comments
 (0)