aboutsummaryrefslogtreecommitdiff
path: root/scripts/setup-chess.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-20 21:53:58 -0400
committerCraig Jennings <c@cjennings.net>2026-05-20 21:53:58 -0400
commit8eede6d7f9decc27bf77ab51a4f24f479b2434ee (patch)
treeb7e7cb6166f57c053b1e1ba1c61a00084ea3548c /scripts/setup-chess.sh
parent173331fe191d32cfc6585968f0b9ccc043a3e94b (diff)
downloadarchsetup-8eede6d7f9decc27bf77ab51a4f24f479b2434ee.tar.gz
archsetup-8eede6d7f9decc27bf77ab51a4f24f479b2434ee.zip
fix(installer): guard constructed-path rm -rf deletes
Three rm -rf sites in archsetup delete paths built from variables: $state_dir for --fresh, and $source_dir/$prog_name for the git and AUR clone-retry cleanups. If a path variable were empty or malformed (preflight skipped, a degenerate git URL), the delete could expand to a top-level or otherwise unintended directory. I added a safe_rm_rf <path> <allowed_prefix> helper that refuses to run unless the target is absolute, free of '..', deeper than a bare top-level dir, strictly inside the allowed prefix, and a real directory rather than a symlink. On the happy path it delegates to rm -rf, so successful installs are unchanged. The helper is self-contained and defined before the top-level --fresh handler, which runs before the logging helpers exist. I covered the guard with unit tests under tests/safe-rm-rf/ that source the real function and exercise normal, boundary, and error cases against temp directories.
Diffstat (limited to 'scripts/setup-chess.sh')
0 files changed, 0 insertions, 0 deletions