- 
                Notifications
    
You must be signed in to change notification settings  - Fork 718
 
mounts: prohibit relative paths in YAML #3950
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
Conversation
b6ee573    to
    2837c7e      
    Compare
  
    | 
           I've not looked in detail, but returning an error from  
 EDIT: I see it is already a separate PR, and just stacked with this one.  | 
    
2837c7e    to
    af44ee9      
    Compare
  
    | 
           Updated to avoid returning err from   | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still not the right fix. The regression was introduced by #3339. It unconditionally expands all local filenames to absolute names. We should only call Expand() when the location actually is a tilde-path:
--- pkg/limayaml/defaults.go
+++ pkg/limayaml/defaults.go
@@ -713,10 +713,12 @@ func FillDefault(ctx context.Context, y, d, o *limatype.LimaYAML, filePath strin
 				mounts[i].NineP.Cache = ptr.Of(Default9pCacheForRO)
 			}
 		}
-		if location, err := localpathutil.Expand(mount.Location); err == nil {
-			mounts[i].Location = location
-		} else {
-			logrus.WithError(err).Warnf("Couldn't expand location %q", mount.Location)
+		if localpathutil.IsTildePath(mount.Location) {
+			if location, err := localpathutil.Expand(mount.Location); err == nil {
+				mounts[i].Location = location
+			} else {
+				logrus.WithError(err).Warnf("Couldn't expand location %q", mount.Location)
+			}
 		}
 		if mount.MountPoint == nil {
 			mountLocation := mounts[i].LocationThis fixes the existing validation:
❯ cat mount.yaml
images: [{location: /foo}]
mounts: [{location: foo}]
❯ l tmpl validate mount.yaml
FATA[0000] failed to validate YAML file "mount.yaml": field `mounts[0].location` must be an absolute path, got "foo"3b103d5    to
    b803a24      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM
Relative paths are still allowed in CLI: `limactl create --mount=DIR` Fix issue 3948 Signed-off-by: Akihiro Suda <[email protected]>
b803a24    to
    749c879      
    Compare
  
    
YAMLs with relative paths like
mounts: [{location: .}]are not longer allowed.Relative paths are still allowed in CLI:
limactl create --mount=DIRFix #3948