no-mistakes(review): Fix stop guard order, accumulate EXCLUDE lines, drop run-parent override
This commit is contained in:
1 parent
76ff344ff5
commit
c45d61387f
2 files changed
+13
-5
No files matched your search
@@ -21,7 +21,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
PROG=security-audit-sandbox
|
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"
|
STATE_ROOT="${XDG_STATE_HOME:-$HOME/.local/state}/security-audit-sandbox"
|
||||||
CONF_NAME=security-audit.conf
|
CONF_NAME=security-audit.conf
|
||||||
DEFAULT_TIMEOUT=600
|
DEFAULT_TIMEOUT=600
|
||||||
@@ -152,7 +152,7 @@ load_conf() {
|
|||||||
value=$(strip_quotes "$value")
|
value=$(strip_quotes "$value")
|
||||||
case $key in
|
case $key in
|
||||||
IMAGE) CONF_IMAGE=$value ;;
|
IMAGE) CONF_IMAGE=$value ;;
|
||||||
EXCLUDE) CONF_EXCLUDE=$value ;;
|
EXCLUDE) CONF_EXCLUDE="${CONF_EXCLUDE:+$CONF_EXCLUDE }$value" ;;
|
||||||
esac
|
esac
|
||||||
done < "$conf"
|
done < "$conf"
|
||||||
}
|
}
|
||||||
@@ -205,14 +205,20 @@ container_exists() {
|
|||||||
docker inspect "$1" >/dev/null 2>&1
|
docker inspect "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
rm_run_dir() {
|
check_run_dir() {
|
||||||
local dir=$1
|
local dir=$1
|
||||||
case $dir in
|
case $dir in
|
||||||
"$RUN_PARENT"/*) rm -rf "$dir" ;;
|
"$RUN_PARENT"/*) ;;
|
||||||
*) die "refusing to remove unexpected run directory: $dir" ;;
|
*) die "refusing to remove unexpected run directory: $dir" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rm_run_dir() {
|
||||||
|
local dir=$1
|
||||||
|
check_run_dir "$dir"
|
||||||
|
rm -rf "$dir"
|
||||||
|
}
|
||||||
|
|
||||||
cleanup_failed_start() {
|
cleanup_failed_start() {
|
||||||
local run_dir=$1 state_file=$2
|
local run_dir=$1 state_file=$2
|
||||||
[ -n "$run_dir" ] && [ -d "$run_dir" ] && rm_run_dir "$run_dir"
|
[ -n "$run_dir" ] && [ -d "$run_dir" ] && rm_run_dir "$run_dir"
|
||||||
@@ -284,6 +290,7 @@ cmd_start() {
|
|||||||
if container_running "$STATE_CONTAINER"; 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"
|
die "a sandbox for $app_dir is already running (container $STATE_CONTAINER); run '$PROG stop $app_arg' first"
|
||||||
fi
|
fi
|
||||||
|
rm_run_dir "$STATE_RUN_DIR"
|
||||||
if container_exists "$STATE_CONTAINER"; then
|
if container_exists "$STATE_CONTAINER"; then
|
||||||
docker rm -f "$STATE_CONTAINER" >/dev/null 2>&1 || true
|
docker rm -f "$STATE_CONTAINER" >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
@@ -476,6 +483,7 @@ cmd_stop() {
|
|||||||
load_state "$app_dir" || die "no sandbox recorded for $app_dir"
|
load_state "$app_dir" || die "no sandbox recorded for $app_dir"
|
||||||
|
|
||||||
run_dir=$STATE_RUN_DIR
|
run_dir=$STATE_RUN_DIR
|
||||||
|
[ "$keep" = 1 ] || check_run_dir "$run_dir"
|
||||||
docker rm -f "$STATE_CONTAINER" >/dev/null 2>&1 || true
|
docker rm -f "$STATE_CONTAINER" >/dev/null 2>&1 || true
|
||||||
rm -f "$(state_file_for "$app_dir")"
|
rm -f "$(state_file_for "$app_dir")"
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ IMAGE=node:22-bookworm
|
|||||||
EXCLUDE="node_modules dist coverage"
|
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:
|
Container controls:
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user