Skip to content

Commit

Permalink
update validation logic
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Dolitsky <jdolitsky@gmail.com>
  • Loading branch information
jdolitsky committed Jan 14, 2019
1 parent b651eab commit 5a6747a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/chart-scanner/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,21 @@ func validateChartPackage(backend storage.Backend, filePath string, debug bool)
exitCode = 1
return
}

fileBaseName := filepath.Base(filePath)
name := chart.Metadata.Name
if !strings.HasPrefix(filepath.Base(filePath), fmt.Sprintf("%s-", name)) {
version := chart.Metadata.Version

// the actual validation occurs here
if strings.ContainsAny(name, "/\\") ||
strings.ContainsAny(version, "/\\") ||
fileBaseName != fmt.Sprintf("%s-%s.tgz", name, version) {

log.Printf("ERROR %s has bad chart name \"%s\"\n", filePath, name)
exitCode = 1
return
}

if debug {
log.Printf("DEBUG %s is valid\n", filePath)
}
Expand Down

0 comments on commit 5a6747a

Please sign in to comment.