Repository navigation
59 lines (53 loc) · 2.59 KB
/
Copy pathsecurity.yml
File metadata and controls
59 lines (53 loc) · 2.59 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
name: Security
# 安全扫描的姿态(2026-10 审计后改口径):gitleaks 与 dependency-review 一红,
# job 就是红的;但「红」≠「拦合并」——只有进了 main 的 required status checks
# 才会真的挡住 PR。这条区别写在注释里而不是只靠印象:本轮把两者加进 required
# checks 之前,任何一次安全告警都只是标签页里的一条记录。
# osv-scanner 现在也 fail-on-vuln=true(lockfile 有已知漏洞即红),不再只当提醒。
# 组成:
# 1. gitleaks —— 密钥泄露扫描(NPM_TOKEN 等一旦进历史就完了,这是最便宜的保险)
# 2. dependency-review —— PR 依赖 diff:新引入依赖的已知漏洞 / 投毒包举报(OSV)
# 3. osv-scanner —— 全量 lockfile 扫描(push 到 main 时兜底,结果进 Security 标签页)
# Socket App(行为级投毒检测)是 GitHub App,不占本文件——在 github.com/apps/socket-security 安装后自动生效。
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 全历史扫描:只扫增量会漏掉历史里已存在的密钥
# 不用 gitleaks-action:v2 起对组织仓库强制 license(个人免费、组织收费),
# 官方二进制本身开源免费,直接跑即可,行为等价
- name: Run gitleaks (binary, full history)
run: |
curl -sSfL https://github.com/gitleaks/gitleaks/releases/download/v8.24.3/gitleaks_8.24.3_linux_x64.tar.gz | tar -xz gitleaks
./gitleaks detect --source . --no-banner --redact
dependency-review:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# OSV 的「恶意包」(投毒)severity 为 critical → moderate 门槛即可拦住;
# 正常依赖升级不出声,不敏感
- uses: actions/dependency-review-action@v4
with:
fail-on-severity: moderate
# 官方 reusable workflow:扫 lockfile、SARIF 传 Security 标签页;fail-on-vuln=true = 有已知漏洞即红
# (2026-10 审计前它是 false,只上传 SARIF 不拦;lockfile 当时 0 漏洞,所以打开没有存量噪音)
osv-scanner:
if: github.event_name == 'push'
permissions:
actions: read
contents: read
security-events: write
uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.6.0
with:
fail-on-vuln: true
scan-args: |-
-r ./dsh-mneme