From 7b660b3da04d114fc85f0b2c45d99bb2a6af571d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabor=20K=C3=B6rber?= Date: Tue, 26 May 2026 14:12:44 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20fermata:=20purge=20botignore.tom?= =?UTF-8?q?l=20from=20all=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update crate README, CLAUDE.md, configuration.md, commands.md, threat-model.md, security-philosophy.md, and tools/fermata.md to reflect the unified .botsecrets [policy] config. No more three-file story — it's .botignore + .botsecrets everywhere. Co-Authored-By: Claude Opus 4.6 (1M context) --- CLAUDE.md | 2 +- README.md | 20 +++++------ docs/commands.md | 11 +++--- docs/configuration.md | 81 ++++++++++++++++++++----------------------- docs/threat-model.md | 2 +- 5 files changed, 55 insertions(+), 61 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 5b4c900..81a4881 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,7 +12,7 @@ Harness-agnostic policy gate and secret filtering engine for AI coding agents. Three concentric layers; nothing inner imports from anything outer. -- **`core/`** — harness-unaware, transport-unaware, sync. Types (`Op`, `Decision`), `.botignore` walker, `botignore.toml` parser, `Policy::check` / `check_command`, path extraction. Sync, no tokio. +- **`core/`** — harness-unaware, transport-unaware, sync. Types (`Op`, `Decision`), `.botignore` walker, `.botsecrets` `[policy]` parser, `Policy::check` / `check_command`, path extraction. Sync, no tokio. - **`core/secrets/`** — the secret filtering engine: - `config.rs` — `.botsecrets` TOML parser and hierarchical resolution (user, project, local override). - `manifest.rs` — discovers secret-containing files from `.botsecrets` patterns and loads their content for redaction. diff --git a/README.md b/README.md index 515ccff..290759d 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ fermata interposes on every tool call in the agent's lifecycle: ``` Agent wants to run a tool | - PreToolUse ── fermata checks .botignore / botignore.toml + PreToolUse ── fermata checks .botignore / .botsecrets [policy] | blocked? → deny with reason | allowed? ↓ Tool executes @@ -87,7 +87,7 @@ Three layers of defense, each independent: | Layer | Mechanism | What it catches | |-------|-----------|-----------------| -| **Access control** | `.botignore` rules block tool calls by path | Direct reads/writes to sensitive files | +| **Access control** | `.botignore` + `.botsecrets [policy]` rules block tool calls by path | Direct reads/writes to sensitive files | | **Known-value redaction** | `.botsecrets` declares secret files; fermata parses them and builds an Aho-Corasick automaton | Every occurrence of a declared secret value, in any tool output, regardless of source | | **Heuristic detection** | Regex patterns from gitleaks detect undeclared secrets (AWS keys, JWTs, GitHub PATs, database URLs) | Secrets not covered by the manifest -- runtime-generated, unexpected locations | @@ -95,7 +95,7 @@ Performance: ~1-5ms per tool call. Cold start (loading config + parsing secret f ## Configuration -Three files, each optional, each solving a different problem: +Two files, each optional, each solving a different problem: ### `.botignore` -- the 80% case @@ -107,22 +107,22 @@ Gitignore syntax. Blocks both reads and writes. Onboarding is one line. secrets/** ``` -### `botignore.toml` -- per-operation rules +### `.botsecrets` -- per-operation policy rules + secret value redaction -Separate namespaces so the same file can be readable but not writable: +`.botsecrets` serves double duty: it declares which files contain secrets (for redaction) **and** provides per-operation policy rules under `[policy.*]` sections. Separate namespaces let the same file be readable but not writable: ```toml -[read] +[policy.read] patterns = [".env*", "secrets/**"] -[write] +[policy.write] patterns = ["vendor/**", "*.lock"] -[bash] +[policy.bash] deny = ["rm -rf /", "curl * | sh"] ``` -### `.botsecrets` -- secret value redaction +#### Secret value redaction Declares which files contain secrets. fermata parses them, extracts values, and redacts every occurrence in tool output. @@ -205,7 +205,7 @@ The policy engine and redaction logic are identical across all modes. Only the I v0.2 -- policy gate and secret filtering engine are production-ready. All core components are implemented and tested: - `.botignore` walker with gitignore semantics -- `botignore.toml` with read/write/bash namespaces +- `.botsecrets [policy]` with read/write/bash namespaces - Claude Code PreToolUse and PostToolUse adapters - `.botsecrets` config, manifest discovery, multi-format parser (.env, TOML, YAML, JSON) - Aho-Corasick known-value redactor diff --git a/docs/commands.md b/docs/commands.md index ce07337..9a16c15 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -6,7 +6,7 @@ Fermata is a policy gate and secret filtering engine for AI coding agents. It sh ## fermata check -Check whether one or more paths are allowed for a given operation. Fermata locates the nearest project root (a directory containing `.botignore`, `botignore.toml`, or `.git`) and evaluates the policy defined there. +Check whether one or more paths are allowed for a given operation. Fermata locates the nearest project root (a directory containing `.botignore`, `.botsecrets`, or `.git`) and evaluates the policy defined there. **Usage** @@ -79,7 +79,7 @@ Fermata follows a **fail-open** policy for hooks: if the payload cannot be parse **Event types** -- **pre-tool-use** -- Runs before the tool executes. Fermata checks the requested path or command against `.botignore` / `botignore.toml` and returns an allow, deny, or ask decision to the harness. +- **pre-tool-use** -- Runs before the tool executes. Fermata checks the requested path or command against `.botignore` / `.botsecrets [policy]` and returns an allow, deny, or ask decision to the harness. - **post-tool-use** -- Runs after the tool executes. Fermata loads `.botsecrets`, builds a manifest of known secret values, and redacts any matches from the tool output before it enters the LLM context. A heuristic scanner (regex patterns derived from gitleaks) catches undeclared secrets as a safety net. **Examples** @@ -103,8 +103,7 @@ Fermata does not have its own global config file. All configuration lives in you | File | Purpose | |------|---------| | `.botignore` | Gitignore-syntax patterns. Blocks both reads and writes to matched paths. | -| `botignore.toml` | Per-operation rules with `[read]`, `[write]`, and `[bash]` sections. | -| `.botsecrets` | TOML file declaring which files contain secrets, custom key patterns, and heuristic scanning options. | +| `.botsecrets` | TOML file with `[policy.read]`, `[policy.write]`, and `[policy.bash]` sections for per-operation rules, plus secret redaction configuration. | Fermata discovers these files by walking up from the target path (or the current working directory for `hook`) until it finds a project root. @@ -164,10 +163,10 @@ Add both hook events to `.claude/settings.json`: ### Block dangerous shell commands -Use `botignore.toml` to deny specific command patterns: +Use `.botsecrets [policy.bash]` to deny specific command patterns: ```toml -[bash] +[policy.bash] deny = ["rm -rf /", "curl * | sh", "wget * | bash"] ``` diff --git a/docs/configuration.md b/docs/configuration.md index b15d5c3..52b647c 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1,16 +1,15 @@ # Configuration Reference -Fermata uses three configuration files to control what an AI coding agent can +Fermata uses two configuration files to control what an AI coding agent can access and what secret values it can see. Configuration is layered, with later (more specific) sources overriding earlier ones. | File | Purpose | Syntax | |------|---------|--------| | `.botignore` | Block agent access to matching paths (reads and writes) | gitignore | -| `botignore.toml` | Fine-grained per-operation rules (read, write, bash) | TOML | -| `.botsecrets` | Declare secret-containing files and control redaction | TOML | +| `.botsecrets` | Per-operation policy rules (`[policy.read]`, `[policy.write]`, `[policy.bash]`) and secret redaction configuration | TOML | -All three files are optional. Without any configuration Fermata allows all +Both files are optional. Without any configuration Fermata allows all operations and performs no redaction. Add only the files you need. --- @@ -20,7 +19,7 @@ operations and performs no redaction. Add only the files you need. A `.botignore` file uses **gitignore syntax** to block agent access to matching paths. When a path matches, both reads and writes are denied. There is no distinction between operations -- if you need per-operation control, use -`botignore.toml` instead. +`.botsecrets [policy.*]` sections instead. ### Placement and Scoping @@ -74,18 +73,19 @@ id_ed25519 --- -## `botignore.toml` -- Per-Operation Rules +## `.botsecrets` -- Policy Rules and Secret Redaction -`botignore.toml` provides fine-grained control by separating rules into three -namespaces: `[read]`, `[write]`, and `[bash]`. Place this file at the project -root alongside `.botignore`. +`.botsecrets` is the central TOML configuration file. It combines two concerns: -When both `.botignore` and `botignore.toml` are present, they are evaluated -together. `.botignore` is checked first (blocking both reads and writes), then -`botignore.toml` namespace-specific rules are applied. A path blocked by either +- **Per-operation policy rules** (`[policy.read]`, `[policy.write]`, `[policy.bash]`) -- fine-grained control over which paths and commands the agent can use. +- **Secret redaction** (`[files]`, `[keys]`, `[redaction]`, `[heuristic]`, `[enforcement]`, `[[file]]`) -- declares which files contain secrets and how Fermata should redact them from tool output. + +When both `.botignore` and `.botsecrets [policy.*]` sections are present, they +are evaluated together. `.botignore` is checked first (blocking both reads and +writes), then `.botsecrets` policy rules are applied. A path blocked by either source is denied. -### `[read]` -- Read Access Rules +### `[policy.read]` -- Read Access Rules Blocks the agent from reading matching paths. Patterns use glob syntax. @@ -94,11 +94,11 @@ Blocks the agent from reading matching paths. Patterns use glob syntax. | `patterns` | `string[]` | Glob patterns for paths the agent cannot read. | ```toml -[read] +[policy.read] patterns = [".env*", "secrets/**", "*.pem"] ``` -### `[write]` -- Write Access Rules +### `[policy.write]` -- Write Access Rules Blocks the agent from writing to matching paths. Patterns use glob syntax. @@ -107,11 +107,11 @@ Blocks the agent from writing to matching paths. Patterns use glob syntax. | `patterns` | `string[]` | Glob patterns for paths the agent cannot write to. | ```toml -[write] +[policy.write] patterns = ["vendor/**", "*.lock", "migrations/**"] ``` -### `[bash]` -- Command Execution Rules +### `[policy.bash]` -- Command Execution Rules Controls which shell commands the agent can run. Commands are evaluated in priority order: deny, then allow_prefixes, then ask. If none match, the @@ -131,35 +131,33 @@ Evaluation order: 4. Otherwise the command is **allowed**. ```toml -[bash] +[policy.bash] deny = ["rm -rf /", "curl * | sh", ":(){ :|:& };:"] allow_prefixes = ["cargo", "npm", "git status"] ask = ["docker", "kubectl"] ``` -### Full `botignore.toml` Example +### Full Policy Example ```toml -[read] +[policy.read] patterns = [".env*", "secrets/**"] -[write] +[policy.write] patterns = ["vendor/**", "*.lock", "dist/**"] -[bash] +[policy.bash] deny = ["rm -rf /", "curl * | sh"] allow_prefixes = ["cargo", "npm", "just"] ask = ["docker", "kubectl", "terraform"] ``` ---- +### Secret Redaction -## `.botsecrets` -- Secret Redaction - -`.botsecrets` declares which files contain secrets and how Fermata should -redact them from tool output. This prevents secret values from leaking into -the LLM context window even when the agent reads files indirectly (via shell -output, log files, error messages, etc.). +The secret redaction sections of `.botsecrets` declare which files contain +secrets and how Fermata should redact them from tool output. This prevents +secret values from leaking into the LLM context window even when the agent +reads files indirectly (via shell output, log files, error messages, etc.). ### Layered Configuration @@ -385,25 +383,25 @@ style = "masked" ### Fine-Grained: Separate Read, Write, and Bash Rules -Use `botignore.toml` when you need different rules for different operations: +Use `.botsecrets [policy.*]` sections when you need different rules for different operations: ```toml -# botignore.toml -[read] +# .botsecrets +[policy.read] patterns = [".env*", "secrets/**"] -[write] +[policy.write] patterns = ["vendor/**", "*.lock", "Cargo.toml"] -[bash] +[policy.bash] deny = ["rm -rf *"] allow_prefixes = ["cargo", "npm", "git"] ask = ["docker", "kubectl"] ``` -### Full-Featured: All Three Files +### Full-Featured: Both Files -A production setup using all configuration files together: +A production setup using both configuration files together: ```gitignore # .botignore @@ -416,21 +414,18 @@ id_ed25519 ``` ```toml -# botignore.toml -[read] +# .botsecrets +[policy.read] patterns = ["secrets/**", ".aws/**"] -[write] +[policy.write] patterns = ["vendor/**", "*.lock", "dist/**", "migrations/**"] -[bash] +[policy.bash] deny = ["rm -rf /", "curl * | sh"] allow_prefixes = ["cargo", "npm", "just", "git"] ask = ["docker", "terraform"] -``` -```toml -# .botsecrets [files] patterns = [".env", ".env.*", "config/credentials.yaml"] diff --git a/docs/threat-model.md b/docs/threat-model.md index 3e87de3..d3d9fbd 100644 --- a/docs/threat-model.md +++ b/docs/threat-model.md @@ -28,7 +28,7 @@ The agent calls a path-typed tool (Read, Write, Edit) with an explicit file path > `Read({"file_path": "/home/user/.env"})` -- `.botignore` matches -- deny. -Both `.botignore` (gitignore semantics, deepest directory wins, negation patterns work as in git) and `botignore.toml` `[read]`/`[write]` glob lists are evaluated against the resolved path. This covers the overwhelming majority of accidental secret-file reads, because most agents use direct path tools as their primary file access method. +Both `.botignore` (gitignore semantics, deepest directory wins, negation patterns work as in git) and `.botsecrets` `[policy.read]`/`[policy.write]` glob lists are evaluated against the resolved path. This covers the overwhelming majority of accidental secret-file reads, because most agents use direct path tools as their primary file access method. ### L1: Absolute paths inside Bash commands