Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d0662b09e | ||
|
|
f7411c2ade | ||
|
|
b4120aaf88 | ||
|
|
baae0d960c | ||
|
|
61c4f20fe9 | ||
|
|
1cd03f93c6 | ||
|
|
8a35b39aa3 | ||
|
|
78424d2778 | ||
|
|
59bdaa6e2a | ||
|
|
c45d61387f | ||
|
|
76ff344ff5 | ||
|
|
a2968cdcef | ||
|
|
84c26cca45 | ||
|
|
75088e1f15 | ||
|
|
d01d13ff1c | ||
|
|
788a97a61d | ||
|
|
aaeadb50d5 | ||
|
|
b1869a1afd | ||
|
|
1a3c38406a | ||
|
|
b37ee69be1 | ||
|
|
86844a3646 | ||
|
|
16677278ba | ||
|
|
4a4ce6c585 | ||
|
|
7603df3666 |
No files matched your search
@@ -8,9 +8,10 @@ Deliberate decisions in this repo - do NOT silently revert them:
|
||||
- Pi is managed the same way: `home/.pi/agent/{settings,models}.json`, `themes/`, and custom extensions (`terminal-status-title`, `calm`). Do not symlink the whole `~/.pi/agent` tree - sessions, auth, npm cache, and herdr's `extensions/herdr-agent-state.ts` stay live.
|
||||
- herdr stores runtime state beside its config, so `~/.config/herdr` stays a real directory and only `config.toml` is symlinked; `home.activation.herdrConfigDir` migrates the old whole-directory symlink and clears leaked artifacts. Do not symlink the whole directory - rationale and artifact list are in `home.nix`.
|
||||
- Codex runs on the OpenCode Go subscription. The ChatGPT app owns and rewrites the live `~/.codex/config.toml`, so it is NOT symlinked; `home.activation.codexOpenCodeGo` merges the repo fragment `home/.codex/config.toml` into it on every rebuild, and the app's own sections (`[desktop]`, `[plugins]`, `[mcp_servers]`, ...) survive. Auth is command-backed via `~/.local/bin/opencode-go-token` (prints the key from the opencode store), so `~/.codex/auth.json` stays in ChatGPT mode and ChatGPT sign-in coexists with Go. Only Go models that speak the Responses API work (`deepseek-v4.1-flash`, `gpt-6-luna`, `gpt-5.6-luna`, `grok-4.7/4.6`); GLM/Kimi/MiMo/LongCat are chat-completions-only and need a proxy. Desktop Codex is now the `chatgpt` cask - do not use the deprecated `codex-app` cask.
|
||||
- firstmate lives at `~/Documents/firstmate` as a mutable git clone (not in the Nix store). `home.activation.firstmate` clones it if missing and seeds `config/backend=herdr` + `config/crew-harness=opencode` only when those files are absent. Crew routing is `home/.config/firstmate/crew-dispatch.json` (symlinked in): per the captain's order 2026-10-20, every coding crewmate and scout uses `opencode` + `opencode/deepseek-v4.1-flash-free` through the OpenCode CLI, because the paid Go subscription was close to emptying its monthly window. The validation pipeline stays on Pi with `opencode-go/deepseek-v4.1-flash` steps and the `opencode-go/glm-5.3-flash` reviewer. The free tier rate-limits under heavy parallel work, so a stalled worker falls back to the paid Go model only on the captain's word. Avoid the `muse-spark-*-contributor` models, which train on prompts, and the `exo-free`, `mimo-*-free`, and `nemotron-*-free` models, whose data may be used to improve the model. `cat-jam-free` retains for 30 days. Crews inherit the primary's OpenCode login through the spawn-owned symlink (the isolated worker data root links the primary `<XDG_DATA_HOME>/opencode/auth.json`; no `~/.pi/agent/auth.json` reliance). Launch with shell alias `fm` (`cd` + OpenCode 2 via `~/.local/bin/oc2`); the primary stays OpenCode 2, only crews run on the opencode harness. Self-update via `/updatefirstmate`, not rebuild.
|
||||
- firstmate lives at `~/Documents/firstmate` as a mutable git clone (not in the Nix store). `home.activation.firstmate` clones it if missing and seeds `config/backend=herdr` + `config/crew-harness=opencode` only when those files are absent. Crew routing is `home/.config/firstmate/crew-dispatch.json` (symlinked in): per the captain's order 2026-10-21, every coding crewmate and scout uses `opencode` + `opencode-go/deepseek-v4.1-flash` through the OpenCode CLI. The free `deepseek-v4.1-flash-free` order of 2026-10-20 resumes when that lane resets. The validation pipeline stays on Pi with `opencode-go/deepseek-v4.1-flash` steps and the `opencode-go/glm-5.3-flash` reviewer. Avoid the `muse-spark-*-contributor` models, which train on prompts, and the `exo-free`, `mimo-*-free`, and `nemotron-*-free` models, whose data may be used to improve the model. `cat-jam-free` retains for 30 days. Crews inherit the primary's OpenCode login through the spawn-owned symlink (the isolated worker data root links the primary `<XDG_DATA_HOME>/opencode/auth.json`; no `~/.pi/agent/auth.json` reliance). Launch with shell alias `fm` (`cd` + OpenCode 2 via `~/.local/bin/oc2`); the primary stays OpenCode 2, only crews run on the opencode harness. Self-update via `/updatefirstmate`, not rebuild.
|
||||
- OpenCode 2 is the firstmate primary. It is not a Homebrew formula: install `@opencode-ai/cli@beta` with Homebrew's npm (`home.activation.opencode2`). Launch through `home/bin/oc2` so `OPENCODE_CONFIG` stays at `home/.config/opencode2/opencode.json` and cannot rewrite OpenCode 1.x's `~/.config/opencode`. Do not add a brew `opencode` / `opencode2` formula; `zap` would fight the npm install. firstmate harness detection matches `*opencode*`, so the `opencode2` process name still classifies as OpenCode.
|
||||
- Shell aliases: `cc` (Claude skip-permissions), `co` (Codex full-auto), `gb` (Grok --yolo), `fm` (firstmate via OpenCode 2), `oc2` (OpenCode 2, isolated). They are intentional high-agency shortcuts.
|
||||
- OpenSuperWhisper is installed by the `opensuperwhisper` cask, and `home.activation.openSuperWhisper` downloads its Whisper model (`ggml-large-v3-turbo.bin` under the app's Application Support directory, never the Nix store) and seeds the model selection only when it is missing or dangling. All other app settings (trigger, language, paste behavior) belong to the app and must not be rewritten by a rebuild, so `modifierOnlyHotkey = rightOption` on this machine stays the effective trigger. Microphone/Accessibility/Input Monitoring grants stay manual because macOS TCC cannot be declarative; do not kill a running app to apply defaults. The model is local-only.
|
||||
|
||||
## Maintaining this file
|
||||
|
||||
|
||||
@@ -64,8 +64,10 @@
|
||||
# app (2026-07); the deprecated `codex-app` cask must not be used.
|
||||
"chatgpt"
|
||||
"codex" # Codex CLI; shares ~/.codex/config.toml with the desktop app
|
||||
"coteditor" # plain-text editor; cask id is one lowercase word
|
||||
"docker-desktop"
|
||||
"grok-build"
|
||||
"opensuperwhisper" # local Whisper dictation; model seed in home.nix
|
||||
"puremac"
|
||||
"utm"
|
||||
"wezterm"
|
||||
|
||||
Generated
+16
-16
@@ -3,16 +3,16 @@
|
||||
"brew-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1788591592,
|
||||
"narHash": "sha256-NbwVKwKLFl0oXub7oPjvmDaOygCtV2oboeKTu4xXFTk=",
|
||||
"lastModified": 1793000687,
|
||||
"narHash": "sha256-8mCor0DDjNhi+0e+FllfqiMABujBl+/RxYW+wgMpcto=",
|
||||
"owner": "Homebrew",
|
||||
"repo": "brew",
|
||||
"rev": "08e85c4e42f5d8f1ea17c36cb59cf61c2ccb26c3",
|
||||
"rev": "c6069d2a943b71b0a90d91fc1ac93cb9c1634dcc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "Homebrew",
|
||||
"ref": "6.0.22",
|
||||
"ref": "7.0.11",
|
||||
"repo": "brew",
|
||||
"type": "github"
|
||||
}
|
||||
@@ -24,11 +24,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1789267039,
|
||||
"narHash": "sha256-LWiBv9yAYFi2LPbUhDGHPGKYskJQjj2fw12OlyO1uQo=",
|
||||
"lastModified": 1792818383,
|
||||
"narHash": "sha256-199i7ubVSXTMl+0AAlL7cVCXSjcI+jWByMcimYjeMX0=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "ec172013fa62135f58fb58dd17ae9651e8f39727",
|
||||
"rev": "24f2190587513b9c2f73db112a17844ae912d965",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -45,11 +45,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1783744694,
|
||||
"narHash": "sha256-2cp6N3rrwnGYLTx9l6N+NI+kwrCWxvJUbj5WJhvB29A=",
|
||||
"lastModified": 1792800221,
|
||||
"narHash": "sha256-53jIZEWNh96irEXhsMZFoNhLJgGSU3nYl1i4wFQHAsU=",
|
||||
"owner": "nix-darwin",
|
||||
"repo": "nix-darwin",
|
||||
"rev": "c3e90c89649b07d1a96e4b9dd6cd0d6e44b91a74",
|
||||
"rev": "d31953cf55f9027a56e9be938daf5db8c5655663",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -64,11 +64,11 @@
|
||||
"brew-src": "brew-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1788981439,
|
||||
"narHash": "sha256-fEaFq0XgpgWFPLfpq1UK4/8ylHd2T0+fo6O3hKz1LUM=",
|
||||
"lastModified": 1793543863,
|
||||
"narHash": "sha256-oDYLVD8KGT/M57c8HziYSSj0le4wCyA+jZ7+/qUS91M=",
|
||||
"owner": "zhaofengli",
|
||||
"repo": "nix-homebrew",
|
||||
"rev": "09a921d0181146cf6163ec2cc1db7b6fd539a885",
|
||||
"rev": "52bc87da3f30c2261a6d1cfef3c892097b53daeb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -79,11 +79,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1789485310,
|
||||
"narHash": "sha256-VsDMTLSkAAJmbNha6sGNzlF33X7RESWLl3SnjDQu+4U=",
|
||||
"lastModified": 1793976852,
|
||||
"narHash": "sha256-bWDN3JZcE9ovYoaD0/6WYbMtXYpUu0vd5onpK0pc/SE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0c32f40fe3e2a9adfc427fd5abc061a31043ea44",
|
||||
"rev": "57f1c8965649ce5bcac5118a0d2e41f1fbdc56e5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -188,6 +188,10 @@ in
|
||||
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/bin/oc2";
|
||||
force = true;
|
||||
};
|
||||
home.file.".local/bin/security-audit-sandbox" = {
|
||||
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/bin/security-audit-sandbox";
|
||||
force = true;
|
||||
};
|
||||
home.file.".grok/AGENTS.md" = {
|
||||
source = config.lib.file.mkOutOfStoreSymlink "${dotfiles}/home/AGENTS.md";
|
||||
force = true;
|
||||
@@ -317,19 +321,20 @@ in
|
||||
|
||||
# OpenCode 2 is not on Homebrew (beta). Install via Homebrew's npm, never
|
||||
# Nix's npm (EACCES on the store). Skip when already present so a rebuild
|
||||
# does not pull a new beta under a live TUI.
|
||||
# does not pull a new beta under a live TUI. Activation blocks are inlined
|
||||
# into one flat script, so never `exit 0` here: that would skip every later
|
||||
# block (securityAuditSkill, setupLaunchAgents, syncMusic).
|
||||
home.activation.opencode2 = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
set -euo pipefail
|
||||
npm=/opt/homebrew/bin/npm
|
||||
bin=/opt/homebrew/bin/opencode2
|
||||
if [ -x "$bin" ]; then
|
||||
exit 0
|
||||
if [ ! -x "$bin" ]; then
|
||||
if [ ! -x "$npm" ]; then
|
||||
echo "opencode2: /opt/homebrew/bin/npm missing (declare node in homebrew.brews)" >&2
|
||||
exit 1
|
||||
fi
|
||||
"$npm" install -g --allow-scripts=@opencode-ai/cli @opencode-ai/cli@beta
|
||||
fi
|
||||
if [ ! -x "$npm" ]; then
|
||||
echo "opencode2: /opt/homebrew/bin/npm missing (declare node in homebrew.brews)" >&2
|
||||
exit 1
|
||||
fi
|
||||
"$npm" install -g --allow-scripts=@opencode-ai/cli @opencode-ai/cli@beta
|
||||
'';
|
||||
|
||||
# backpass (kunchenguid/backpass) - gradient descent for agent memory: reads
|
||||
@@ -401,4 +406,89 @@ in
|
||||
# Ensure daemon running (launchd on macOS)
|
||||
"$bin" daemon restart >/dev/null 2>&1 || "$bin" daemon start >/dev/null 2>&1 || true
|
||||
'';
|
||||
|
||||
# cloudflare/security-audit - vulnerability-hunting skill for the coding agents.
|
||||
# Installed by the upstream Skills CLI through Homebrew's npx, because the skill
|
||||
# is a multi-file bundle and an upstream refresh must stay byte-identical.
|
||||
# Scope: the CLI's "universal" target is ~/.agents/skills, which Codex, Pi, and
|
||||
# OpenCode read as a user-level skill directory; Claude Code reads
|
||||
# ~/.claude/skills, so the CLI also links the skill there. Grok Build is out of
|
||||
# scope for this install: its skill directory is ~/.grok/skills, and the CLI
|
||||
# only populates it when `grok` is named in --agent. Never target
|
||||
# ~/.config/opencode/skills: home-manager owns that path with force = true and
|
||||
# mkOutOfStoreSymlink into the mutable dotfiles checkout, so a rebuild would
|
||||
# clobber the CLI's link and CLI writes would land in the git checkout. Skip
|
||||
# when installed, like opencode2/backpass, so a rebuild never pulls a new skill
|
||||
# version mid-session. The skill's own README still requires an OS-enforced
|
||||
# sandbox before it may run target-controlled builds, tests, browsers, or
|
||||
# fuzzers. That sandbox is home/bin/security-audit-sandbox; without it, those
|
||||
# leads stay `needs_validation`.
|
||||
# Install and refresh commands, plus the sandbox docs, are in readme.md.
|
||||
home.activation.securityAuditSkill = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
set -euo pipefail
|
||||
# Activation PATH lacks /opt/homebrew/bin, so npx's `#!/usr/bin/env node`
|
||||
# shebang fails. It also lacks /usr/bin, so the Skills CLI cannot spawn
|
||||
# /usr/bin/git and the clone fails with "spawn git ENOENT". Prepend both -
|
||||
# replacing PATH breaks the rest of the HM activation (nix-env, gettext).
|
||||
export PATH="/opt/homebrew/bin:/usr/bin:$PATH"
|
||||
npx=/opt/homebrew/bin/npx
|
||||
# Canonical copy plus the Claude Code link: rerun when either is missing so a
|
||||
# half-removed install heals, then skip while both exist. No `exit 0` here:
|
||||
# activation blocks are inlined into one flat script, and later blocks must
|
||||
# still run.
|
||||
if [ ! -f "$HOME/.agents/skills/security-audit/SKILL.md" ] \
|
||||
|| [ ! -e "$HOME/.claude/skills/security-audit" ]; then
|
||||
if [ ! -x "$npx" ]; then
|
||||
echo "securityAuditSkill: /opt/homebrew/bin/npx missing (declare node in homebrew.brews)" >&2
|
||||
exit 1
|
||||
fi
|
||||
# A rebuild must not fail when GitHub or npm is unreachable: the skill is an
|
||||
# enhancement, so warn and keep the rest of the switch going.
|
||||
if ! "$npx" --yes skills add https://github.com/cloudflare/security-audit-skill \
|
||||
--skill security-audit --global \
|
||||
--agent claude-code codex pi opencode --yes; then
|
||||
echo "securityAuditSkill: WARNING: skill install failed (network or Skills CLI unavailable); rebuild continues." >&2
|
||||
echo "securityAuditSkill: rerun ./rebuild.sh or install manually with the command in readme.md." >&2
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
|
||||
# OpenSuperWhisper - local voice-first prompting (cask in configuration.nix).
|
||||
# The app reads its model from its own Application Support directory, so the
|
||||
# 1.6 GB Whisper model is downloaded here once and kept outside the Nix store.
|
||||
# A failed download must not fail the switch: warn, drop the partial file, and
|
||||
# let the app's Settings download it later. Only a missing or unusable model
|
||||
# selection is seeded; every other setting belongs to the app and survives the
|
||||
# rebuild. Never write hasCompletedOnboarding - onboarding must still run so the
|
||||
# captain can grant Microphone/Accessibility (macOS TCC grants are manual by
|
||||
# design). A running app picks up new defaults on its next launch; do not kill
|
||||
# it here.
|
||||
home.activation.openSuperWhisper = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
set -euo pipefail
|
||||
supportDir="$HOME/Library/Application Support/ru.starmel.OpenSuperWhisper"
|
||||
modelDir="$supportDir/whisper-models"
|
||||
modelPath="$modelDir/ggml-large-v3-turbo.bin"
|
||||
modelUrl="https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v3-turbo.bin?download=true"
|
||||
modelSha="1fc70f774d38eb169993ac391eea357ef47c88757ef72ee5943879b7e8e2bc69"
|
||||
curl="${pkgs.curl}/bin/curl"
|
||||
|
||||
mkdir -p "$modelDir"
|
||||
if [ ! -f "$modelPath" ]; then
|
||||
tmp="$(${pkgs.coreutils}/bin/mktemp "$modelDir/.ggml-large-v3-turbo.XXXXXX")"
|
||||
if "$curl" -fL --retry 3 --connect-timeout 30 -o "$tmp" "$modelUrl" \
|
||||
&& printf '%s %s\n' "$modelSha" "$tmp" | ${pkgs.coreutils}/bin/sha256sum -c - >/dev/null 2>&1; then
|
||||
mv "$tmp" "$modelPath"
|
||||
else
|
||||
echo "openSuperWhisper: WARNING: could not download or verify the Whisper model." >&2
|
||||
echo "openSuperWhisper: the app still works; download \"Whisper V3 Large\" in Settings later." >&2
|
||||
${pkgs.coreutils}/bin/rm -f "$tmp"
|
||||
fi
|
||||
fi
|
||||
|
||||
defaults=/usr/bin/defaults
|
||||
selectedModel="$("$defaults" read ru.starmel.OpenSuperWhisper selectedWhisperModelPath 2>/dev/null || true)"
|
||||
if [ -f "$modelPath" ] && { [ -z "$selectedModel" ] || [ ! -f "$selectedModel" ]; }; then
|
||||
"$defaults" write ru.starmel.OpenSuperWhisper selectedWhisperModelPath -string "$modelPath"
|
||||
fi
|
||||
'';
|
||||
}
|
||||
@@ -5,18 +5,18 @@
|
||||
"use": [
|
||||
{
|
||||
"harness": "opencode",
|
||||
"model": "opencode/deepseek-v4.1-flash-free",
|
||||
"provider": "opencode"
|
||||
"model": "opencode-go/deepseek-v4.1-flash",
|
||||
"provider": "opencode-go"
|
||||
}
|
||||
],
|
||||
"why": "Captain's order 2026-10-20: every coding crewmate and scout runs DeepSeek V4.1 Flash Free through the OpenCode CLI, which answers this model (verified with a one-shot probe the same day). The paid Go subscription was at 6 percent of its monthly window and projected to empty the next evening. The validation pipeline stays on Pi with paid deepseek-v4.1-flash and the glm-5.3-flash reviewer. Known risk: the free tier rate-limits under heavy parallel work, so a stalled worker falls back to the paid Go model on the captain's word."
|
||||
"why": "Captain's order 2026-10-21: paid Go for every crewmate and scout after the free lane hit 'Free usage exceeded' with a 10.5 hour retry, which ended five sessions in forty minutes. The free deepseek-v4.1-flash-free order of 2026-10-20 resumes when that lane resets; paid Go had 5 percent of its monthly window left, projected empty 2026-10-22T05:43Z."
|
||||
}
|
||||
],
|
||||
"default": [
|
||||
{
|
||||
"harness": "opencode",
|
||||
"model": "opencode/deepseek-v4.1-flash-free",
|
||||
"provider": "opencode"
|
||||
"model": "opencode-go/deepseek-v4.1-flash",
|
||||
"provider": "opencode-go"
|
||||
}
|
||||
]
|
||||
}
|
||||
Executable
+576
@@ -0,0 +1,576 @@
|
||||
#!/usr/bin/env bash
|
||||
# security-audit-sandbox - OS-enforced Docker sandbox for the security-audit skill.
|
||||
#
|
||||
# Copies target code into a scratch directory and runs it in a locked-down
|
||||
# container: no network, read-only root, scratch-only writes, dropped
|
||||
# capabilities, no-new-privileges, and CPU/memory/PID limits.
|
||||
#
|
||||
# Usage:
|
||||
# security-audit-sandbox start <app> [--image <image>] [--exclude <pattern>]...
|
||||
# security-audit-sandbox exec <app> [--timeout <seconds>] -- <command>...
|
||||
# security-audit-sandbox stop <app> [--keep]
|
||||
# security-audit-sandbox status <app>
|
||||
# security-audit-sandbox --help
|
||||
#
|
||||
# Optional <app>/security-audit.conf (simple KEY=value lines, never sourced):
|
||||
# IMAGE=node:22-bookworm
|
||||
# EXCLUDE="node_modules dist coverage"
|
||||
#
|
||||
# Default exclusions: .git, .env*, and the top-level /data directory.
|
||||
# The original app directory is never mounted into the container.
|
||||
set -euo pipefail
|
||||
|
||||
PROG=security-audit-sandbox
|
||||
RUN_PARENT="$HOME/security-audit-runs"
|
||||
STATE_ROOT="${XDG_STATE_HOME:-$HOME/.local/state}/security-audit-sandbox"
|
||||
CONF_NAME=security-audit.conf
|
||||
DEFAULT_TIMEOUT=600
|
||||
|
||||
die() {
|
||||
printf '%s: %s\n' "$PROG" "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Copy target code into a scratch directory and run it in a locked-down Docker
|
||||
container: no network, read-only root, scratch-only writes, dropped
|
||||
capabilities, no-new-privileges, and CPU/memory/PID limits.
|
||||
|
||||
Usage:
|
||||
security-audit-sandbox start <app> [--image <image>] [--exclude <pattern>]...
|
||||
Copy <app> to $HOME/security-audit-runs/<slug>.XXXXXX and start the
|
||||
container. Repeat --exclude to add rsync exclusions.
|
||||
|
||||
security-audit-sandbox exec <app> [--timeout <seconds>] -- <command>...
|
||||
Run <command> inside the running container from /scratch/app under
|
||||
`timeout --signal=KILL`. Default timeout: 600 seconds.
|
||||
|
||||
security-audit-sandbox stop <app> [--keep]
|
||||
Remove the container and state file. Remove the run directory too,
|
||||
unless --keep is given.
|
||||
|
||||
security-audit-sandbox status <app>
|
||||
Print the container name, run directory, and whether it is running.
|
||||
|
||||
security-audit-sandbox --help
|
||||
Show this help.
|
||||
|
||||
Optional <app>/security-audit.conf (simple KEY=value lines, never sourced):
|
||||
IMAGE=node:22-bookworm
|
||||
EXCLUDE="node_modules dist coverage"
|
||||
|
||||
Image resolution order:
|
||||
1. --image
|
||||
2. IMAGE= in security-audit.conf
|
||||
3. package.json -> node:22-bookworm
|
||||
pyproject.toml or requirements.txt -> python:3.12-slim
|
||||
go.mod -> golang:1.24-bookworm
|
||||
Cargo.toml -> rust:1-bookworm
|
||||
Gemfile -> ruby:3.3-bookworm
|
||||
|
||||
Always excluded from the copy: .git, .env*, and the top-level /data directory.
|
||||
The original app directory is never mounted into the container.
|
||||
|
||||
Docker Desktop on macOS may refuse the fsize ulimit. The wrapper then starts
|
||||
the container without that one limit and prints a warning; nofile stays in
|
||||
place. On Linux hosts that accept fsize, the 100 MiB file-size cap is applied.
|
||||
EOF
|
||||
}
|
||||
|
||||
need_docker() {
|
||||
command -v docker >/dev/null 2>&1 || die "docker is not installed or not on PATH"
|
||||
docker info >/dev/null 2>&1 || die "cannot reach the Docker daemon; is Docker running?"
|
||||
}
|
||||
|
||||
canonical_app() {
|
||||
local app=$1
|
||||
[ -d "$app" ] || die "app directory not found: $app"
|
||||
(cd -P "$app" && pwd -P)
|
||||
}
|
||||
|
||||
app_slug() {
|
||||
local name
|
||||
name=$(basename "$1")
|
||||
name=${name//[^A-Za-z0-9_.-]/-}
|
||||
[ -n "$name" ] || name=app
|
||||
printf '%s' "$name"
|
||||
}
|
||||
|
||||
app_hash() {
|
||||
printf '%s' "$1" | shasum -a 256 | cut -c1-8
|
||||
}
|
||||
|
||||
state_file_for() {
|
||||
local app=$1 slug hash
|
||||
slug=$(app_slug "$app")
|
||||
hash=$(app_hash "$app")
|
||||
printf '%s/state-%s-%s' "$STATE_ROOT" "$slug" "$hash"
|
||||
}
|
||||
|
||||
container_name_for() {
|
||||
local app=$1 slug hash
|
||||
slug=$(app_slug "$app")
|
||||
hash=$(app_hash "$app")
|
||||
printf 'security-audit-%s-%s' "$slug" "$hash"
|
||||
}
|
||||
|
||||
strip_quotes() {
|
||||
local value=$1
|
||||
case $value in
|
||||
\"*\") value=${value#\"}; value=${value%\"} ;;
|
||||
\'*\') value=${value#\'}; value=${value%\'} ;;
|
||||
esac
|
||||
printf '%s' "$value"
|
||||
}
|
||||
|
||||
trim() {
|
||||
local value=$1
|
||||
value=${value#"${value%%[![:space:]]*}"}
|
||||
value=${value%"${value##*[![:space:]]}"}
|
||||
printf '%s' "$value"
|
||||
}
|
||||
|
||||
CONF_IMAGE=""
|
||||
CONF_EXCLUDE=""
|
||||
load_conf() {
|
||||
local app=$1 conf line key value
|
||||
conf="$app/$CONF_NAME"
|
||||
[ -f "$conf" ] || return 0
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
line=${line%$'\r'}
|
||||
line=$(trim "$line")
|
||||
case $line in
|
||||
''|'#'*) continue ;;
|
||||
esac
|
||||
case $line in
|
||||
*=*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
key=$(trim "${line%%=*}")
|
||||
value=$(trim "${line#*=}")
|
||||
value=$(strip_quotes "$value")
|
||||
case $key in
|
||||
IMAGE) CONF_IMAGE=$value ;;
|
||||
EXCLUDE) CONF_EXCLUDE="${CONF_EXCLUDE:+$CONF_EXCLUDE }$value" ;;
|
||||
esac
|
||||
done < "$conf"
|
||||
}
|
||||
|
||||
infer_image() {
|
||||
local app=$1
|
||||
if [ -f "$app/package.json" ]; then
|
||||
printf 'node:22-bookworm'
|
||||
elif [ -f "$app/pyproject.toml" ] || [ -f "$app/requirements.txt" ]; then
|
||||
printf 'python:3.12-slim'
|
||||
elif [ -f "$app/go.mod" ]; then
|
||||
printf 'golang:1.24-bookworm'
|
||||
elif [ -f "$app/Cargo.toml" ]; then
|
||||
printf 'rust:1-bookworm'
|
||||
elif [ -f "$app/Gemfile" ]; then
|
||||
printf 'ruby:3.3-bookworm'
|
||||
else
|
||||
printf ''
|
||||
fi
|
||||
}
|
||||
|
||||
load_state() {
|
||||
local app=$1 file key value
|
||||
file=$(state_file_for "$app")
|
||||
[ -f "$file" ] || return 1
|
||||
STATE_CONTAINER=""
|
||||
STATE_RUN_DIR=""
|
||||
STATE_APP=""
|
||||
STATE_IMAGE=""
|
||||
STATE_FSIZE=""
|
||||
while IFS='=' read -r key value || [ -n "$key" ]; do
|
||||
case $key in
|
||||
CONTAINER) STATE_CONTAINER=$value ;;
|
||||
RUN_DIR) STATE_RUN_DIR=$value ;;
|
||||
APP) STATE_APP=$value ;;
|
||||
IMAGE) STATE_IMAGE=$value ;;
|
||||
FSIZE) STATE_FSIZE=$value ;;
|
||||
esac
|
||||
done < "$file"
|
||||
[ -n "$STATE_CONTAINER" ] && [ -n "$STATE_RUN_DIR" ]
|
||||
}
|
||||
|
||||
container_running() {
|
||||
local name=$1 state
|
||||
state=$(docker inspect -f '{{.State.Running}}' "$name" 2>/dev/null) || return 1
|
||||
[ "$state" = "true" ]
|
||||
}
|
||||
|
||||
container_exists() {
|
||||
docker inspect "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
WALL_CLOCK_PROBE_SECS=2
|
||||
|
||||
check_wall_clock_guard() {
|
||||
local container=$1 status elapsed out
|
||||
SECONDS=0
|
||||
set +e
|
||||
out=$(docker exec "$container" timeout --signal=KILL "$WALL_CLOCK_PROBE_SECS" sleep 10 2>&1)
|
||||
status=$?
|
||||
set -e
|
||||
elapsed=$SECONDS
|
||||
case $status in
|
||||
124|137) ;;
|
||||
*)
|
||||
[ -z "$out" ] || printf '%s\n' "$out" >&2
|
||||
die "image $STATE_IMAGE's 'timeout' does not enforce '--signal=KILL'; refusing to run without a wall-clock limit"
|
||||
;;
|
||||
esac
|
||||
if [ "$elapsed" -lt 1 ] || [ "$elapsed" -gt $((WALL_CLOCK_PROBE_SECS + 4)) ]; then
|
||||
die "image $STATE_IMAGE's 'timeout' did not stop the probe after ${WALL_CLOCK_PROBE_SECS}s; refusing to run without a wall-clock limit"
|
||||
fi
|
||||
}
|
||||
|
||||
check_run_dir() {
|
||||
local dir=$1
|
||||
case $dir in
|
||||
"$RUN_PARENT"/*) ;;
|
||||
*) die "refusing to remove unexpected run directory: $dir" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
rm_run_dir() {
|
||||
local dir=$1
|
||||
check_run_dir "$dir"
|
||||
rm -rf "$dir"
|
||||
}
|
||||
|
||||
cleanup_failed_start() {
|
||||
local run_dir=$1 state_file=$2
|
||||
[ -n "$run_dir" ] && [ -d "$run_dir" ] && rm_run_dir "$run_dir"
|
||||
[ -n "$state_file" ] && rm -f "$state_file"
|
||||
}
|
||||
|
||||
cmd_start() {
|
||||
local app_arg="" image_opt="" conf_image inferred
|
||||
local app app_dir run_dir container state_file fsize_note out
|
||||
local -a cli_excludes rsync_cmd docker_cmd
|
||||
cli_excludes=()
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--image)
|
||||
[ $# -ge 2 ] || die "--image needs a value"
|
||||
image_opt=$2
|
||||
shift 2
|
||||
;;
|
||||
--image=*)
|
||||
image_opt=${1#--image=}
|
||||
shift
|
||||
;;
|
||||
--exclude)
|
||||
[ $# -ge 2 ] || die "--exclude needs a value"
|
||||
cli_excludes+=("$2")
|
||||
shift 2
|
||||
;;
|
||||
--exclude=*)
|
||||
cli_excludes+=("${1#--exclude=}")
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
-*)
|
||||
die "unknown option for start: $1"
|
||||
;;
|
||||
*)
|
||||
[ -z "$app_arg" ] || die "unexpected argument for start: $1"
|
||||
app_arg=$1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$app_arg" ] || die "start needs an app directory"
|
||||
need_docker
|
||||
app_dir=$(canonical_app "$app_arg")
|
||||
|
||||
load_conf "$app_dir"
|
||||
conf_image=$CONF_IMAGE
|
||||
|
||||
if [ -n "$image_opt" ]; then
|
||||
image=$image_opt
|
||||
elif [ -n "$conf_image" ]; then
|
||||
image=$conf_image
|
||||
else
|
||||
inferred=$(infer_image "$app_dir")
|
||||
[ -n "$inferred" ] || die "cannot infer an image for $app_dir; pass --image or set IMAGE= in $CONF_NAME"
|
||||
image=$inferred
|
||||
fi
|
||||
|
||||
state_file=$(state_file_for "$app_dir")
|
||||
container=$(container_name_for "$app_dir")
|
||||
|
||||
if load_state "$app_dir"; then
|
||||
if container_running "$STATE_CONTAINER"; then
|
||||
die "a sandbox for $app_dir is already running (container $STATE_CONTAINER); run '$PROG stop $app_arg' first"
|
||||
fi
|
||||
if container_exists "$STATE_CONTAINER"; then
|
||||
docker rm -f "$STATE_CONTAINER" >/dev/null 2>&1 || true
|
||||
fi
|
||||
rm -f "$state_file"
|
||||
printf '%s: removed stale state for stopped container %s\n' "$PROG" "$STATE_CONTAINER" >&2
|
||||
fi
|
||||
|
||||
if container_exists "$container"; then
|
||||
die "container $container already exists but is not recorded in state; remove it with 'docker rm -f $container'"
|
||||
fi
|
||||
|
||||
mkdir -p "$RUN_PARENT" || die "cannot create $RUN_PARENT"
|
||||
run_dir=$(mktemp -d "$RUN_PARENT/$(app_slug "$app_dir").XXXXXX") || die "cannot create run directory under $RUN_PARENT"
|
||||
mkdir -p "$run_dir/app" "$run_dir/home" "$run_dir/tmp" "$run_dir/cache" || {
|
||||
cleanup_failed_start "$run_dir" "$state_file"
|
||||
die "cannot prepare run directory $run_dir"
|
||||
}
|
||||
|
||||
rsync_cmd=(rsync -a --exclude=.git --exclude='.env*' --exclude=/data)
|
||||
if [ -n "$CONF_EXCLUDE" ]; then
|
||||
local conf_pat
|
||||
local -a conf_pats
|
||||
read -r -a conf_pats <<< "$CONF_EXCLUDE"
|
||||
for conf_pat in "${conf_pats[@]}"; do
|
||||
rsync_cmd+=("--exclude=$conf_pat")
|
||||
done
|
||||
fi
|
||||
if [ ${#cli_excludes[@]} -gt 0 ]; then
|
||||
local cli_pat
|
||||
for cli_pat in "${cli_excludes[@]}"; do
|
||||
rsync_cmd+=("--exclude=$cli_pat")
|
||||
done
|
||||
fi
|
||||
|
||||
if ! "${rsync_cmd[@]}" "$app_dir/" "$run_dir/app/"; then
|
||||
cleanup_failed_start "$run_dir" "$state_file"
|
||||
die "rsync failed while copying $app_dir"
|
||||
fi
|
||||
|
||||
docker_cmd=(docker run -d --name "$container"
|
||||
--network none
|
||||
--read-only
|
||||
-v "$run_dir:/scratch"
|
||||
--tmpfs '/tmp:rw,nosuid,size=512m'
|
||||
-e HOME=/scratch/home
|
||||
-e TMPDIR=/scratch/tmp
|
||||
-e XDG_CACHE_HOME=/scratch/cache
|
||||
--user "$(id -u):$(id -g)"
|
||||
--memory 4g
|
||||
--cpus 2
|
||||
--pids-limit 256
|
||||
--cap-drop ALL
|
||||
--security-opt no-new-privileges
|
||||
--init
|
||||
--ulimit nofile=1024:1024
|
||||
--workdir /scratch/app)
|
||||
|
||||
fsize_note=""
|
||||
if out=$("${docker_cmd[@]}" --ulimit fsize=104857600 "$image" sleep infinity 2>&1); then
|
||||
STATE_FSIZE=on
|
||||
fsize_note=on
|
||||
else
|
||||
case $out in
|
||||
*fsize*|*FSIZE*)
|
||||
printf '%s: Docker refused the fsize ulimit; starting without the file-size cap\n' "$PROG" >&2
|
||||
if out=$("${docker_cmd[@]}" "$image" sleep infinity 2>&1); then
|
||||
STATE_FSIZE=off
|
||||
fsize_note=off
|
||||
else
|
||||
cleanup_failed_start "$run_dir" "$state_file"
|
||||
die "docker run failed: $out"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
cleanup_failed_start "$run_dir" "$state_file"
|
||||
die "docker run failed: $out"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
mkdir -p "$STATE_ROOT" || {
|
||||
docker rm -f "$container" >/dev/null 2>&1 || true
|
||||
cleanup_failed_start "$run_dir" "$state_file"
|
||||
die "cannot create state directory $STATE_ROOT"
|
||||
}
|
||||
if ! {
|
||||
printf 'CONTAINER=%s\n' "$container"
|
||||
printf 'RUN_DIR=%s\n' "$run_dir"
|
||||
printf 'APP=%s\n' "$app_dir"
|
||||
printf 'IMAGE=%s\n' "$image"
|
||||
printf 'FSIZE=%s\n' "$STATE_FSIZE"
|
||||
} > "$state_file"; then
|
||||
docker rm -f "$container" >/dev/null 2>&1 || true
|
||||
cleanup_failed_start "$run_dir" "$state_file"
|
||||
die "cannot write state file $state_file"
|
||||
fi
|
||||
|
||||
printf 'container: %s\n' "$container"
|
||||
printf 'run dir: %s\n' "$run_dir"
|
||||
printf 'scratch: %s\n' "$run_dir (mounted at /scratch)"
|
||||
printf 'app copy: %s/app (mounted at /scratch/app)\n' "$run_dir"
|
||||
printf 'image: %s\n' "$image"
|
||||
if [ "$fsize_note" = off ]; then
|
||||
printf 'note: fsize ulimit refused by Docker; no file-size cap applied\n'
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_exec() {
|
||||
local app_arg="" timeout_secs=$DEFAULT_TIMEOUT saw_sep=0
|
||||
local app_dir container
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--timeout)
|
||||
[ $# -ge 2 ] || die "--timeout needs a value"
|
||||
timeout_secs=$2
|
||||
shift 2
|
||||
;;
|
||||
--timeout=*)
|
||||
timeout_secs=${1#--timeout=}
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
saw_sep=1
|
||||
break
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
-*)
|
||||
die "unknown option for exec: $1"
|
||||
;;
|
||||
*)
|
||||
[ -z "$app_arg" ] || die "unexpected argument for exec: $1"
|
||||
app_arg=$1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$app_arg" ] || die "exec needs an app directory"
|
||||
[ "$saw_sep" = 1 ] || die "exec needs -- before the command"
|
||||
[ $# -gt 0 ] || die "exec needs a command after --"
|
||||
case $timeout_secs in
|
||||
''|*[!0-9]*) die "--timeout must be a positive integer number of seconds" ;;
|
||||
esac
|
||||
[ "$timeout_secs" -gt 0 ] || die "--timeout must be greater than zero"
|
||||
|
||||
need_docker
|
||||
app_dir=$(canonical_app "$app_arg")
|
||||
load_state "$app_dir" || die "no sandbox recorded for $app_dir; run '$PROG start $app_arg' first"
|
||||
container=$STATE_CONTAINER
|
||||
container_running "$container" || die "container $container is not running; run '$PROG stop $app_arg' and start again"
|
||||
|
||||
check_wall_clock_guard "$container"
|
||||
|
||||
docker exec --workdir /scratch/app "$container" timeout --signal=KILL "$timeout_secs" "$@"
|
||||
}
|
||||
|
||||
cmd_stop() {
|
||||
local app_arg="" keep=0 app_dir run_dir
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--keep)
|
||||
keep=1
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
-*)
|
||||
die "unknown option for stop: $1"
|
||||
;;
|
||||
*)
|
||||
[ -z "$app_arg" ] || die "unexpected argument for stop: $1"
|
||||
app_arg=$1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$app_arg" ] || die "stop needs an app directory"
|
||||
app_dir=$(canonical_app "$app_arg")
|
||||
load_state "$app_dir" || die "no sandbox recorded for $app_dir"
|
||||
|
||||
run_dir=$STATE_RUN_DIR
|
||||
[ "$keep" = 1 ] || check_run_dir "$run_dir"
|
||||
docker rm -f "$STATE_CONTAINER" >/dev/null 2>&1 || true
|
||||
rm -f "$(state_file_for "$app_dir")"
|
||||
|
||||
if [ "$keep" = 1 ]; then
|
||||
printf 'removed container %s; kept run dir %s\n' "$STATE_CONTAINER" "$run_dir"
|
||||
else
|
||||
rm_run_dir "$run_dir"
|
||||
printf 'removed container %s and run dir %s\n' "$STATE_CONTAINER" "$run_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
cmd_status() {
|
||||
local app_arg="" app_dir running
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
-*)
|
||||
die "unknown option for status: $1"
|
||||
;;
|
||||
*)
|
||||
[ -z "$app_arg" ] || die "unexpected argument for status: $1"
|
||||
app_arg=$1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$app_arg" ] || die "status needs an app directory"
|
||||
app_dir=$(canonical_app "$app_arg")
|
||||
load_state "$app_dir" || die "no sandbox recorded for $app_dir"
|
||||
|
||||
if container_running "$STATE_CONTAINER"; then
|
||||
running=running
|
||||
elif container_exists "$STATE_CONTAINER"; then
|
||||
running=stopped
|
||||
else
|
||||
running=missing
|
||||
fi
|
||||
|
||||
printf 'container: %s\n' "$STATE_CONTAINER"
|
||||
printf 'run dir: %s\n' "$STATE_RUN_DIR"
|
||||
printf 'app: %s\n' "$STATE_APP"
|
||||
printf 'image: %s\n' "$STATE_IMAGE"
|
||||
printf 'fsize cap: %s\n' "$STATE_FSIZE"
|
||||
printf 'state: %s\n' "$running"
|
||||
}
|
||||
|
||||
main() {
|
||||
[ $# -gt 0 ] || {
|
||||
usage >&2
|
||||
exit 1
|
||||
}
|
||||
local cmd=$1
|
||||
shift
|
||||
case $cmd in
|
||||
start) cmd_start "$@" ;;
|
||||
exec) cmd_exec "$@" ;;
|
||||
stop) cmd_stop "$@" ;;
|
||||
status) cmd_status "$@" ;;
|
||||
-h|--help|help) usage ;;
|
||||
*)
|
||||
die "unknown command: $cmd (try --help)"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -14,3 +14,88 @@ The firstmate crew dispatch + Gitea PR helper are wired by `darwin-rebuild`, but
|
||||
git remote set-url origin http://unraid.local:3003/transnet/investor-flow
|
||||
|
||||
Verify: `fm` launches OpenCode 2 as the first mate (isolated `~/.config/opencode2`); `oc2 --version` prints an OpenCode 2 version; `pi --list-models mimo` shows `opencode-go/mimo-v2.5-pro`; `tea pulls list --repo transnet/investor-flow` works.
|
||||
|
||||
## security-audit skill (agent security reviews)
|
||||
|
||||
`home.activation.securityAuditSkill` installs Cloudflare's `security-audit` skill from `https://github.com/cloudflare/security-audit-skill` so the coding agents can run a structured vulnerability audit. The exact command:
|
||||
|
||||
```bash
|
||||
/opt/homebrew/bin/npx --yes skills add https://github.com/cloudflare/security-audit-skill \
|
||||
--skill security-audit --global \
|
||||
--agent claude-code codex pi opencode --yes
|
||||
```
|
||||
|
||||
The install needs Homebrew's `node`, which `configuration.nix` already declares, plus the system Git at `/usr/bin/git` for the clone. Renew or update the skill by hand with:
|
||||
|
||||
```bash
|
||||
/opt/homebrew/bin/npx --yes skills update security-audit --global --yes
|
||||
```
|
||||
|
||||
Agent scope: the Skills CLI installs the bundle once under `~/.agents/skills/security-audit`, the universal user-level directory that Codex, Pi, and OpenCode read, and it links that directory into `~/.claude/skills` for Claude Code. Grok Build is out of scope for this install: its skill directory is `~/.grok/skills`, and the CLI only populates it when `grok` is named in `--agent`. The install leaves `~/.config/opencode/skills` alone because home-manager owns that path with `force = true` and `mkOutOfStoreSymlink` into the mutable dotfiles checkout: a rebuild would clobber the CLI's link, and CLI writes would land in the git checkout. That is why the install uses the shared directory instead.
|
||||
|
||||
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: 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, and the key may be repeated: every `EXCLUDE=` line applies. 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, or its `timeout` does not enforce the `--signal=KILL` wall-clock limit, `exec` refuses to run rather than dropping the 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)
|
||||
|
||||
Hold a shortcut, speak, release, and the transcript pastes into the focused app. Everything runs on the Mac: no audio or transcript leaves the machine.
|
||||
|
||||
First run:
|
||||
|
||||
1. The `opensuperwhisper` cask is installed and `home.activation.openSuperWhisper` pre-downloads the model to `~/Library/Application Support/ru.starmel.OpenSuperWhisper/whisper-models/ggml-large-v3-turbo.bin`. It selects "Whisper V3 Large" only when no model is selected or the selected file is gone, so a model you pick in the app stays selected.
|
||||
2. Open the app. Onboarding should already show "Whisper V3 Large" as downloaded.
|
||||
3. Grant **Microphone**, **Accessibility**, and **Input Monitoring** when macOS asks. Input Monitoring is needed because the trigger is Right Option, a single modifier key.
|
||||
4. Keep the Right Option trigger (or change it in the app's settings). Hold it, speak, release. Auto-paste puts the text into the focused terminal or editor.
|
||||
|
||||
Notes:
|
||||
|
||||
- A fresh install starts with Option plus backtick instead of Right Option, and that combination needs no Input Monitoring. The activation never writes the trigger, the language, or the paste settings, so whatever you choose in the app survives the next rebuild.
|
||||
- The model is local-only (about 1.6 GB). If the download failed during the rebuild, rerun `./rebuild.sh` or download the large Turbo V3 model ("Turbo V3 large" in the app's Settings) by hand.
|
||||
- Voice is for prompts and prose. Type URLs, file paths, and exact identifiers yourself.
|
||||
- The first-run steps above are manual on purpose: macOS TCC permissions cannot be granted declaratively.
|
||||
+39
-2
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Rebuild nix-darwin + home-manager. Rotates stale home-manager *.backup files
|
||||
# so a second switch never fails with "would be clobbered".
|
||||
# Also upgrades grok-build and installs OpenCode 1.x (stable CLI for free-tier).
|
||||
# Also updates flake inputs, upgrades grok-build, installs OpenCode 1.x
|
||||
# (stable CLI for free-tier), updates no-mistakes, and updates pi extensions.
|
||||
set -euo pipefail
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
ln -sfn "$DIR" ~/.dotfiles
|
||||
@@ -31,6 +32,24 @@ else
|
||||
echo "==> OpenCode 1.x already installed: $(${OPENCODE_BIN} --version)"
|
||||
fi
|
||||
|
||||
echo "==> Updating no-mistakes..."
|
||||
NO_MISTAKES_BIN="$HOME/.no-mistakes/bin/no-mistakes"
|
||||
if [ -x "$NO_MISTAKES_BIN" ]; then
|
||||
if "$NO_MISTAKES_BIN" update 2>&1; then
|
||||
echo "==> no-mistakes update complete"
|
||||
else
|
||||
echo "==> WARNING: no-mistakes update failed. Skipping."
|
||||
fi
|
||||
elif command -v no-mistakes >/dev/null 2>&1; then
|
||||
if no-mistakes update 2>&1; then
|
||||
echo "==> no-mistakes update complete"
|
||||
else
|
||||
echo "==> WARNING: no-mistakes update failed. Skipping."
|
||||
fi
|
||||
else
|
||||
echo "==> WARNING: no-mistakes not found. Skipping update."
|
||||
fi
|
||||
|
||||
stamp="$(date +%Y%m%d-%H%M%S)"
|
||||
# Paths home-manager manages via home.file (regular files become out-of-store symlinks).
|
||||
managed=(
|
||||
@@ -74,4 +93,22 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
exec sudo darwin-rebuild switch --flake ~/.dotfiles#lt-mbp
|
||||
echo "==> Updating flake inputs..."
|
||||
if nix flake update --flake ~/.dotfiles 2>&1; then
|
||||
echo "==> flake update complete"
|
||||
else
|
||||
echo "==> WARNING: flake update failed. Continuing with locked inputs."
|
||||
fi
|
||||
|
||||
sudo darwin-rebuild switch --flake ~/.dotfiles#lt-mbp
|
||||
|
||||
# Update installed pi packages after the switch, because the Homebrew bundle
|
||||
# may have upgraded the pi binary.
|
||||
echo "==> Updating pi extensions..."
|
||||
if ! command -v pi >/dev/null 2>&1; then
|
||||
echo "==> WARNING: pi not found. Skipping extension update."
|
||||
elif pi update --extensions --no-approve 2>&1; then
|
||||
echo "==> pi extension update complete"
|
||||
else
|
||||
echo "==> WARNING: pi extension update failed. Skipping."
|
||||
fi
|
||||
Reference in new issue
Block a user