# Security scanner

BrigadeStack includes a local security scanner for agent workspaces. It produces redacted findings that you can review, suppress, or import into the local work inbox.

## Local Config

`brigadestack security init` writes `.brigade/security.toml`. The file is host-local and should stay gitignored.

Supported fields:

- `policy`: `personal`, `public-repo`, `ci`, or `strict`.
- `scan_profile`: `public-repo`, `internal-workspace`, or `local-only-audit`.
- `fail_on`: `none`, `low`, `medium`, `high`, or `critical`.
- `include_templates`: whether public template files are scanned.
- `enabled_checks`: any of `automation`, `handoff-injection`, `mcp`, `permissions`, `prompt-injection`, `secrets`, and `supply-chain`.
- `include_paths` and `exclude_paths`: relative path prefixes.
- `severity_threshold`: minimum severity retained in reports.
- `output_path`: relative path for the latest local evidence bundle.
- `[suppressions]` and `[suppression_reasons]`: reviewed finding fingerprints and reasons.

Keep tokens, private URLs, hostnames, mount paths, repo paths, and credentials out of this config. Use labels or local paths only when they are safe to expose in local command output.

## Review Flow

```bash
brigadestack security scan --target .
brigadestack security findings
brigadestack security show <finding-id>
brigadestack security suppress <finding-id-or-fingerprint> --reason "reviewed false positive"
brigadestack security unsuppress <finding-id-or-fingerprint>
brigadestack security doctor
```

Findings include stable `id`, `fingerprint`, `rule_id`, `severity`, `category`, `path`, `line`, `safe_excerpt`, and `remediation_hint` fields. Secret-looking values are redacted before JSON reports, Markdown reports, work imports, docs, or session artifacts are written.

The `handoff-injection` check screens pending handoff notes in writer inboxes for prompt-injection signals, using the same untrusted-context signal the ingest gate uses, and reports them under a dedicated `handoff-inbox` surface. Note content is treated as untrusted and is not attributed to the repo author. `processed/` folders and `TEMPLATE.md` stay excluded.

## Inbox Flow

`brigadestack security scan --import-findings` writes the local evidence bundle and imports unsuppressed findings into the existing work inbox with source `security-scan`.

Imported records preserve safe metadata:

- finding id
- rule id
- severity and category
- path and line
- safe detail
- remediation hint
- local evidence path
- stable source key and fingerprint

Repeated scans dedupe equivalent pending findings. Dismissed imports stay dismissed until the finding materially changes.

## Scope

`security scan` reads local files and makes no network calls. It does not change GitHub issues. Fixing a finding is a separate step.

`security enrich` is the one command that can reach out. With the default `local` provider it stays offline. If you set the provider to `misp`, it sends each indicator value extracted from a finding (a URL, package name or action reference) to the MISP server you configure in `misp_url`, using the API key in the environment variable you name. Results are cached locally.