-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (99 loc) · 2.89 KB
/
Copy pathsecurity-scan.yml
File metadata and controls
119 lines (99 loc) · 2.89 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
118
119
# .github/workflows/security-scan.yml
# Automated security scanning on every push and PR
name: Security Scan
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
schedule:
# Run weekly security scan
- cron: '0 9 * * 1'
jobs:
# Dependency vulnerability check
dependency-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: pip install safety pip-audit
- name: Check Python dependencies
run: |
pip-audit -r requirements.txt || true
safety check -r requirements.txt || true
# Static analysis
static-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install tools
run: pip install bandit semgrep
- name: Bandit security scan
run: bandit -r . -ll -ii --format json -o bandit-report.json || true
- name: Semgrep scan
uses: semgrep/semgrep-action@v1
with:
config: >-
p/python
p/owasp-top-ten
p/security-audit
continue-on-error: true
- name: Upload results
uses: actions/upload-artifact@v4
if: always()
with:
name: security-reports
path: |
bandit-report.json
# Secret detection
secret-detection:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: TruffleHog scan
uses: trufflesecurity/trufflehog@main
with:
extra_args: --only-verified
# Container security (if using Docker)
container-scan:
runs-on: ubuntu-latest
if: hashFiles('Dockerfile') != ''
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build -t local/test .
- name: Trivy container scan
uses: aquasecurity/trivy-action@master
with:
image-ref: 'local/test'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'
# License compliance
license-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Check licenses
run: |
pip install pip-licenses
pip-licenses --from=mixed --format=json --with-urls --allow-only="MIT;BSD;Apache-2.0;ISC;PSF"