Skip to content

Commit

Permalink
Fix: handle integers for Chart name in Helm parsing (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Rumney authored Jul 17, 2022
1 parent c4160e1 commit 358076a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/scanners/helm/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (p *Parser) extractChartName(chartPath string) error {
if name, ok := chartContent["name"]; !ok {
return fmt.Errorf("could not extract the chart name from %s", chartPath)
} else {
p.helmClient.ReleaseName = name.(string)
p.helmClient.ReleaseName = fmt.Sprintf("%v", name)
}
return nil
}
Expand Down
23 changes: 23 additions & 0 deletions pkg/scanners/helm/test/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ func Test_helm_parser(t *testing.T) {
}
}

func Test_helm_parser_where_name_non_string(t *testing.T) {

tests := []struct {
testName string
chartName string
}{
{
testName: "Scanning chart with integer for name",
chartName: "numberName",
},
}

for _, test := range tests {
chartName := test.chartName

t.Logf("Running test: %s", test.testName)

helmParser := parser.New(chartName)
err := helmParser.ParseFS(context.TODO(), os.DirFS(filepath.Join("testdata", chartName)), ".")
require.NoError(t, err)
}
}

func Test_tar_is_chart(t *testing.T) {

tests := []struct {
Expand Down
3 changes: 3 additions & 0 deletions pkg/scanners/helm/test/testdata/numberName/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
apiVersion: v2
name: 1001
version: 1.0.0

0 comments on commit 358076a

Please sign in to comment.