# Bandit configuration for the template research repository. # # exclude_dirs: skip third-party and non-authored trees so local pre-push stays # fast when developers keep per-project `.venv/` trees under `projects/` (tens # of thousands of `.py` files otherwise). Same policy in CI (harmless no-ops # when those dirs are absent on a clean checkout). exclude_dirs: # Non-rendered typed project subfolders hold private/rotating WIP — not held # to the exemplar security floor. Keep in sync with # infrastructure.project.discovery.NON_RENDERED_SUBDIRS. - "projects/working" - "projects/ongoing" - "projects/published" - "projects/archive" - "projects/other" - ".venv" - "site-packages" # Vendored Lean/Lake package cache (e.g. actinf_policy_entanglement_lean's # lean/MathlibProofs/.lake/packages/mathlib). Third-party, non-authored; # same policy as .venv/site-packages. Harmless no-op on clean checkouts. - ".lake" # Optional upstream Kmyth git submodule. Third-party C sources and tooling; # template-owned Python integration is in infrastructure/steganography/*.py. - "infrastructure/steganography/kmyth" # Rotating research projects: research WIP intentionally NOT held to the # exemplar security floor (the same documented rotating-project exception # that applies to coverage and mypy). The security gate stays strict on # `infrastructure/`, `scripts/`, and the canonical exemplars # (`template_active_inference` / `template_code_project` / `template_prose_project` — all clean); rotating # research code must not block every contributor's push/CI. Harmless no-op # when a name is absent on a given checkout (these rotate to the already- # excluded typed subfolders `projects/working/` … `projects/archive/`). - "projects/BeeStack" - "projects/cogant" - "projects/crescent_city" - "projects/deep_temporal_affect" - "projects/biology_textbook" - "projects/actinf_policy_entanglement_lean" - "projects/_test_project" # # Policy: CI runs Bandit at MEDIUM+ severity (`-ll`) over `infrastructure/`, # `scripts/`, and `projects/` (minus `exclude_dirs` above). The skips below silence LOW-severity findings # that are systemically safe in this codebase, so a stricter scan # (`bandit -r --severity-level low`) also runs clean. Documented at # `docs/rules/security.md` and `.github/AGENTS.md`. # # Each skipped test is justified below. New findings outside these IDs MUST # be triaged: either fix the code or add a targeted `# nosec reason: …`. skips: # B101 — assert_used. # Asserts in `infrastructure/` express internal invariants and are validated # by tests, not relied on for security boundaries. Coverage gates ensure # they are exercised. Suppressing B101 reduces noise without weakening # security review of real issues. (Mirrors `[tool.bandit]` in # `pyproject.toml`.) - B101 # B311 — pseudo-random generators. # `random.random()` is used only for retry-jitter (thundering-herd # mitigation in `infrastructure/core/runtime/retry.py`). It is never used # for tokens, secrets, or anything cryptographic. Cryptographic randomness # uses `secrets` / `os.urandom` directly where required. - B311 # B403 — pickle import. # Imported only by `infrastructure/validation/integrity/checks.py` to # validate already-trusted, locally-produced pickle artifacts during # output integrity checks. No untrusted pickle data is loaded; the file # carries an explicit `noqa: S403` comment. - B403 # B404 — subprocess import. # Subprocess is unavoidable for our orchestrator pattern: launching the # local Ollama server, invoking `pdflatex`/`pandoc` for rendering, # running `ruff`/`mypy`/`bandit` from gate scripts, and executing # discovered `scripts/` analysis modules. All call sites use fixed-list # argv with `shell=False`. Importing the module itself is not a risk. - B404 # B405 — xml.etree Element import. # The single occurrence in # `infrastructure/search/literature/backends.py` re-exports `Element` # solely as a type-hint target. Actual XML parsing uses `defusedxml`. - B405 # B603 — subprocess_without_shell_equals_true. # Same systemic justification as B404. Every call site passes a fixed # argv list with the default `shell=False`; no user-controlled string is # concatenated into a command. The one run-varying token — a project slug # — is path-traversal-validated by # `infrastructure.orchestration.discovery.validate_project_slug` before it # reaches any argv list. - B603 # B607 — start_process_with_partial_path. # Partial paths are restricted to well-known, hard-coded executables # (`bandit`, `pip-audit`, `safety`, `which`, `rm`, `kpsewhich`, `git`) # invoked from gate / fixture / discovery scripts. Resolution relies on # the developer / CI runner `PATH`, which is treated as trusted. - B607