-
Notifications
You must be signed in to change notification settings - Fork 3
117 lines (95 loc) · 3.25 KB
/
Copy pathsecurity-scan.yaml
File metadata and controls
117 lines (95 loc) · 3.25 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Security Scan
on:
schedule:
# Run every Monday at 09:00 UTC
- cron: '0 9 * * 1'
workflow_dispatch: # Allow manual trigger
env:
CARGO_TERM_COLOR: always
jobs:
# SCA: Check for new CVEs in dependencies
dependency-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Run security audit
id: audit
run: |
cargo audit --json > audit-results.json 2>&1 || true
cargo audit --deny warnings
- name: Upload audit results
if: always()
uses: actions/upload-artifact@v7
with:
name: cargo-audit-results
path: audit-results.json
retention-days: 30
# Check for outdated dependencies
dependency-freshness:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install cargo-outdated
run: cargo install cargo-outdated --locked
- name: Check outdated dependencies
run: cargo outdated --root-deps-only
# License and supply chain compliance
supply-chain-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install cargo-deny
run: cargo install cargo-deny --locked
- name: Check licenses and advisories
run: cargo deny check
# Secrets scanning across full history
secrets-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Run gitleaks (full history)
uses: gitleaks/gitleaks-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
# Create issue on vulnerability detection
notify-on-findings:
runs-on: ubuntu-latest
needs: [dependency-audit]
if: failure()
steps:
- uses: actions/checkout@v7
- name: Create issue for vulnerabilities
uses: actions/github-script@v9
with:
script: |
const title = '🤖 Dependency vulnerabilities detected';
const body = `## Weekly Security Scan Alert
The scheduled security scan has detected potential vulnerabilities in project dependencies.
**Action Required:**
1. Review the [workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})
2. Run \`cargo audit\` locally for details
3. Update affected dependencies or apply mitigations
**Scan Date:** ${new Date().toISOString().split('T')[0]}
`;
// Check for existing open issue
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'security'
});
const existingIssue = issues.data.find(i => i.title === title);
if (!existingIssue) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['security', 'dependencies']
});
}