-
Notifications
You must be signed in to change notification settings - Fork 858
101 lines (85 loc) · 2.88 KB
/
Copy pathsecurity.yml
File metadata and controls
101 lines (85 loc) · 2.88 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
95
96
97
98
99
100
101
name: Security Scan
on:
push:
branches: [main, develop]
pull_request:
schedule:
- cron: '0 0 * * 1' # 每周一
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
# ========== 密钥泄露检测 ==========
secrets-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run TruffleHog
uses: trufflesecurity/trufflehog@v3.88.30
with:
path: ./
base: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
head: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
extra_args: --only-verified
# ========== 依赖漏洞扫描 ==========
dependency-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24.x'
- uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ hashFiles('package.json') }}
restore-keys: npm-${{ runner.os }}-
# npm install 会生成临时 package-lock.json 供 audit 使用
- run: npm install
# npm audit
- name: Run npm audit
run: |
echo "Running npm audit..."
npm audit --audit-level=high || echo "⚠ npm audit found issues (non-blocking)"
# 使用 better-npm-audit 获得更好体验
- name: Run better-npm-audit
run: |
npx better-npm-audit audit --level=high || echo "⚠ better-npm-audit found issues (non-blocking)"
# ========== Skill 依赖扫描 ==========
skills-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '24.x'
- name: Audit Skills
run: |
set +e # Don't exit on error
for skill in SKILLs/*/; do
if [ -f "$skill/package.json" ]; then
echo ""
echo "=== Auditing $skill ==="
(cd "$skill" && npm install --package-lock-only 2>/dev/null && npm audit --audit-level=moderate 2>/dev/null) || echo "⚠ Audit issues found in $skill (non-blocking)"
fi
done
echo ""
echo "=== Skill audit complete ==="
# ========== 代码扫描 (CodeQL) ==========
codeql:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: javascript, typescript
- name: Autobuild
uses: github/codeql-action/autobuild@v4
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4