Commit 0767f90
committed
fix: prevent silent ancestor resolution from malformed YAML paths
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 (#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)
```1 parent cd30471 commit 0767f90
2 files changed
+30
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
171 | 179 | | |
172 | 180 | | |
173 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
210 | 231 | | |
211 | 232 | | |
212 | 233 | | |
| |||
0 commit comments