cadrumo.core.link_safety module¶
Link-safety predicate shared by every path guard in the codebase.
A guard that refuses to follow a link into or out of a controlled tree must
ask about both reparse-point kinds Windows exposes, not just the POSIX one:
Path.is_symlink() is False for a Windows directory junction, so a check
written with it alone fails open against a junction. Thirty-one sites spelled
the two-part test inline before this module existed, and the one place the
predicate was already named lived in a journal repository, unreachable from
any other package.
The neighbouring primitives live in their own defining modules:
fsync_parent_dir() and
exclusive_file_lock(). This predicate follows the
same single-owner shape.
- is_link_like(path)[source]¶
Return whether
pathis a symlink or a Windows junction.Note the asymmetry that makes this worth naming: a junction is a directory-only reparse point. A guard that already requires
is_file()therefore loses nothing by testingis_symlink()alone, because a junction cannot satisfyis_file()in the first place. Those sites are correct as written and are not defects awaiting this helper; the ones that need it are the guards over directories, and the guards that run before any kind is established.