-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(sbom): duplicate dependson #3261
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,6 +205,7 @@ func (e *Marshaler) marshalComponents(r types.Report, bomRef string) (*[]cdx.Com | |
pkgID := packageID(result.Target, pkg.Name, utils.FormatVersion(pkg), pkg.FilePath) | ||
if _, ok := bomRefMap[pkgID]; !ok { | ||
bomRefMap[pkgID] = pkgComponent.BOMRef | ||
componentDependencies = append(componentDependencies, cdx.Dependency{Ref: pkgComponent.BOMRef}) | ||
} | ||
|
||
// When multiple lock files have the same dependency with the same name and version, | ||
|
@@ -227,8 +228,6 @@ func (e *Marshaler) marshalComponents(r types.Report, bomRef string) (*[]cdx.Com | |
// TODO: All packages are flattened at the moment. We should construct dependency tree. | ||
components = append(components, pkgComponent) | ||
} | ||
|
||
componentDependencies = append(componentDependencies, cdx.Dependency{Ref: pkgComponent.BOMRef}) | ||
} | ||
|
||
for _, vuln := range result.Vulnerabilities { | ||
|
@@ -247,8 +246,8 @@ func (e *Marshaler) marshalComponents(r types.Report, bomRef string) (*[]cdx.Com | |
} | ||
} | ||
|
||
if result.Type == ftypes.NodePkg || result.Type == ftypes.PythonPkg || result.Type == ftypes.GoBinary || | ||
result.Type == ftypes.GemSpec || result.Type == ftypes.Jar || result.Type == ftypes.RustBinary { | ||
if result.Type == ftypes.NodePkg || result.Type == ftypes.PythonPkg || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is the root. We aggregate Go/Rust binaries by mistake. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we no longer aggregating these components with this change, or would this only filter duplicates? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We no longer aggregate dependencies in Go/Rust binaries. It should have been a mistake. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh no. I was relying on this feature in my project. Any ideas for enabling go/rust binary parsing while generating SBoM with the new release? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No problem. This feature modifies packages that depend on binaries so that they are not aggregated. Before. (Aggregate package with the golang)
After (Aggregate package with the package)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We just don't aggregate those dependencies. You are still able to see those packages in SBOM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, @masahiro331 and @knqyf263, for the detailed explanation! |
||
result.Type == ftypes.GemSpec || result.Type == ftypes.Jar { | ||
// If a package is language-specific package that isn't associated with a lock file, | ||
// it will be a dependency of a component under "metadata". | ||
// e.g. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why could it be duplicated?
componentDependencies
is defined pertypes.Result
. The duplicate should not exist inResult.Packages
.