summaryrefslogtreecommitdiff
path: root/src/lib/config.sync.source.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-16 23:11:32 +0300
committerPaul Buetow <paul@buetow.org>2026-06-16 23:11:32 +0300
commitca5bcf37e40d4dbd41dc9d9d001d6f4b9c6dcd65 (patch)
tree9deb2da9693d422ea01995e216862239194b4fd7 /src/lib/config.sync.source.sh
parent72f72995a9c4a1ddd2ea3adb04cc2d7641410245 (diff)
8n0 validate DIST_DIR before --clean rm -rf
The --clean action ran `rm -rf "$DIST_DIR"` after only an `[ -d ]` check, so a misconfigured DIST_DIR (empty, /, $HOME, system dirs, etc.) could recursively delete the wrong tree. Add validate_clean_dist_dir (and resolve_dist_dir_path) in config.validate.source.sh and call it in the --clean case before any deletion. The guard canonicalizes DIST_DIR with `pwd -P` (handling ./ trailing slashes, symlinks and relative paths; for a not-yet-existing dir it resolves the existing parent and re-attaches the basename) and refuses to clean when the resolved path is empty, the filesystem root, a well-known system directory, the resolved $HOME, or the current working directory. Rejection uses config_error with a clear message and a non-zero exit, so nothing is deleted. Normal DIST_DIRs still clean. Tests (tests/cli.sh, registered in main): a HOME-as-DIST_DIR case (uses a fake HOME under TEST_TMPDIR with a sentinel file, so a regression can only touch the throwaway temp dir) and an empty-DIST_DIR case both assert rejection and that nothing is removed. Note: leftover staging artifacts on --clean are out of scope (task ln0). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'src/lib/config.sync.source.sh')
0 files changed, 0 insertions, 0 deletions