aboutsummaryrefslogtreecommitdiff
path: root/tests/layout-navigate/test_layout_navigate.py
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
commit0051671d0cff859ad3a67a21714005714ae1f752 (patch)
treeb7e7cb6166f57c053b1e1ba1c61a00084ea3548c /tests/layout-navigate/test_layout_navigate.py
parentc24174f811ad5ffca1a3454013b55127df50ff3c (diff)
downloadarchsetup-0051671d0cff859ad3a67a21714005714ae1f752.tar.gz
archsetup-0051671d0cff859ad3a67a21714005714ae1f752.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 'tests/layout-navigate/test_layout_navigate.py')
0 files changed, 0 insertions, 0 deletions