feat(home): add security-audit-sandbox wrapper
This commit is contained in:
1 parent
a2968cdcef
commit
76ff344ff5
3 files changed
+599
-1
No files matched your search
@@ -35,7 +35,52 @@ Agent scope: the Skills CLI installs the bundle once under `~/.agents/skills/sec
|
||||
|
||||
The activation is idempotent and non-interactive: it skips the install when both the canonical copy and the Claude Code link exist, and a failed download only warns so the rebuild still completes. Trigger it in an agent with "security audit this codebase".
|
||||
|
||||
Sandbox limitation: the skill's README requires an OS-enforced sandbox (no external network, sanitized environment, resource limits, scratch-only writes) before it may run target-controlled builds, tests, browser automation, emulators, fuzzers, or fixtures. This Nix setup installs the skill only and creates no sandbox. Without one, the workflow keeps such leads as `needs_validation` rather than executing target code.
|
||||
Sandbox: the skill's README requires an OS-enforced sandbox (no external network, sanitized environment, resource limits, scratch-only writes) before it may run target-controlled builds, tests, browser automation, emulators, fuzzers, or fixtures. `security-audit-sandbox` below provides that sandbox. Run target code only through it; otherwise the workflow keeps such leads as `needs_validation` rather than executing target code.
|
||||
|
||||
## Security audit sandbox
|
||||
|
||||
`security-audit-sandbox` (installed as `~/.local/bin/security-audit-sandbox`) runs untrusted target code in a Docker container. It is for target code only: do not run the audit agent or your own tools inside it.
|
||||
|
||||
```bash
|
||||
security-audit-sandbox start ~/code/myapp [--image node:22-bookworm] [--exclude dist]...
|
||||
security-audit-sandbox exec ~/code/myapp [--timeout 600] -- npm test
|
||||
security-audit-sandbox stop ~/code/myapp [--keep]
|
||||
security-audit-sandbox status ~/code/myapp
|
||||
```
|
||||
|
||||
`start` canonicalizes the app path, copies the app to `~/security-audit-runs/<slug>.XXXXXX`, and starts a detached container. The original app directory is never mounted into the container, so the copy is the only thing the target code can see.
|
||||
|
||||
Image resolution order:
|
||||
|
||||
1. `--image`
|
||||
2. `IMAGE=` in the app's `security-audit.conf`
|
||||
3. Inference: `package.json` gives `node:22-bookworm`, `pyproject.toml` or `requirements.txt` gives `python:3.12-slim`, `go.mod` gives `golang:1.24-bookworm`, `Cargo.toml` gives `rust:1-bookworm`, and `Gemfile` gives `ruby:3.3-bookworm`.
|
||||
|
||||
`start` stops with an error when nothing resolves an image. To support another runtime, add a marker file mapping or pass `--image`.
|
||||
|
||||
The optional `security-audit.conf` in the app root holds simple `KEY=value` lines. It is parsed, never sourced:
|
||||
|
||||
```ini
|
||||
IMAGE=node:22-bookworm
|
||||
EXCLUDE="node_modules dist coverage"
|
||||
```
|
||||
|
||||
`EXCLUDE=` is a whitespace-separated list. CLI `--exclude` patterns are added on top of it. The copy always excludes `.git`, `.env*`, and the top-level `/data` directory, so secrets and live data stay on the host.
|
||||
|
||||
Container controls:
|
||||
|
||||
- `--network none`: no external network, only loopback for local tests.
|
||||
- `--read-only` root with writes limited to the bind-mounted scratch directory at `/scratch`, plus a 512 MiB tmpfs at `/tmp`.
|
||||
- `HOME=/scratch/home`, `TMPDIR=/scratch/tmp`, and `XDG_CACHE_HOME=/scratch/cache`.
|
||||
- Runs as your host UID:GID, with `--cap-drop ALL`, `no-new-privileges`, and `--init`.
|
||||
- `--memory 4g`, `--cpus 2`, `--pids-limit 256`, and `nofile=1024:1024`.
|
||||
- `fsize=104857600` (100 MiB) when the Docker host accepts it. Docker Desktop on macOS may refuse `fsize`; the wrapper then starts without only that cap and prints a warning.
|
||||
|
||||
`exec` runs the command from `/scratch/app` under `timeout --signal=KILL`, default 600 seconds. It passes no host environment variables. If the image has no `timeout` binary, `exec` refuses to run rather than dropping the wall-clock limit.
|
||||
|
||||
`stop` removes the container, the state file, and the run directory. Pass `--keep` to keep the run directory for inspection. State lives under `${XDG_STATE_HOME:-~/.local/state}/security-audit-sandbox` and is keyed by the canonical app path, so `exec`, `stop`, and `status` find the same run.
|
||||
|
||||
Use dummy data only. The exclusions cover common secrets and the top-level `data` directory, not every possible secret path. Review the copied tree, or add `--exclude` patterns, before you run a target that reads credentials from unexpected places. Audit findings do not belong in this repo or in the run directory.
|
||||
|
||||
## OpenSuperWhisper (local voice input)
|
||||
|
||||
|
||||
Reference in new issue
Block a user