# Security Instructions — MRPS Agent Toolkit

## Overview
Dependency vulnerabilities, hardcoded secrets, and infrastructure misconfiguration.

## Category & Tools
- **Tools**: `trivy` (`kind: cli`)
- **Category**: `security`
- **ID prefix**: `sec` (secrets may use `sec`) · **Report slug**: `security`
- **Produces findings**: yes

## When to Reach for What
Reach for `trivy` to audit the SBOM, detect known CVEs in locked dependencies, locate
hardcoded secrets, and flag misconfigured Dockerfiles or IaC.

## What Inspect means here
Static, read-only scans over manifests and configs. No live requests, no exploitation.

## The ladder, applied here
- **Inspect** — scan. Read-only.
- **Critique** — CVSS score, exploitability, whether the vulnerable path is actually reachable.
- **Recommend** — version bump or rotation step. Do not edit manifests.
- **Fix** — only on explicit instruction, with the user approving each bump.

## Commands
```bash
trivy fs \
  --scanners vuln,secret,misconfig \
  --severity HIGH,CRITICAL \
  --skip-dirs node_modules,dist,build,vendor,.venv \
  --format json \
  --output reports/security/trivy.json .
```
`misconfig` is **not** enabled by default — pass it explicitly or the report will silently
miss Dockerfile/IaC problems. `--skip-dirs` prevents noise from vendored and build output.

Variants: `trivy image <ref>` for containers, `trivy repo <url>` only with permission.

## Severity mapping
| CVSS | Sev |
|---|---|
| ≥ 9.0 | C |
| 7.0–8.9 | H |
| 4.0–6.9 | M |
| < 4.0 | L |

Secrets are always at least `H`, regardless of score.

## Secrets — redaction is mandatory
Record `file:line`, the rule ID, and a masked prefix only: `AKIA…****`.
Never print the full value in chat, the report, or a commit message. Recommend rotation.
Do not attempt to validate or use a found credential.

## Boundaries
- This is **not** a penetration test. No fuzzing, no exploitation, no live probing.
- Never scan production, staging, or a host the user does not own.
- `--ignore-unfixed` is allowed only if you say so in the report — it hides real findings.

## Evidence rules
Cite the CVE or rule ID, the package + installed version, and the file that pins it.
Example: `CVE-2024-21538 · cross-spawn@7.0.3 · package-lock.json`.

## Report example
```markdown
# security — 2026-11-09T14-32-05Z

Prior: none (first run)
Toolchain: Trivy 0.56.2
Delta: +1 new · 0 still open · 0 resolved · 0 not checked

## What was found (plain English)
- **sec-01** — A dependency has a publicly known remote-code-execution flaw. (High)

## What changed since last run
- First run.

## Technical detail
| ID | Sev | Evidence | File | Rule | Status |
|----|-----|----------|------|------|--------|
| sec-01 | H | CVE-2024-21538 · cross-spawn@7.0.3 | package-lock.json | vuln | NEW |

## Commands run
| Command | Exit | Note |
|---------|------|------|
| trivy fs --scanners vuln,secret,misconfig . | 0 | 1 HIGH |

## Not checked
- Container image — no image built locally.

Generated by <agent name>. Read-only. No source files were modified.
Findings are advisory; the user decides what to fix.
```
