feat(home): add repeatable security-audit Docker sandbox #11

Merged
hermes merged 5 commits from fm/dotfiles-audit-sandbox into main 2026-10-25 13:03:35 -04:00
2 changed files with 13 additions and 5 deletions
Showing only changes of commit c45d61387f - Show all commits

No files matched your search

+12 -4
View File
@@ -21,7 +21,7 @@
set -euo pipefail
PROG=security-audit-sandbox
RUN_PARENT="${SECURITY_AUDIT_RUN_PARENT:-$HOME/security-audit-runs}"
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
@@ -152,7 +152,7 @@ load_conf() {
value=$(strip_quotes "$value")
case $key in
IMAGE) CONF_IMAGE=$value ;;
EXCLUDE) CONF_EXCLUDE=$value ;;
EXCLUDE) CONF_EXCLUDE="${CONF_EXCLUDE:+$CONF_EXCLUDE }$value" ;;
esac
done < "$conf"
}
@@ -205,14 +205,20 @@ container_exists() {
docker inspect "$1" >/dev/null 2>&1
}
rm_run_dir() {
check_run_dir() {
local dir=$1
case $dir in
"$RUN_PARENT"/*) rm -rf "$dir" ;;
"$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"
@@ -284,6 +290,7 @@ cmd_start() {
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
rm_run_dir "$STATE_RUN_DIR"
if container_exists "$STATE_CONTAINER"; then
docker rm -f "$STATE_CONTAINER" >/dev/null 2>&1 || true
fi
@@ -476,6 +483,7 @@ cmd_stop() {
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")"
+1 -1
View File
@@ -65,7 +65,7 @@ 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.
`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: