Skip to content

fix(extract): improve symlink handling to replace existing entries atomically - #26

Merged
zombocoder merged 1 commit into
mainfrom
fix/extract-symlink-toctou
Oct 24, 2026
Merged

zombocoder merged 1 commit into
mainfrom
fix/extract-symlink-toctou

Conversation

@zombocoder

Copy link
Copy Markdown
Owner

This pull request improves the safety and correctness of symlink extraction in the CLI, especially when handling existing files, symlinks, or directories at the extraction path. It introduces an atomic replacement strategy for symlinks, updates the extraction logic to require -f to overwrite existing entries, and adds comprehensive tests for these scenarios.

Symlink extraction improvements:

  • Introduced a new replace_with_symlink function (non-Windows) that atomically creates and renames a symlink, ensuring safe replacement of existing files or symlinks without race conditions.
  • Updated extract_symlink to use the new atomic replacement logic: now, if a symlink already exists and -f is not specified, extraction fails with an informative message; if -f is given, the symlink is safely replaced. Regular files are also replaced only with -f, and directories are never replaced.
  • Ensured that on Windows, symlinks are skipped with a warning, maintaining platform compatibility. [1] [2]

Testing improvements:

  • Added a comprehensive test section to test_cli.sh that verifies symlink extraction over existing symlinks, files, and directories, both with and without the -f (force) flag, and checks for cleanup of temporary symlinks.

@zombocoder
zombocoder merged commit 378009d into main Oct 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant