-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: prevent silent ancestor resolution from malformed YAML paths #5980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: prevent silent ancestor resolution from malformed YAML paths #5980
Conversation
|
Welcome @willbuckner! |
Hi @willbuckner. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: willbuckner The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
When malformed YAML creates resource paths like `"../../base - ../../shared/prod"`, `FileLoader.New()` was silently resolving these to existing ancestor directories through path normalization instead of failing appropriately. This could cause resources to be loaded from unintended locations, which can be especially dangerous in CI/CD environments (kubernetes-sigs#5979). Added validation in `FileLoader.New()` to check directory existence before allowing path normalization, preventing the silent "ancestor snapping" behavior. Before: ``` === RUN TestNewLoaderMalformedPath fileloader_test.go:223: Error Trace: /Users/wbuckner/dev/kustomize/api/internal/loader/fileloader_test.go:223 Error: "must build at directory: not a valid directory: '/shared/prod' doesn't exist" does not contain "does not exist" Test: TestNewLoaderMalformedPath --- FAIL: TestNewLoaderMalformedPath (0.00s) FAIL FAIL sigs.k8s.io/kustomize/api/internal/loader 0.757s FAIL ``` After: ``` === RUN TestNewLoaderMalformedPath --- PASS: TestNewLoaderMalformedPath (0.00s) PASS ok sigs.k8s.io/kustomize/api/internal/loader (cached) ```
5e93cdc
to
0767f90
Compare
/ok-to-test |
Hi @willbuckner Please fix tests that happen on CI. |
Fixes #5979
When malformed YAML creates resource paths like
"../../base - ../../shared/prod"
,FileLoader.New()
was silently resolving these to existing ancestor directories through path normalization instead of failing appropriately. This could cause resources to be loaded from unintended locations, which can be especially dangerous in CI/CD environments.Added validation in
FileLoader.New()
to check directory existence before allowing path normalization, preventing the silent "ancestor snapping" behavior.Before:
After: