This repository was archived by the owner on Jun 3, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
87 lines (71 loc) · 2.3 KB
/
Copy pathsecurity-scan.yml
File metadata and controls
87 lines (71 loc) · 2.3 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
name: Security Scan
on:
pull_request:
branches: [main, master, develop]
schedule:
- cron: "0 2 * * 1" # also run weekly on Mondays at 02:00 UTC
permissions:
contents: read
security-events: write # needed to upload SARIF to GitHub Security tab
concurrency:
group: security-${{ github.ref }}
cancel-in-progress: true
jobs:
bandit:
name: Bandit SAST
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install bandit
run: pip install "bandit[toml,sarif]"
- name: Run Bandit
run: |
bandit -r src/ \
-ll \
--exclude src/tests \
-f sarif \
-o bandit-results.sarif
continue-on-error: true
- name: Upload Bandit SARIF
if: >-
always() &&
hashFiles('bandit-results.sarif') != '' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: bandit-results.sarif
category: bandit
- name: Summarize Bandit for fork PR
if: >-
always() &&
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository
run: |
{
echo "### Bandit SAST"
echo
echo "Bandit ran for this fork PR. SARIF upload to the repository security tab is skipped because fork PR tokens are read-only."
} >> "$GITHUB_STEP_SUMMARY"
pip-audit:
name: Dependency CVE Audit
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install pip-audit
run: pip install pip-audit
- name: Audit dependencies
run: pip-audit --requirement <(pip install -e ".[dev]" --dry-run -q 2>&1 | grep "Would install" | sed 's/.*Would install //' | tr ' ' '\n' | sed 's/==.*/==&/') || true
- name: pip-audit (from pyproject)
run: |
pip install -e ".[dev]" -q
pip-audit