-
Notifications
You must be signed in to change notification settings - Fork 13
114 lines (98 loc) · 2.82 KB
/
security.yaml
File metadata and controls
114 lines (98 loc) · 2.82 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
name: Security Scan
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
trivy-scan:
name: Trivy
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f pyproject.toml ]; then
pip install -e ".[dev]"
fi
- name: Run Trivy vulnerability scan
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
exit-code: '0'
- name: Check for critical and high vulnerabilities
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
with:
scan-type: 'fs'
scan-ref: '.'
format: 'table'
severity: 'CRITICAL,HIGH'
exit-code: '1'
continue-on-error: true
- name: Upload Trivy scan results to Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results.sarif'
category: 'trivy-security-scan'
bandit-scan:
name: Bandit
runs-on: ubuntu-latest
permissions:
security-events: write
actions: read
contents: read
checks: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Create virtual environment
run: |
python -m pip install --upgrade pip
python -m venv .venv
- name: Install dependencies
run: |
source .venv/bin/activate
pip install -e ".[dev]"
- name: Install Bandit
run: |
source .venv/bin/activate
pip install bandit[sarif]
- name: Run Bandit Security Scan
uses: PyCQA/bandit-action@v1
with:
targets: "."
exclude: "tests"
- name: Upload SARIF results to Security tab
if: github.ref == 'refs/heads/main'
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
category: bandit-security-scan
continue-on-error: true
- name: Upload SARIF as artifact
uses: actions/upload-artifact@v4
with:
name: bandit-sarif-results
path: results.sarif
retention-days: 30
continue-on-error: true