Skip to content

Commit d425a88

Browse files
kkraus14cryos
andauthored
Add CodeQL and Bandit Static Analysis Scans (#560)
* Add CodeQL and Bandit Static Analysis Scans * Add concurrency groups and cancel in progress Co-authored-by: Marcus D. Hanwell <[email protected]> * Add bandit to pre-commit * Change CodeQL workflow to only be manually triggered for now * skip bandit on pre-commit.ci * Revert "Change CodeQL workflow to only be manually triggered for now" This reverts commit c529e5f. --------- Co-authored-by: Marcus D. Hanwell <[email protected]>
1 parent db7c854 commit d425a88

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

.github/workflows/bandit.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "Static Analysis: Bandit Scan"
2+
3+
on:
4+
push:
5+
branches:
6+
- "pull-request/[0-9]+"
7+
- "main"
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
analyze:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
security-events: write
17+
steps:
18+
- name: Perform Bandit Analysis
19+
uses: PyCQA/bandit-action@8a1b30610f61f3f792fe7556e888c9d7dffa52de # v1.0.0

.github/workflows/codeql.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "Static Analysis: CodeQL Scan"
2+
3+
on:
4+
push:
5+
branches:
6+
- "pull-request/[0-9]+"
7+
- "main"
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
analyze:
14+
name: Analyze (${{ matrix.language }})
15+
runs-on: ubuntu-latest
16+
permissions:
17+
security-events: write
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- language: python
24+
build-mode: none
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v3
31+
with:
32+
languages: ${{ matrix.language }}
33+
build-mode: ${{ matrix.build-mode }}
34+
queries: security-extended
35+
36+
- name: Perform CodeQL Analysis
37+
uses: github/codeql-action/analyze@v3
38+
with:
39+
category: "/language:${{matrix.language}}"

.pre-commit-config.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ ci:
66
autoupdate_branch: ''
77
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
88
autoupdate_schedule: quarterly
9-
skip: []
9+
skip: [bandit]
1010
submodules: false
1111

1212
repos:
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.11.4
14+
rev: 971923581912ef60a6b70dbf0c3e9a39563c9d47 #v0.11.4
1515
hooks:
1616
- id: ruff
1717
args: [--fix, --show-fixes]
1818
- id: ruff-format
19+
- repo: https://github.com/PyCQA/bandit
20+
rev: 8ff25e07e487f143571cc305e56dd0253c60bc7b #v1.8.3
21+
hooks:
22+
- id: bandit
1923

2024
default_language_version:
2125
python: python3

0 commit comments

Comments
 (0)