Hwaro::Utils::OutputGuard
Instance methods
Verify that the given output path is within the output directory. Returns the output_path if safe, or a fallback path and logs a warning.
Example: safe_path("public/../etc/passwd", "public") # => "public/index.html" (with warning) safe_path("public/blog/index.html", "public") # => "public/blog/index.html"
cwd lets a caller that resolves many paths in one build pass the
working directory it already holds.
Check an existing directory before pruning it. Resolve the directory itself (including symlinked ancestors), reject a symlink leaf, and never allow pruning the output root.
Check an existing file before unlinking it. Lexical containment alone
is not enough for a persisted stale path such as
public/link/secret: public/link may point outside the output tree.
The leaf may itself be a symlink because deleting it removes the link,
so resolve and check its parent instead.