Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Feb 14, 2024
1 parent 06871e4 commit e96689e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
17 changes: 9 additions & 8 deletions commands/audit/sca/pnpm/pnpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/jfrog/gofrog/datastructures"
"github.com/jfrog/gofrog/io"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"golang.org/x/exp/maps"

"github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
Expand Down Expand Up @@ -113,14 +114,14 @@ func parsePnpmLSContent(projectInfo []pnpmLsProject) (dependencyTrees []*xrayUti
dependencyTree, uniqueProjectDeps := coreXray.BuildXrayDependencyTree(createProjectDependenciesTree(project), getDependencyId(project.Name, project.Version))
// Add results
dependencyTrees = append(dependencyTrees, dependencyTree)
uniqueDepsSet.AddElements(uniqueProjectDeps...)
uniqueDepsSet.AddElements(maps.Keys(uniqueProjectDeps)...)
}
uniqueDeps = uniqueDepsSet.ToSlice()
return
}

func createProjectDependenciesTree(project pnpmLsProject) map[string][]string {
treeMap := make(map[string][]string)
func createProjectDependenciesTree(project pnpmLsProject) map[string]coreXray.DepTreeNode {
treeMap := make(map[string]coreXray.DepTreeNode)
directDependencies := []string{}
// Handle production-dependencies
for depName, dependency := range project.Dependencies {
Expand All @@ -135,7 +136,7 @@ func createProjectDependenciesTree(project pnpmLsProject) map[string][]string {
appendTransitiveDependencies(directDependency, dependency.Dependencies, treeMap)
}
if len(directDependencies) > 0 {
treeMap[getDependencyId(project.Name, project.Version)] = directDependencies
treeMap[getDependencyId(project.Name, project.Version)] = coreXray.DepTreeNode{Children: directDependencies}
}
return treeMap
}
Expand All @@ -145,13 +146,13 @@ func getDependencyId(depName, version string) string {
return utils.NpmPackageTypeIdentifier + depName + ":" + version
}

func appendTransitiveDependencies(parent string, dependencies map[string]pnpmLsDependency, result map[string][]string) {
func appendTransitiveDependencies(parent string, dependencies map[string]pnpmLsDependency, result map[string]coreXray.DepTreeNode) {
for depName, dependency := range dependencies {
dependencyId := getDependencyId(depName, dependency.Version)
if children, ok := result[parent]; ok {
result[parent] = appendUniqueChild(children, dependencyId)
if node, ok := result[parent]; ok {
node.Children = appendUniqueChild(node.Children, dependencyId)
} else {
result[parent] = []string{dependencyId}
result[parent] = coreXray.DepTreeNode{Children: []string{dependencyId}}
}
appendTransitiveDependencies(dependencyId, dependency.Dependencies, result)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
)

replace github.com/jfrog/jfrog-cli-core/v2 => github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20240211085821-ef4276849d1f
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20240214101912-0c2093e58b65

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go dev
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer5
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20240211085821-ef4276849d1f h1:CEP7i/QHmzNCYmJefxUHgO/3t7nC4ly1ZHm1QoR7Dsk=
github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20240211085821-ef4276849d1f/go.mod h1:+eraSKhahQf7tj09+g3rAA2Z+XPnZGfMc0y8uUDecZw=
github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20240214101912-0c2093e58b65 h1:MGY+ssto3bCqUlsYIlaVGH2UHAD88irdCTz8cn1Akqc=
github.com/attiasas/jfrog-cli-core/v2 v2.0.0-20240214101912-0c2093e58b65/go.mod h1:+eraSKhahQf7tj09+g3rAA2Z+XPnZGfMc0y8uUDecZw=
github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
Expand Down Expand Up @@ -95,8 +95,6 @@ github.com/jfrog/gofrog v1.5.1 h1:2AXL8hHu1jJFMIoCqTp2OyRUfEqEp4nC7J8fwn6KtwE=
github.com/jfrog/gofrog v1.5.1/go.mod h1:SZ1EPJUruxrVGndOzHd+LTiwWYKMlHqhKD+eu+v5Hqg=
github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY=
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240213075115-4bf1fe83505d h1:9efTE8NyZV6XtF9XoGq0g3XiEIYjCPdiHVEanxhhnlk=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20240213075115-4bf1fe83505d/go.mod h1:+eraSKhahQf7tj09+g3rAA2Z+XPnZGfMc0y8uUDecZw=
github.com/jfrog/jfrog-client-go v1.36.1 h1:22Ucy5XdEP1yHEjbN8zOt2dZys5rbwcwhC3l3pcOdf4=
github.com/jfrog/jfrog-client-go v1.36.1/go.mod h1:y1WF6eiZ7V2DortiwjpMEicEH6NIJH+hOXI5QI2W3NU=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
Expand Down

0 comments on commit e96689e

Please sign in to comment.