Skip to content

Commit 4c94e51

Browse files
authored
Merge pull request #389 from lukaszstolarczuk/add-bandit
Add bandit scanner workflow
2 parents e17a0ad + b5218d4 commit 4c94e51

File tree

4 files changed

+40
-11
lines changed

4 files changed

+40
-11
lines changed

.github/workflows/bandit.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Bandit static analysis (for Python code)
2+
name: Bandit
3+
4+
on: [push, pull_request]
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
8+
cancel-in-progress: true
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
bandit:
15+
name: Bandit
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, windows-latest]
19+
runs-on: ${{matrix.os}}
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
24+
25+
- name: Install Bandit
26+
run: python3 -m pip install bandit
27+
28+
# Run Bandit recursively, but omit _deps directory (with 3rd party code)
29+
- name: Run Bandit
30+
run: python3 -m bandit -r . -x '/_deps/'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/oneapi-src/unified-memory-framework/badge)](https://securityscorecards.dev/viewer/?uri=github.com/oneapi-src/unified-memory-framework)
1010
[![Coverity build](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/coverity.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/coverity.yml)
1111
[![Coverity report](https://scan.coverity.com/projects/29761/badge.svg?flat=0)](https://scan.coverity.com/projects/oneapi-src-unified-memory-framework)
12+
[![Bandit](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/bandit.yml/badge.svg?branch=main)](https://github.com/oneapi-src/unified-memory-framework/actions/workflows/bandit.yml)
1213

1314
## Introduction
1415

scripts/generate_docs.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
2-
Copyright (C) 2023 Intel Corporation
2+
Copyright (C) 2023-2024 Intel Corporation
33
44
Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
55
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
"""
77

88
from pathlib import Path
99
from shutil import rmtree
10-
import subprocess
10+
import subprocess # nosec B404
1111
import time
1212

1313

@@ -41,9 +41,8 @@ def _prepare_docs_dir(docs_path: Path) -> None:
4141
def _generate_xml(config_path: Path, docs_path: Path) -> None:
4242
print("Generating XML files with doxygen...", flush=True)
4343
try:
44-
subprocess.run(
45-
["doxygen", Path(config_path, "Doxyfile")], text=True
46-
).check_returncode()
44+
subprocess.run(["doxygen", Path(config_path, "Doxyfile")], text=True
45+
).check_returncode() # nosec B603, B607
4746
print(f"All XML files generated in {docs_path}", flush=True)
4847
except subprocess.CalledProcessError as ex:
4948
print("Generating XML files failed!")
@@ -54,9 +53,8 @@ def _generate_xml(config_path: Path, docs_path: Path) -> None:
5453
def _generate_html(config_path: Path, docs_path: Path) -> None:
5554
print("Generating HTML pages with sphinx...", flush=True)
5655
try:
57-
subprocess.run(
58-
["sphinx-build", config_path, Path(docs_path, "html")], text=True
59-
).check_returncode()
56+
subprocess.run(["sphinx-build", config_path, Path(docs_path, "html")], text=True
57+
).check_returncode() # nosec B603, B607
6058
print(f"All HTML files generated in {docs_path}", flush=True)
6159
except subprocess.CalledProcessError as ex:
6260
print("Generating HTML pages failed!")

test/test_installation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import difflib
1010
from pathlib import Path
1111
import platform
12-
import subprocess
12+
import subprocess # nosec B404
1313
import sys
1414
from typing import List
1515

@@ -143,7 +143,7 @@ def install_umf(self) -> None:
143143

144144
install_cmd = f"cmake --install {self.build_dir} --config {self.build_type.title()} --prefix {self.install_dir}"
145145
try:
146-
subprocess.run(install_cmd.split()).check_returncode()
146+
subprocess.run(install_cmd.split()).check_returncode() # nosec B603
147147
except subprocess.CalledProcessError:
148148
sys.exit(f"Error: UMF installation command '{install_cmd}' failed")
149149

@@ -180,7 +180,7 @@ def uninstall_umf(self) -> None:
180180
"""
181181
uninstall_cmd = f"cmake --build {self.build_dir} --target uninstall"
182182
try:
183-
subprocess.run(uninstall_cmd.split()).check_returncode()
183+
subprocess.run(uninstall_cmd.split()).check_returncode() # nosec B603
184184
except subprocess.CalledProcessError:
185185
sys.exit(f"Error: UMF uninstallation command '{uninstall_cmd}' failed")
186186

0 commit comments

Comments
 (0)