Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: nathannaveen <[email protected]>
  • Loading branch information
nathannaveen committed Jul 18, 2024
1 parent 94b837d commit 3fe1418
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions pkg/guacanalytics/searchForSBOM.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/Khan/genqlient/graphql"
model "github.com/guacsec/guac/pkg/assembler/clients/generated"
"github.com/guacsec/guac/pkg/assembler/helpers"
"github.com/guacsec/guac/pkg/dependencies"
"github.com/jedib0t/go-pretty/v6/table"
"strings"
)
Expand Down Expand Up @@ -117,36 +116,42 @@ func SearchForSBOMViaPkg(ctx context.Context, gqlclient graphql.Client, searchSt
if isDep.DependencyPackage.Type == guacType {
continue
}
var matchingDepPkgVersionIDs []string
if len(isDep.DependencyPackage.Namespaces[0].Names[0].Versions) == 0 {
findMatchingDepPkgVersionIDs, err := dependencies.FindDepPkgVersionIDs(ctx, gqlclient, isDep.DependencyPackage.Type, isDep.DependencyPackage.Namespaces[0].Namespace,
isDep.DependencyPackage.Namespaces[0].Names[0].Name, isDep.VersionRange)
if err != nil {
return nil, nil, fmt.Errorf("error from FindMatchingDepPkgVersionIDs:%w", err)
depPkgID := isDep.DependencyPackage.Namespaces[0].Names[0].Versions[0].Id
dfsN, seen := nodeMap[depPkgID]
if !seen {
dfsN = dfsNode{
parent: now,
pkgID: depPkgID,
depth: nowNode.depth + 1,
}
matchingDepPkgVersionIDs = append(matchingDepPkgVersionIDs, findMatchingDepPkgVersionIDs...)
} else {
matchingDepPkgVersionIDs = append(matchingDepPkgVersionIDs, isDep.DependencyPackage.Namespaces[0].Names[0].Versions[0].Id)
nodeMap[depPkgID] = dfsN
}
for _, pkgID := range matchingDepPkgVersionIDs {
dfsN, seen := nodeMap[pkgID]
if !seen {
dfsN = dfsNode{
parent: now,
pkgID: pkgID,
depth: nowNode.depth + 1,
}
nodeMap[pkgID] = dfsN
}
if !dfsN.expanded {
queue = append(queue, pkgID)
}
pkgVersionNeighbors, err := getVulnAndVexNeighborsForPackage(ctx, gqlclient, pkgID, isDep)
if err != nil {
return nil, nil, fmt.Errorf("getVulnAndVexNeighborsForPackage failed with error: %w", err)
if !dfsN.expanded {
queue = append(queue, depPkgID)
}
pkgVersionNeighbors, err := getVulnAndVexNeighborsForPackage(ctx, gqlclient, depPkgID, isDep)
if err != nil {
return nil, nil, fmt.Errorf("getVulnAndVexNeighbors failed with error: %w", err)
}
collectedPkgVersionResults = append(collectedPkgVersionResults, pkgVersionNeighbors)
checkedPkgIDs[depPkgID] = true

}

for _, isDep := range hasSBOM.IncludedDependencies {
if isDep.DependencyPackage.Type == guacType {
continue
}

depPkgID := isDep.DependencyPackage.Namespaces[0].Names[0].Versions[0].Id
dfsN, seen := nodeMap[depPkgID]

Check failure on line 147 in pkg/guacanalytics/searchForSBOM.go

View workflow job for this annotation

GitHub Actions / Lint

ineffectual assignment to dfsN (ineffassign)
if !seen {
dfsN = dfsNode{
parent: now,
pkgID: depPkgID,
depth: nowNode.depth + 1,
}
collectedPkgVersionResults = append(collectedPkgVersionResults, pkgVersionNeighbors)
checkedPkgIDs[pkgID] = true
nodeMap[depPkgID] = dfsN
}
}
}
Expand Down

0 comments on commit 3fe1418

Please sign in to comment.