7 from pathlib import Path
10 def is_excluded(f: str) -> bool:
11 return re.match(r"^([.]git|config/chroot_local-includes/usr/share/doc/tails/website|submodules|tmp|wiki/src)/",
12 f) is not None or Path(f).is_dir()
15 def mimetype(f: str) -> str:
16 return subprocess.run(['file', '--brief', '--mime-type', f],
17 stdout=subprocess.PIPE,
18 universal_newlines=True,
19 check=True).stdout.rstrip()
22 def is_python_file(f: str) -> bool:
23 return f.endswith('.py') or mimetype(f) == "text/x-script.python"
27 f for f in glob.glob("**/*", recursive=True)
28 if not is_excluded(f) and is_python_file(f)
32 subprocess.run(['bandit'] + sys.argv[1:] + python_files).returncode)