Skip to content

Commit b1498fb

Browse files
authored
Merge pull request #617 from wlemkows/ur-bandit-setup
Add Bandit scan for python tools
2 parents 1eba168 + 9209d1d commit b1498fb

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

.github/workflows/bandit.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Runs bandit security checker for code written in Python.
2+
name: Bandit
3+
4+
on: [push, pull_request, workflow_dispatch]
5+
6+
jobs:
7+
linux:
8+
name: Bandit
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Clone the git repo
13+
uses: actions/checkout@v3
14+
15+
- name: Install apt packages
16+
run: |
17+
sudo apt-get update
18+
sudo apt-get install -y doxygen
19+
20+
- name: Install pip packages
21+
run: pip install -r third_party/requirements.txt
22+
23+
# Scan is run only for the 'tools' folder.
24+
- name: Run Bandit
25+
run: |
26+
bandit -r tools

third_party/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
alabaster==0.7.12
22
Babel==2.7.0
3+
bandit==1.6.2
34
beautifulsoup4==4.11.1
45
breathe==4.33.1
56
bs4==0.0.1

tools/urtrace/urtrace.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# See LICENSE.TXT
66
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77
import argparse
8-
import subprocess
8+
import subprocess # nosec B404
99
import os
1010
import sys
1111

@@ -134,7 +134,9 @@ def get_dynamic_library_name(name):
134134
print(env)
135135

136136
if config['command']:
137-
result = subprocess.run(config['command'], env=env)
137+
# The core functionality is to pass the user's command,
138+
# and it is the user's responsibility to pass secure parameters.
139+
result = subprocess.run(config['command'], env=env) # nosec B603
138140
if args.debug:
139141
print(result)
140142
exit(result.returncode)

0 commit comments

Comments
 (0)