banger/internal/kernelcat
Thales Maciel fdaf7cce0f
imagepull + kernelcat: allow absolute symlink targets
Container (and kernel) layers routinely ship symlinks with absolute
targets — /usr/bin/mawk, /lib/modules/<ver>/build, etc. Those are
interpreted relative to the rootfs at runtime (`/` inside the VM),
not against the host filesystem, so they are rooted inside dest by
construction and need no escape check at write time.

The previous logic resolved absolute Linknames literally (against
the host root), compared to the staging dir, and rejected everything
that didn't happen to live under it. That made `banger image pull
docker.io/library/debian:bookworm` fail on the very first symlink
("etc/alternatives/awk -> /usr/bin/mawk").

Relative targets still get the traversal check — a relative
Linkname with ../s can genuinely escape dest at write time even if
in-VM resolution would be safe — so the defense against malicious
relative chains is intact.

Tests:
 - TestFlattenAcceptsAbsoluteSymlink replaces the old overly-strict
   test, using the exact etc/alternatives/awk -> /usr/bin/mawk case
   that broke debian:bookworm.
 - TestFlattenRejectsRelativeSymlinkEscape confirms relative-with-
   traversal is still rejected with the same "unsafe symlink"
   error.

Same fix applied in internal/kernelcat/fetch.go for consistency;
future kernel bundles with absolute symlinks in the modules tree
would otherwise hit the same wall.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 17:33:16 -03:00
..
catalog.go Phase 4: remote catalog + banger kernel pull 2026-04-16 15:05:42 -03:00
catalog.json kernel catalog: add void-6.12 2026-04-16 16:28:45 -03:00
catalog_test.go Phase 4: remote catalog + banger kernel pull 2026-04-16 15:05:42 -03:00
fetch.go imagepull + kernelcat: allow absolute symlink targets 2026-04-16 17:33:16 -03:00
fetch_test.go Phase 4: remote catalog + banger kernel pull 2026-04-16 15:05:42 -03:00
import.go Phase 3: banger kernel import bridges make-*-kernel.sh output 2026-04-16 14:53:49 -03:00
import_test.go Phase 3: banger kernel import bridges make-*-kernel.sh output 2026-04-16 14:53:49 -03:00
kernelcat.go Phase 1: local kernel catalog scaffolding 2026-04-16 14:21:10 -03:00
kernelcat_test.go Phase 1: local kernel catalog scaffolding 2026-04-16 14:21:10 -03:00