Commit e46cf9a
Validate container path is absolute in VolumeMount::Parse (#40085)
* Validate container path is absolute in VolumeMount::Parse
Add validation that non-empty container paths must start with '/' since
they are Linux paths inside the container. This catches cases where
Windows drive letter colons (e.g. C:\path) get misinterpreted as the
host:container separator, producing invalid container paths like
'\hostPath' instead of '/containerPath'.
Previously, 'C:\hostPath:ro' would silently parse as host='C',
container='\hostPath', mode=ro ΓÇö now it throws a clear error.
Updated tests to reflect the new validation and moved previously
'valid' but semantically incorrect cases to the invalid test set.
* Also validate host path is absolute, add format hint to error, cover forward-slash cases
- Reject non-absolute host paths (catches C:/hostPath where host='C')
- Add 'Expected format:' hint to container path error message for consistency
- Add forward-slash drive letter cases to invalid test set
- Move '::' case to invalid (host=':' is not absolute)
* Remove host path is_absolute check to allow future named volumes
Per review feedback: named volumes (e.g. 'test_vol:/path') would fail
an is_absolute() check on the host path. Keep only the container path
validation (must start with '/') which doesn't conflict with named
volume identifiers.
---------
Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>1 parent e712372 commit e46cf9a
3 files changed
Lines changed: 30 additions & 8 deletions
File tree
- src/windows/wslc/services
- test/windows/wslc
- e2e
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
199 | 206 | | |
200 | 207 | | |
201 | 208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | 38 | | |
40 | | - | |
41 | | - | |
42 | 39 | | |
43 | | - | |
| 40 | + | |
44 | 41 | | |
45 | 42 | | |
46 | 43 | | |
| |||
69 | 66 | | |
70 | 67 | | |
71 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
72 | 87 | | |
73 | 88 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | | - | |
| 313 | + | |
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | | - | |
| 320 | + | |
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
| 342 | + | |
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| |||
0 commit comments