Skip to content

Commit 51afa61

Browse files
patrick.rissmann@l3montree.compatrick.rissmann@l3montree.com
authored andcommitted
Now seems to work without problems for all cases
1 parent 461c88c commit 51afa61

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

internal/core/assetversion/asset_version_service.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"log/slog"
66
"math"
7-
"math/rand/v2"
87
"net/http"
98
"strings"
109
"time"
@@ -223,8 +222,8 @@ func (s *service) HandleScanResult(asset models.Asset, assetVersion *models.Asse
223222
func (s *service) handleScanResult(userID string, scannerID string, assetVersion *models.AssetVersion, dependencyVulns []models.DependencyVuln, doRiskManagement bool, asset models.Asset) (int, int, []models.DependencyVuln, error) {
224223
// get all existing dependencyVulns from the database - this is the old state
225224

226-
number := rand.IntN(len(dependencyVulns))
227-
dependencyVulns = dependencyVulns[:number]
225+
//number := rand.IntN(len(dependencyVulns))
226+
//dependencyVulns = dependencyVulns[:0]
228227
scannerID = scannerID + " "
229228
existingDependencyVulns, err := s.dependencyVulnRepository.ListByAssetAndAssetVersion(assetVersion.Name, assetVersion.AssetID)
230229
if err != nil {
@@ -245,8 +244,8 @@ func (s *service) handleScanResult(userID string, scannerID string, assetVersion
245244
foundByScannerAndExisting := comparison.InBoth //We have to check if it was already found by this scanner or only by other scanners
246245
notFoundByScannerAndExisting := comparison.OnlyInA //We have to update all vulnerabilities which were previously found by this scanner and now aren't
247246

248-
var vulnerabilitiesToFix []models.DependencyVuln //We should collect all vulnerabilities we want to fix so we can do it all at once
249-
var vulnerabilitiesToUpdate []models.DependencyVuln
247+
var vulnerabilitiesToFix []models.DependencyVuln //We should collect all vulnerabilities we want to fix so we can do it all at once
248+
var vulnerabilitiesToUpdate []models.DependencyVuln //We should do the same
250249
// get a transaction
251250
if err := s.dependencyVulnRepository.Transaction(func(tx core.DB) error {
252251
// We can create the newly found one without checking anything
@@ -257,12 +256,12 @@ func (s *service) handleScanResult(userID string, scannerID string, assetVersion
257256
// Now we work on the vulnerabilities found in both sets -> has the vulnerability this scanner id already in his scanner_ids
258257
for i := range foundByScannerAndExisting {
259258
if !strings.Contains(foundByScannerAndExisting[i].ScannerID, scannerID) {
260-
fmt.Printf("\nThe Scanner ID before : %s\n", foundByScannerAndExisting[i].ScannerID)
261259
foundByScannerAndExisting[i].ScannerID = foundByScannerAndExisting[i].ScannerID + scannerID
262-
fmt.Printf("\nThe Scanner ID after : %s\n", foundByScannerAndExisting[i].ScannerID)
263260
}
264261
}
262+
265263
err := s.dependencyVulnRepository.SaveBatch(tx, foundByScannerAndExisting)
264+
266265
if err != nil {
267266
slog.Error("error when trying to update vulnerabilities")
268267
return err

internal/core/vulndb/scan/scan_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func DependencyVulnScan(c core.Context, bom normalize.SBOM, s *httpController) (
125125
slog.Error("no scanner id provided")
126126
return scanResults, err
127127
}
128-
//scannerID = ""
128+
//scannerID = "Reboot-Van"
129129
// handle the scan result
130130
amountOpened, amountClose, newState, err := s.assetVersionService.HandleScanResult(asset, &assetVersion, vulns, scannerID, scannerID, userID, doRiskManagement)
131131
if err != nil {

0 commit comments

Comments
 (0)