Skip to content

Commit

Permalink
move filepath.Clean to caller
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Oct 22, 2020
1 parent 2505858 commit 54109b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions client/allocrunner/taskrunner/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ func parseTemplateConfigs(config *TaskTemplateManagerConfig) (map[*ctconf.Templa
src = taskEnv.ReplaceEnv(tmpl.SourcePath)
if !filepath.IsAbs(src) {
src = filepath.Join(config.TaskDir, src)
} else {
src = filepath.Clean(src)
}
escapes := helper.PathEscapesSandbox(config.TaskDir, src)
if escapes && sandboxEnabled {
Expand Down
6 changes: 3 additions & 3 deletions helper/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,10 @@ func CheckNamespaceScope(provided string, requested []string) []string {
return nil
}

// PathEscapesSandbox returns whether a cleaned path inside the sandbox
// directory (typically this will be the allocation directory) escapes.
// PathEscapesSandbox returns whether previously cleaned path inside the
// sandbox directory (typically this will be the allocation directory)
// escapes.
func PathEscapesSandbox(sandboxDir, path string) bool {
path = filepath.Clean(path)
rel, err := filepath.Rel(sandboxDir, path)
if err != nil {
return true
Expand Down

0 comments on commit 54109b4

Please sign in to comment.