kubernetes-sigs / bom

A utility to generate SPDX-compliant Bill of Materials manifests
https://kubernetes-sigs.github.io/bom/
Apache License 2.0
329 stars 48 forks source link

OSInfo: Distroless Scanner #345

Closed puerco closed 12 months ago

puerco commented 12 months ago

What type of PR is this?

/kind bug /kind feature

What this PR does / why we need it:

This PR adds a new OS Info image scanner to support the scanning of images based on distroless.

At this time it will read OS packages from the split dpkg database used by distroless. Support for files could be added later, the test fixtures include file data when we decide to implement it.

The layer scanner now has a function to extract directories from tarballs, I refactored the tar logic to reuse some of the code among the different tar functions.

I'm also adding two bug fixes:

  1. OCI purls were encoded wrong due to a long-running bug in the package URL go package. It should be harmless once a new release is cut.
  2. Fixes a bug in the debian image OS scanner where it would always drop the last package dropped from the database.

All the affected tests are fixed as those bugs modify data expected by the test cases.

Plus: I moved some of the needless verbose messages in the SPDX package to Debug to reduce the verbosity (this is on its own commit so it should be easy to hide when reviewing)

Which issue(s) this PR fixes:

Follow-up to https://github.com/kubernetes-sigs/bom/pull/342

Special notes for your reviewer:

/assign @cpanato @saschagrunert

Does this PR introduce a user-facing change?

- `bom` now supports scanning OS packages from images based on distroless.
- Fixed a bug where `bom` would drop the last package read from the debian database
- Fixed an encoding bug in oci-typed purls where the version had an unescaped colon.
puerco commented 12 months ago

Example generating an SBOM of the kube-apiserver image:

image

puerco commented 12 months ago

After this one merges we should cut a new release

k8s-ci-robot commented 12 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cpanato, puerco

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/bom/blob/main/OWNERS)~~ [cpanato,puerco] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment