Skip to content

Commit

Permalink
Adds test to see if Trivy server is alive before sending data
Browse files Browse the repository at this point in the history
  • Loading branch information
bomoko committed Oct 3, 2023
1 parent 63371e3 commit 0ccfca8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/handler/insightsParserFilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ func processSbomInsightsData(h *Messaging, insights InsightsData, v string, apiC
source := fmt.Sprintf("insights:sbom:%s", resource.Service)

// we process the SBOM here
// BMK - this is likely not the appropriate place to call this

if h.ProblemsFromSBOM == true {
err = SbomToProblems(apiClient, h.TrivyServerEndpoint, "/tmp/", environment.Id, "insights-handler", *bom)
isAlive, err := IsTrivyServerIsAlive(h.TrivyServerEndpoint)
if err != nil {
return nil, "", fmt.Errorf("trivy server not alive: %v", err.Error())
}
if isAlive {
err = SbomToProblems(apiClient, h.TrivyServerEndpoint, "/tmp/", environment.Id, "insights-handler", *bom)
}
if err != nil {
return nil, "", err
}
Expand Down

0 comments on commit 0ccfca8

Please sign in to comment.