Trivy to recognize system packages listed on multiple SBOMs #8314
juan131
started this conversation in
Development
Replies: 2 comments
-
I did some investigation and adding the debug log below... diff --git a/pkg/fanal/analyzer/sbom/sbom.go b/pkg/fanal/analyzer/sbom/sbom.go
index 20a069d5..3415e14d 100644
--- a/pkg/fanal/analyzer/sbom/sbom.go
+++ b/pkg/fanal/analyzer/sbom/sbom.go
@@ -60,6 +60,17 @@ func (a sbomAnalyzer) Analyze(ctx context.Context, input analyzer.AnalysisInput)
}
}
+ log.Debugf("There are %d OS packages in the %s SBOM", len(bom.Packages), input.FilePath)
+ for i, osPkg := range bom.Packages {
+ for j, pkg := range osPkg.Packages {
+ log.DebugContext(ctx, "OS package contains package",
+ log.String("pkg_name", pkg.Name),
+ log.String("pkg_version", pkg.Version),
+ log.String("pkg_path", pkg.FilePath))
+ bom.Packages[i].Packages[j].FilePath = input.FilePath
+ }
+ }
+
return &analyzer.AnalysisResult{
PackageInfos: bom.Packages,
Applications: bom.Applications, ... we can see that Trivy is detecting every SBOM file: $ trivy --debug image docker.io/juanariza131/static:multispdx
(...)
DEBUG There are 1 OS packages in the opt/bitnami/debian/.spdx-ca-certificates.spdx SBOM
DEBUG OS package contains package file_path="opt/bitnami/debian/.spdx-ca-certificates.spdx" pkg_name="ca-certificates" pkg_version="20230311" pkg_path=""
DEBUG There are 1 OS packages in the opt/bitnami/debian/.spdx-tzdata.spdx SBOM
DEBUG OS package contains package file_path="opt/bitnami/debian/.spdx-tzdata.spdx" pkg_name="tzdata" pkg_version="2024b-0+deb12u1" pkg_path=""
DEBUG There are 1 OS packages in the opt/bitnami/debian/.spdx-netbase.spdx SBOM
DEBUG OS package contains package file_path="opt/bitnami/debian/.spdx-netbase.spdx" pkg_name="netbase" pkg_version="6.4" pkg_path=""
(...) But it seems that later on the duplicate filter or sth like that is discarding all but one of them. |
Beta Was this translation helpful? Give feedback.
0 replies
-
cc @knqyf263 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
At Bitnami we're working on new "minimal containers" (similar to distroless concept) that can be serve as base images for developer that wants minimal runtime dependencies. As we do for the rest of Bitnami images, we're including SBOM on the images that we generate at build time. Here you have a simplified version of how we build
bitnami/static
(an image designed to be used as base image for statically compiled applications):install-trivy.sh
installs latest trivy version.prepare-rootfs.sh
copies to/rootfs
the directories & files that will be part of the final image. Some examples are:/etc/debian_version
,/etc/localtime
,/etc/ssl/certs/ca-certificates.crt
,/usr/share/zoneinfo
, etc.generate-spdx.sh
generates the/opt/bitnami/debian/.spdx-debian.spdx
file below:I also published the image in my local DockerHub in case you want to try it:
docker.io/juanariza131/static:latest
. You can run the command below to see that everything works as expected:Our issue comes when we generate N SPDX files (N>1) because we split the build process on several steps. I published another image (
docker.io/juanariza131/static:multispdx
) that has 3 SPDX files under/opt/bitnami/debian
:.spdx-ca-certificates.spdx
:.spdx-netbase.spdx
:.spdx-tzdata.spdx
:If we run the same command:
You'll find out that only the
tzdata
package is listed (netbase
andca-certificates
are filtered out)Beta Was this translation helpful? Give feedback.
All reactions