Skip to content

Commit d006e07

Browse files
committed
Check for absolute paths in a Kitfile and print clear message
Print a clear error message if a Kitfile contains an absolute path (instead of a relative one). Otherwise, we try to concatenate the absolute path to the pack context, which leads to a very confusing error message.
1 parent ee0758b commit d006e07

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/lib/filesystem/paths.go

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import (
1212
// VerifySubpath checks that filepath.Join(context, subDir) is a subdirectory of context, following
1313
// symlinks if present.
1414
func VerifySubpath(context, subDir string) (absPath string, err error) {
15+
if filepath.IsAbs(subDir) {
16+
return "", fmt.Errorf("absolute paths are not supported (%s)", subDir)
17+
}
18+
1519
// Get absolute path for context and context + subDir
1620
absContext, err := filepath.Abs(context)
1721
if err != nil {

0 commit comments

Comments
 (0)