-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_bandit.py
More file actions
40 lines (29 loc) · 925 Bytes
/
run_bandit.py
File metadata and controls
40 lines (29 loc) · 925 Bytes
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
#!/usr/bin/env python3
"""Run bandit security scan and summarize findings.
Usage:
python scripts/run_bandit.py # Medium+ severity
python scripts/run_bandit.py --all # All severities
python scripts/run_bandit.py --strict # Fail on any finding
"""
import subprocess
import sys
def main() -> int:
args = sys.argv[1:]
show_all = "--all" in args
strict = "--strict" in args
cmd = [
sys.executable, "-m", "bandit",
"-r", "src/divineos/",
"-f", "txt",
"-s", "B101", # Skip assert_used (tests use asserts)
"--exclude", "tests",
]
if not show_all:
cmd.extend(["-ll"]) # Medium+ severity only
result = subprocess.run(cmd)
if strict and result.returncode != 0:
print("\n[!] Bandit found issues — strict mode, failing.")
return 1
return 0
if __name__ == "__main__":
raise SystemExit(main())