applier: refuse to clobber a symlinked LICENSE (#33) #40

Merged
KofTwentyTwo merged 1 commits from feature/GH-33-symlink-license into develop 2026-06-09 15:17:56 +00:00
1 Commits
Author SHA1 Message Date
james.maes 05157ddf48 fix(#33): refuse to overwrite a symlinked license file
AtomicWrite used os.Stat + os.Rename with no symlink check, so writing a
managed LICENSE / LICENSES/<id>.txt that is a deliberate symlink (e.g.
LICENSE -> LICENSES/MIT.txt) would replace the link with a regular file,
silently breaking it.

AtomicWrite now lstats the target and refuses with errSymlinkTarget when it
is a symlink, leaving the link and its target untouched. The error message
contains "refusing to write" so the CLI's isWriteRefusal mapping classifies
it as a write refusal (exit code 3). writeManaged propagates this refusal as
a returned error (other write failures stay recorded per-file as before).

Closes #33
2026-06-09 08:00:58 -05:00