Skip to content

fix(template): keep in-template symlinks and never read through them - #182

Merged
Ilyes512 merged 4 commits into
mainfrom
fix/GH-175-template-symlinks
Nov 24, 2026
Merged

Ilyes512 merged 4 commits into
mainfrom
fix/GH-175-template-symlinks

Conversation

@Ilyes512

@Ilyes512 Ilyes512 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Closes #175

Summary

  • Symlinks that resolve inside template/ stay symlinks (file, directory and chained links); their target is rendered like a file name, so .node-version → {{ .Name }}.rc points at the rendered name
  • Absolute, escaping (at any step of the chain) and dangling links are never read through: they are skipped with a warning instead of leaking outside files or aborting the run; links whose rendered target is not generated are removed with a warning
  • CopyDir recreates in-bounds links and skips the rest, so the local → temp and temp → target copies no longer flatten or read through them
  • Cloned templates with a link out of template/ are rejected in specs use <git-url>, template download and remote template upgrade; template validate reports skipped links with exit bit 8

Decisions and skipped steps

  • Every absolute target is out of bounds, even one pointing into template/: it stops pointing at the template once the template is copied
  • Any step that leaves template/ makes a link out of bounds, even if a later step comes back in
  • A remote upgrade now clones into a staging dir under the config dir and only replaces the registered template once the check passes, so a rejected (or failed) upgrade leaves the existing template intact
  • template download --force keeps its existing behaviour on rejection: the old template has already been removed, as with reserved variable names
  • Not fixed here: a file or directory name that renders to ../x is written outside the output directory; unrelated to symlinks, filed as Rendered file names are not bounds-checked: a template can write outside the output directory #183

GH-175)

CopyDir recreates a link that resolves inside the copied tree and skips (and returns) one that is absolute, escapes at any step of its chain, or dangles. Callers warn about the skipped links.
…ugh them (GH-175)

Execute recreates a link that resolves inside template/ with its target rendered like a file name, and skips out-of-bounds and dangling links with a warning. Links whose rendered target is not in the output are removed. Analysis and validate no longer read through links, and template validate reports skipped links with exit bit 8.
…GH-175)

CheckLinks runs wherever a template is cloned: specs use <git-url>, template download and remote upgrades. A remote upgrade now clones into a staging dir and only replaces the registered template once the check passes.
@Ilyes512
Ilyes512 merged commit f0d98f1 into main Nov 24, 2026
8 checks passed
@Ilyes512
Ilyes512 deleted the fix/GH-175-template-symlinks branch November 24, 2026 15:58
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.

Template symlinks are followed: in-template links are flattened and out-of-template targets are read

1 participant