-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (104 loc) · 3.13 KB
/
bandit.yaml
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
# https://github.com/marketplace/actions/bandit-scan is ISC licensed, by abirismyname
# https://pypi.org/project/bandit/ is Apache v2.0 licensed, by PyCQA
name: Bandit
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
bandit:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
runs-on: ubuntu-latest
steps:
- name: Sleep for 5min to let Jenkins checks start
uses: jakejarvis/wait-action@master
with:
time: '5m'
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
run: |
pip install bandit bandit-sarif-formatter
- name: Run Bandit scan
shell: bash
run: |
UPPERCASE_LEVEL=$(echo $INPUT_LEVEL | tr a-z A-Z)
case $UPPERCASE_LEVEL in
LOW)
LEVEL="-l"
;;
MEDIUM | MID)
LEVEL="-ll"
;;
HIGH)
LEVEL="-lll"
;;
*)
LEVEL=""
;;
esac
UPPERCASE_CONFIDENCE=$(echo $INPUT_CONFIDENCE | tr a-z A-Z)
case $UPPERCASE_CONFIDENCE in
LOW)
CONFIDENCE="-i"
;;
MEDIUM | MID)
CONFIDENCE="-ii"
;;
HIGH)
CONFIDENCE="-iii"
;;
*)
CONFIDENCE=""
;;
esac
if [ "$INPUT_EXCLUDED_PATHS" == "DEFAULT" ]; then
EXCLUDED_PATHS=""
else
EXCLUDED_PATHS="-x $INPUT_EXCLUDED_PATHS"
fi
if [ "$INPUT_EXIT_ZERO" == "DEFAULT" ]; then
EXIT_ZERO=""
else
EXIT_ZERO="--exit-zero"
fi
if [ "$INPUT_SKIPS" == "DEFAULT" ]; then
SKIPS=""
else
SKIPS="-s $INPUT_SKIPS"
fi
if [ "$INPUT_INI_PATH" == "DEFAULT" ]; then
INI_PATH=""
else
INI_PATH="--ini $INPUT_INI_PATH"
fi
bandit -f sarif -o results.sarif -r $INPUT_PATH $LEVEL $CONFIDENCE $EXCLUDED_PATHS $EXIT_ZERO $SKIPS $INI_PATH
env:
INPUT_PATH: '.'
INPUT_LEVEL: 'UNDEFINED'
INPUT_CONFIDENCE: 'UNDEFINED'
INPUT_EXCLUDED_PATHS: 'DEFAULT'
INPUT_EXIT_ZERO: true
INPUT_SKIPS: 'DEFAULT'
INPUT_INI_PATH: 'DEFAULT'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: results.sarif
path: results.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif