Repository navigation
Expand file tree
/
Copy pathgithub-action-workflow.yml
More file actions
94 lines (83 loc) · 3.27 KB
/
Copy pathgithub-action-workflow.yml
File metadata and controls
94 lines (83 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# ClawMoat CI/CD Integration Examples
# Add this to your repo's .github/workflows/ directory
#
# Example 1: Scan PR diffs for prompt injection & secret leaks
# Example 2: Scan agent config files before deployment
# Example 3: Full project scan on push to main
# ─── Example 1: PR Security Scan ─────────────────────────────────
name: ClawMoat Security Scan
on:
pull_request:
branches: [main, develop]
push:
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
clawmoat-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install ClawMoat
run: npm install -g clawmoat
# Scan all text/config files for prompt injection, secrets, PII
- name: Scan for threats
run: |
echo "## 🏰 ClawMoat Security Scan" >> $GITHUB_STEP_SUMMARY
# Scan changed files in PR
if [ "${{ github.event_name }}" = "pull_request" ]; then
FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD -- '*.md' '*.yml' '*.yaml' '*.json' '*.txt' '*.env*' '*.js' '*.ts' '*.py')
else
FILES=$(find . -type f \( -name "*.md" -o -name "*.yml" -o -name "*.yaml" -o -name "*.json" -o -name "*.js" -o -name "*.ts" -o -name "*.py" \) -not -path "*/node_modules/*" -not -path "*/.git/*")
fi
FOUND_ISSUES=0
for file in $FILES; do
if [ -f "$file" ]; then
RESULT=$(clawmoat scan "$file" --format json 2>/dev/null || true)
if echo "$RESULT" | grep -q '"blocked":true'; then
echo "⛔ **BLOCKED** — $file" >> $GITHUB_STEP_SUMMARY
echo "$RESULT" | jq -r '.findings[] | " - \(.severity): \(.type)/\(.subtype)"' >> $GITHUB_STEP_SUMMARY 2>/dev/null
FOUND_ISSUES=1
fi
fi
done
if [ "$FOUND_ISSUES" = "1" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "❌ Security issues found. Review above findings." >> $GITHUB_STEP_SUMMARY
exit 1
else
echo "✅ No security issues found." >> $GITHUB_STEP_SUMMARY
fi
# Scan OpenClaw skills if present
- name: Scan skills (supply chain)
if: always()
run: |
if [ -d "skills/" ]; then
clawmoat audit skills/ --format summary >> $GITHUB_STEP_SUMMARY
fi
# ─── Example 2: Pre-deployment Agent Config Scan ─────────────────
# Uncomment and adapt for your deployment pipeline:
#
# deploy-scan:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with: { node-version: '20' }
# - run: npm install -g clawmoat
# - name: Validate agent configs
# run: |
# # Scan YAML configs for dangerous patterns
# for f in config/*.yml agents/*.yml; do
# clawmoat scan "$f" --fail-on high
# done
# - name: Scan prompts for injection
# run: |
# # Scan prompt templates
# for f in prompts/*.md prompts/*.txt; do
# clawmoat scan "$f" --fail-on critical
# done