Skip to content

Commit 108e9e5

Browse files
committed
feat: Add Security Agent Workflow for automated security assessments
1 parent accf935 commit 108e9e5

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Security Agent Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
security-assessment:
8+
runs-on: ubuntu-latest
9+
timeout-minutes: 15
10+
permissions:
11+
contents: read
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 22
20+
21+
- name: Install GitHub Copilot CLI
22+
run: npm i -g @github/copilot
23+
24+
- name: Run Security Agent via Copilot CLI
25+
env:
26+
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
27+
GITHUB_REPOSITORY: ${{ github.repository }}
28+
run: |
29+
set -euo pipefail
30+
AGENT_PROMPT=$(cat .github/agents/security-agent.md)
31+
PROMPT="$AGENT_PROMPT"
32+
PROMPT+=$'\n\nContext:\n'
33+
PROMPT+="- Repository: $GITHUB_REPOSITORY"
34+
PROMPT+=$'\n\nTask:\n'
35+
PROMPT+=$"\n- Execute the instructions on the full codebase"
36+
PROMPT+=$'\n- Generate the security report at /security-reports/security-assessment-report.md summarizing findings, severity, and remediation guidance.'
37+
38+
copilot --prompt "$PROMPT" --allow-all-tools --allow-all-paths < /dev/null
39+
40+
- name: Output security report as summary
41+
if: always()
42+
run: |
43+
set -euo pipefail
44+
REPORT_PATH="security-reports/security-assessment-report.md"
45+
46+
if [ ! -f "$REPORT_PATH" ]; then
47+
echo "No security report generated; skipping summary."
48+
exit 0
49+
fi
50+
51+
echo "## Security Assessment Report" >> $GITHUB_STEP_SUMMARY
52+
cat "$REPORT_PATH" >> $GITHUB_STEP_SUMMARY
53+
54+
- name: Upload security report artifact
55+
if: always()
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: security-assessment-report-${{ github.run_id }}
59+
path: security-reports/security-assessment-report.md
60+
retention-days: 30
61+
62+
- name: Check for critical vulnerabilities
63+
if: always()
64+
run: |
65+
set -euo pipefail
66+
REPORT_PATH="security-reports/security-assessment-report.md"
67+
68+
if [ ! -f "$REPORT_PATH" ]; then
69+
echo "No security report generated; skipping critical check."
70+
exit 0
71+
fi
72+
73+
if grep -q "THIS ASSESSMENT CONTAINS A CRITICAL VULNERABILITY" "$REPORT_PATH"; then
74+
echo "❌ CRITICAL VULNERABILITY DETECTED - Workflow failed"
75+
echo "The security assessment found critical vulnerabilities that must be addressed before proceeding."
76+
exit 1
77+
else
78+
echo "✅ No critical vulnerabilities detected"
79+
fi

0 commit comments

Comments
 (0)