Skip to content

Commit

Permalink
add only uniq deps in dependsOn (aquasecurity#4943)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen authored Aug 6, 2023
1 parent b544e0d commit a796701
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 73 deletions.
8 changes: 6 additions & 2 deletions pkg/fanal/analyzer/pkg/dpkg/dpkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
debVersion "github.com/knqyf263/go-deb-version"
"github.com/samber/lo"
"go.uber.org/zap"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"

dio "github.com/aquasecurity/go-dep-parser/pkg/io"
Expand Down Expand Up @@ -294,8 +295,11 @@ func (a dpkgAnalyzer) parseDepends(s string) []string {
for _, d := range strings.Split(dep, "|") {
d = a.trimVersionRequirement(d)

// Store only package names here
dependencies = append(dependencies, strings.TrimSpace(d))
// Store only uniq package names here
d = strings.TrimSpace(d)
if !slices.Contains(dependencies, d) {
dependencies = append(dependencies, d)
}
}
}
return dependencies
Expand Down
Loading

0 comments on commit a796701

Please sign in to comment.