Skip to content

Commit

Permalink
Adds some general processing
Browse files Browse the repository at this point in the history
  • Loading branch information
bomoko committed Sep 14, 2023
1 parent da9e358 commit 911eded
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: gettestgrype
gettestgrype:
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b ./internal/handler/testassets/bin
.PHONY: gettrivy
gettrivy:
mkdir -p internal/handler/testassets/bin/trivy/ && wget -O - https://github.com/aquasecurity/trivy/releases/download/v0.45.0/trivy_0.45.0_Linux-64bit.tar.gz | tar -zxvf - -C internal/handler/testassets/bin/trivy/


18 changes: 10 additions & 8 deletions internal/handler/insightsParserFilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ func processSbomInsightsData(h *Messaging, insights InsightsData, v string, apiC
}
source := fmt.Sprintf("insights:sbom:%s", resource.Service)

//// Add sbom onto processing queue
//
//SbomQueuePush(sbomQueueItem{
// EnvironmentId: environment.Id,
// Service: "test",
// SBOM: *bom,
//})

//err := SbomToProblems()

// Process SBOM into facts
facts := processFactsFromSBOM(bom.Components, environment.Id, source)

Expand All @@ -75,14 +85,6 @@ func processSbomInsightsData(h *Messaging, insights InsightsData, v string, apiC

log.Printf("Successfully decoded SBOM of image %s with %s, found %d for '%s:%s'", bom.Metadata.Component.Name, (*bom.Metadata.Tools)[0].Name, len(*bom.Components), resource.Project, resource.Environment)

// Add sbom onto processing queue

SbomQueuePush(sbomQueueItem{
EnvironmentId: environment.Id,
Service: "test",
SBOM: *bom,
})

return facts, source, nil
}

Expand Down
21 changes: 21 additions & 0 deletions internal/handler/trivyProcessing.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ func sbomQueuePop() *sbomQueueItem {
return nil
}

func SbomToProblems(trivyRemoteAddress string, bomWriteDirectory string, environmentId int, service string, sbom cyclonedx.BOM) error {
rep, err := executeProcessingTrivy(trivyRemoteAddress, bomWriteDirectory, sbom)
if err != nil {
return err
}

problems, err := trivyReportToProblems(environmentId, problemSource, service, rep)

if err != nil {
return err
}

err = writeProblemsArrayToApi(environmentId, problemSource, service, problems)

if err != nil {
return err
}

return nil
}

func processQueue() {
for {
i := sbomQueuePop()
Expand Down

0 comments on commit 911eded

Please sign in to comment.