Skip to content

refactor(images): adopt resolve-once pattern, port upstream security tests#461

Merged
DorianZheng merged 1 commit into
mainfrom
refactor/containerd-resolve-once-pattern
May 2, 2026
Merged

refactor(images): adopt resolve-once pattern, port upstream security tests#461
DorianZheng merged 1 commit into
mainfrom
refactor/containerd-resolve-once-pattern

Conversation

@DorianZheng

Copy link
Copy Markdown
Member

Summary

  • Simplify SafeRoot from 12+ methods to 5 (open/resolve/resolve_or_root/normalize/root_path) — callers use standard std::fs on the resolved PathBuf
  • Move extraction helpers into LayerExtractor as associated functions instead of scattered free functions
  • Fix dir finalization to use symlink_metadata instead of exists() (prevents following replaced symlinks)
  • Port upstream security test cases: symlink escape, whiteout handling, hardlink safety, path traversal, circular symlinks, hop limits
  • Remove dead dns.rs module, fix build.rs linker comment, refactor guest /etc bind-mounts to bundle-dir pattern

Test plan

  • cargo clippy clean on macOS and Linux
  • cargo test passes on macOS (662 tests) and Linux (670 tests)
  • 54 archive-specific tests pass on both platforms (including pathrs backend on Linux)
  • CI runs clippy + tests automatically on push

…m tests

Ditch the SafeRoot god object (12+ methods) in favor of containerd's
resolve-once pattern: SafeRoot shrinks to open/resolve/resolve_or_root/
normalize/root_path. Callers use standard std::fs on the resolved PathBuf.

Key changes:
- Move extraction helpers into LayerExtractor as associated functions
- Extract resolve_or_root() and normalize() onto SafeRoot (DRY)
- Fix dir finalization to use symlink_metadata instead of exists()
- Simplify remove_nofollow, obstacle removal, apply_xattrs
- Port containerd/umoci security test cases (symlink escape, whiteout,
  hardlink, path traversal, circular symlinks, hop limits)
- Remove dead dns.rs module, fix build.rs linker comment
- Refactor guest /etc bind-mounts to bundle-dir pattern (Docker/containerd)
@DorianZheng DorianZheng merged commit b5e7b1b into main May 2, 2026
30 checks passed
@DorianZheng DorianZheng deleted the refactor/containerd-resolve-once-pattern branch May 2, 2026 07:01
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.

1 participant