Skip to content

Commit b834596

Browse files
authored
Merge pull request trustyai-explainability#15 from AmberJBlue/main
chore: Add Bandit code scanning to security scan
2 parents be6eab4 + 993e02d commit b834596

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

.github/workflows/security.yml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
trivy-scan:
11-
name: Trivy Security Scan
11+
name: Trivy
1212
runs-on: ubuntu-latest
1313
permissions:
1414
contents: read
@@ -53,4 +53,58 @@ jobs:
5353
if: always()
5454
with:
5555
sarif_file: 'trivy-results.sarif'
56-
category: 'trivy-security-scan'
56+
category: 'trivy-security-scan'
57+
58+
bandit-scan:
59+
name: Bandit
60+
runs-on: ubuntu-latest
61+
permissions:
62+
security-events: write
63+
actions: read
64+
contents: read
65+
checks: write
66+
67+
steps:
68+
- uses: actions/checkout@v4
69+
70+
- name: Set up Python
71+
uses: actions/setup-python@v5
72+
with:
73+
python-version: "3.12"
74+
cache: "pip"
75+
76+
- name: Create virtual environment
77+
run: |
78+
python -m pip install --upgrade pip
79+
python -m venv .venv
80+
81+
- name: Install dependencies
82+
run: |
83+
source .venv/bin/activate
84+
pip install -e .
85+
86+
- name: Install Bandit
87+
run: |
88+
source .venv/bin/activate
89+
pip install bandit[sarif]
90+
91+
- name: Run Bandit Security Scan
92+
uses: PyCQA/bandit-action@67a458d90fa11fb1463e91e7f4c8f068b5863c7f
93+
with:
94+
targets: "."
95+
96+
- name: Upload SARIF results to Security tab
97+
if: github.ref == 'refs/heads/main'
98+
uses: github/codeql-action/upload-sarif@v3
99+
with:
100+
sarif_file: results.sarif
101+
category: bandit-security-scan
102+
continue-on-error: true
103+
104+
- name: Upload SARIF as artifact
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: bandit-sarif-results
108+
path: results.sarif
109+
retention-days: 30
110+
continue-on-error: true

0 commit comments

Comments
 (0)