Skip to content
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

Improve generation of base images SBOMs #191

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

mkosiarc
Copy link
Contributor

The process how the base image SBOM is generated was slightly changed.

The most important change is due to requiring different inputs. The script now requires the full json of parsed Dockerfile, so we can extract the base images better. This allows us to extract base images data even for stage aliases.

Another advantage is that we are counting
the stages/layers more carefully, because we have more information about which stage was from scratch or from oci-archive.

KFLUXBUGS-1718

@mkosiarc mkosiarc force-pushed the parse-base-images-from-json branch 2 times, most recently from 307dab0 to 16c1454 Compare November 28, 2024 09:11
mkosiarc added a commit to mkosiarc/build-definitions that referenced this pull request Nov 28, 2024
most functional changes are in the related PR that updates the
base_images_sbom_script.py
konflux-ci/build-tasks-dockerfiles#191

Here, we are just updating on how we generate the inputs for this
script.
We are now passing the whole parsed Dockerfile in json format to that
script, which allows us to better parse/detect base images.

Also, the format of the /shared/base_images_digests file was changed.
Previously we could rely on the order of the image references with the
digests in the file. Now we need to provide a mapping from an image
reference as it was used in the Dockerfile to the full image reference
with digests that was used during build and generated by buildah.

The mapping is done as:
<image-reference-used-in-dockerfile>|<full-image-reference-with-digest>

The character that creates the mapping "|" was chosen arbitrarily, just
because it cannot be a valid part of image reference.

KFLUXBUGS-1718

Signed-off-by: mkosiarc <[email protected]>
mkosiarc added a commit to mkosiarc/build-definitions that referenced this pull request Nov 28, 2024
most functional changes are in the related PR that updates the
base_images_sbom_script.py
konflux-ci/build-tasks-dockerfiles#191

Here, we are just updating on how we generate the inputs for this
script.
We are now passing the whole parsed Dockerfile in json format to that
script, which allows us to better parse/detect base images.

Also, the format of the /shared/base_images_digests file was changed.
Previously we could rely on the order of the image references with the
digests in the file. Now we need to provide a mapping from an image
reference as it was used in the Dockerfile to the full image reference
with digests that was used during build and generated by buildah.

The mapping is done as:
<image-reference-used-in-dockerfile>|<full-image-reference-with-digest>

The character that creates the mapping "|" was chosen arbitrarily, just
because it cannot be a valid part of image reference.

KFLUXBUGS-1718

Signed-off-by: mkosiarc <[email protected]>
mkosiarc added a commit to mkosiarc/build-definitions that referenced this pull request Nov 28, 2024
most functional changes are in the related PR that updates the
base_images_sbom_script.py
konflux-ci/build-tasks-dockerfiles#191

Here, we are just updating on how we generate the inputs for this
script.
We are now passing the whole parsed Dockerfile in json format to that
script, which allows us to better parse/detect base images.

Also, the format of the /shared/base_images_digests file was changed.
Previously we could rely on the order of the image references with the
digests in the file. Now we need to provide a mapping from an image
reference as it was used in the Dockerfile to the full image reference
with digests that was used during build and generated by buildah.

The mapping is done as:
<image-reference-used-in-dockerfile>|<full-image-reference-with-digest>

The character that creates the mapping "|" was chosen arbitrarily, just
because it cannot be a valid part of image reference.

KFLUXBUGS-1718

Signed-off-by: mkosiarc <[email protected]>
@mkosiarc mkosiarc force-pushed the parse-base-images-from-json branch 3 times, most recently from 53b524a to 832c174 Compare November 28, 2024 11:34
@mkosiarc mkosiarc requested a review from chmeliik November 28, 2024 11:35
@mkosiarc mkosiarc force-pushed the parse-base-images-from-json branch 2 times, most recently from e04ae40 to 2177875 Compare December 4, 2024 11:39
@mkosiarc
Copy link
Contributor Author

mkosiarc commented Dec 4, 2024

switched to using empty space, instead of "|" as discussed in konflux-ci/build-definitions#1659

Copy link
Contributor

@chmeliik chmeliik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one nitpick

mkosiarc added a commit to mkosiarc/build-definitions that referenced this pull request Dec 4, 2024
most functional changes are in the related PR that updates the
base_images_sbom_script.py
konflux-ci/build-tasks-dockerfiles#191

Here, we are just updating on how we generate the inputs for this
script.
We are now passing the whole parsed Dockerfile in json format to that
script, which allows us to better parse/detect base images.

Also, the format of the /shared/base_images_digests file was changed.
Previously we could rely on the order of the image references with the
digests in the file. Now we need to provide a mapping from an image
reference as it was used in the Dockerfile to the full image reference
with digests that was used during build and generated by buildah.

The mapping is done as:
<image-reference-used-in-dockerfile> <full-image-reference-with-digest>

KFLUXBUGS-1718

Signed-off-by: mkosiarc <[email protected]>
mkosiarc added a commit to mkosiarc/build-definitions that referenced this pull request Dec 4, 2024
most functional changes are in the related PR that updates the
base_images_sbom_script.py
konflux-ci/build-tasks-dockerfiles#191

Here, we are just updating on how we generate the inputs for this
script.
We are now passing the whole parsed Dockerfile in json format to that
script, which allows us to better parse/detect base images.

Also, the format of the /shared/base_images_digests file was changed.
Previously we could rely on the order of the image references with the
digests in the file. Now we need to provide a mapping from an image
reference as it was used in the Dockerfile to the full image reference
with digests that was used during build and generated by buildah.

The mapping is done as:
<image-reference-used-in-dockerfile> <full-image-reference-with-digest>

KFLUXBUGS-1718

Signed-off-by: mkosiarc <[email protected]>
The process how the base image SBOM is generated was slightly changed.

The most important change is due to requiring different inputs. The
script now requires the full json of parsed Dockerfile, so we can
extract the base images better. This allows us to extract base images
data even for stage aliases.

Another advantage is that we are counting
the stages/layers more carefully, because we have more information about
which stage was from scratch or from oci-archive.

KFLUXBUGS-1718

Signed-off-by: mkosiarc <[email protected]>
@mkosiarc mkosiarc force-pushed the parse-base-images-from-json branch from 2177875 to 16f74d5 Compare December 4, 2024 11:49
mkosiarc added a commit to mkosiarc/build-definitions that referenced this pull request Dec 4, 2024
most functional changes are in the related PR that updates the
base_images_sbom_script.py
konflux-ci/build-tasks-dockerfiles#191

Here, we are just updating on how we generate the inputs for this
script.
We are now passing the whole parsed Dockerfile in json format to that
script, which allows us to better parse/detect base images.

Also, the format of the /shared/base_images_digests file was changed.
Previously we could rely on the order of the image references with the
digests in the file. Now we need to provide a mapping from an image
reference as it was used in the Dockerfile to the full image reference
with digests that was used during build and generated by buildah.

The mapping is done as:
<image-reference-used-in-dockerfile> <full-image-reference-with-digest>

KFLUXBUGS-1718

Signed-off-by: mkosiarc <[email protected]>
@mkosiarc mkosiarc requested a review from tkdchen December 5, 2024 09:36
@mkosiarc mkosiarc merged commit ff9679c into konflux-ci:main Dec 9, 2024
1 check passed
mkosiarc added a commit to mkosiarc/build-definitions that referenced this pull request Dec 9, 2024
most functional changes are in the related PR that updates the
base_images_sbom_script.py
konflux-ci/build-tasks-dockerfiles#191

Here, we are just updating on how we generate the inputs for this
script.
We are now passing the whole parsed Dockerfile in json format to that
script, which allows us to better parse/detect base images.

Also, the format of the /shared/base_images_digests file was changed.
Previously we could rely on the order of the image references with the
digests in the file. Now we need to provide a mapping from an image
reference as it was used in the Dockerfile to the full image reference
with digests that was used during build and generated by buildah.

The mapping is done as:
<image-reference-used-in-dockerfile> <full-image-reference-with-digest>

KFLUXBUGS-1718

Signed-off-by: mkosiarc <[email protected]>
mkosiarc added a commit to mkosiarc/build-definitions that referenced this pull request Dec 9, 2024
most functional changes are in the related PR that updates the
base_images_sbom_script.py
konflux-ci/build-tasks-dockerfiles#191

Here, we are just updating on how we generate the inputs for this
script.
We are now passing the whole parsed Dockerfile in json format to that
script, which allows us to better parse/detect base images.

Also, the format of the /shared/base_images_digests file was changed.
Previously we could rely on the order of the image references with the
digests in the file. Now we need to provide a mapping from an image
reference as it was used in the Dockerfile to the full image reference
with digests that was used during build and generated by buildah.

The mapping is done as:
<image-reference-used-in-dockerfile> <full-image-reference-with-digest>

Also, the sbom utility image has to be updated together in the same
PR/commit, otherwise it would break konflux temporarily

KFLUXBUGS-1718

Signed-off-by: mkosiarc <[email protected]>
github-merge-queue bot pushed a commit to konflux-ci/build-definitions that referenced this pull request Dec 9, 2024
most functional changes are in the related PR that updates the
base_images_sbom_script.py
konflux-ci/build-tasks-dockerfiles#191

Here, we are just updating on how we generate the inputs for this
script.
We are now passing the whole parsed Dockerfile in json format to that
script, which allows us to better parse/detect base images.

Also, the format of the /shared/base_images_digests file was changed.
Previously we could rely on the order of the image references with the
digests in the file. Now we need to provide a mapping from an image
reference as it was used in the Dockerfile to the full image reference
with digests that was used during build and generated by buildah.

The mapping is done as:
<image-reference-used-in-dockerfile> <full-image-reference-with-digest>

Also, the sbom utility image has to be updated together in the same
PR/commit, otherwise it would break konflux temporarily

KFLUXBUGS-1718

Signed-off-by: mkosiarc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants