- `BuildFSSync.read()` and `info()` resolved a
requested path, checked that the result was
inside the build context, and then opened the
original path. A symlink replaced between the
check and the open was followed to its new
target, which could be outside the context.
-This change opens each requested file by
walking its path one component at a time from
a directory descriptor pinned on the context
root, using `FileDescriptorOps` from
`containerization`. Symlinks are followed only
when the target is relative and stays beneath
the context root. The metadata and the content
returned to the builder both come from the
same open descriptor.
- Behavior change: a symlink with an absolute
target is now rejected by `read()` and `info()`,
even when the target is inside the context.
Relative symlinks that stay inside the context
still work. `walk()`-based transfers are unchanged.
- Dependency: Requires `containerization` 0.50.0
for its `FileDescriptorOps` API enhancements.
This change updates the library from 0.52.0
to 0.52.1.
Closes#782#99
If a Dockerfile can't be found in the context dir, check for the common
alternative Containerfile. This does not implement .containerignore
also, solely Containerfile for now. This also funnily enough fixes us
not checking for the Dockerfile IN the context directory.. woops.
## Type of Change
- [x] Bug fix
- [x] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [x] Tested locally
- [x] Added/updated tests
- [x] Added/updated docs
`BuildFSSync.walk` relied on an implementation detail to skip traversing
the path ".", relative to the build context dir.
Specifically, it assumed that:
- `URL.parentOf()` would return false when the parent argument was
relative.
- `URL.path(percentEncoded: false)` would preserve the relativity of an
input path.
These assumptions held on earlier macOS releases, so the context
directory silently remained untouched.
In some versions of macOS , `URL.path(percentEncoded: false)` always
returns an absolute path, regardless of how the URL was created. Because
of this change, `URL.parentOf()` now returns true for ".", and
BuildFSSync.walk begins descending into the context directory—something
it was never meant to do.
This solution:
- Remove the hidden dependency on `URL.parentOf()` for context‑directory
detection.
- Add an explicit check for "." inside BuildFSSync.walk and bail out
early.
Replace fragile calls to `URL.path(percentEncoded: false`) with the
stable, documented `URL.relativePath`, which preserves relativity when
the original path was relative.