Skip to content

Commit

Permalink
fix(helm): fixed helm filepath bug introduced by resolver (#5400)
Browse files Browse the repository at this point in the history
Signed-off-by: João Reigota <[email protected]>
  • Loading branch information
cx-joao-reigota authored May 25, 2022
1 parent 39778e8 commit 3ace1f4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions pkg/detector/helm/helm_detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ func (d DetectKindLine) DetectLine(file *model.FileMetadata, searchKey string,
Line: curLineRes.lineRes + 1,
VulnLines: detector.GetAdjacentVulnLines(curLineRes.lineRes, outputLines, lines),
LineWithVulnerabilty: strings.Split(lines[curLineRes.lineRes], ": ")[0],
ResolvedFile: file.FilePath,
}
}

logWithFields.Warn().Msgf("Failed to detect line, query response %s", searchKey)

return model.VulnerabilityLines{
Line: undetectedVulnerabilityLine,
VulnLines: []model.CodeLine{},
Line: undetectedVulnerabilityLine,
VulnLines: []model.CodeLine{},
ResolvedFile: file.FilePath,
}
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/detector/helm/helm_detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ spec:
},
},
LineWithVulnerabilty: " containers:",
ResolvedFile: "test-connection.yaml",
},
},
{
Expand Down Expand Up @@ -116,6 +117,7 @@ spec:
},
},
LineWithVulnerabilty: "spec:",
ResolvedFile: "test-dup_values.yaml",
},
},
{
Expand Down Expand Up @@ -177,6 +179,7 @@ spec:
},
},
LineWithVulnerabilty: " containers:",
ResolvedFile: "test-dups.yaml",
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/vulnerability_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var DefaultVulnerabilityBuilder = func(ctx *QueryContext, tracker Tracker,

var similarityID *string

similarityID, err = similarity.ComputeSimilarityID(ctx.baseScanPaths, file.FilePath, queryID, similarityIDLineInfo, searchValue)
similarityID, err = similarity.ComputeSimilarityID(ctx.baseScanPaths, linesVulne.ResolvedFile, queryID, similarityIDLineInfo, searchValue)
if err != nil {
logWithFields.Err(err).Send()
tracker.FailedComputeSimilarityID()
Expand Down

0 comments on commit 3ace1f4

Please sign in to comment.