diff --git a/.claude/agents/extension-reviewer.md b/.claude/agents/extension-reviewer.md index 3f8cadc..4bce9a8 100644 --- a/.claude/agents/extension-reviewer.md +++ b/.claude/agents/extension-reviewer.md @@ -47,6 +47,14 @@ Optional interfaces: - Table-driven tests with named subtests - Tests for Check (current state detection) and Apply (convergence) - Tests for error cases and edge conditions +- Use `testutil.AssertConverges(t, ext)` for the Check/Apply/Check contract +- Use `testutil.MapFS` for file I/O tests without root (see `internal/testutil/`) + +### 6. Testability (FS Interface) +- Extensions that manage files must accept `extensions.FS` in their Opts struct +- `nil` defaults to the real OS filesystem via `extensions.RealFS()` +- Direct `os.ReadFile`/`os.WriteFile`/`os.Stat` calls that bypass `fsys()` are a finding +- Use `errors.Is(err, fs.ErrNotExist)` not `os.IsNotExist()` for mock FS compatibility ## Output diff --git a/.claude/agents/security-auditor.md b/.claude/agents/security-auditor.md index 9533611..ddf4972 100644 --- a/.claude/agents/security-auditor.md +++ b/.claude/agents/security-auditor.md @@ -28,7 +28,12 @@ Review: registry paths that could escalate privileges, security policy weakening Review: `Check` methods with side effects, `Apply` without rollback capability, missing error handling that leaves partial state. -### 5. File Permissions (`extensions/file/`) +### 5. Condition Shell Execution (`condition/shell.go`) +`condition.Shell()` runs user-supplied commands in the platform shell as the daemon user (root). The command string is passed to `internal/shell.Command()` which wraps it in PowerShell/bash/cmd. + +Review: commands constructed from untrusted blueprint input, unquoted arguments interpolated into the shell string, `Match()` bypass via output injection (e.g. attacker controlling stdout to match an expected value). + +### 6. File Permissions (`extensions/file/`) Creates/modifies files with specified ownership and permissions. Review: files created world-writable, ownership changes to root-owned paths, symlink following. diff --git a/CLAUDE.md b/CLAUDE.md index dbc9239..37dd918 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,7 +12,7 @@ Read `docs/design.md` for philosophy and security model, `docs/extensions.md` fo | Extensions | `extensions/` (one subdirectory per resource type, see directory for full list) | | Conditions | [`condition/`](condition/) (see directory for full list) | | Blueprints | `blueprints/` (baseline, per-OS, CIS benchmarks) | -| Internals | `internal/` (daemon, engine, exit, graph, logging, output, platform, version, watch, winreg) | +| Internals | `internal/` (daemon, engine, exit, graph, logging, output, platform, shell, testutil, version, watch, winreg) | | CLI | `cmd/converge/` | ## Build and test