-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add build image support to add_image_reference #254
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Julen Landa Alustiza <[email protected]>
4ceb6bb
to
7823c07
Compare
Signed-off-by: Julen Landa Alustiza <[email protected]>
Signed-off-by: Julen Landa Alustiza <[email protected]>
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.
Could you please make PR description explaining the changes, what how and why was done?
sbom-utility-scripts/scripts/add-image-reference-script/add_image_reference.py
Outdated
Show resolved
Hide resolved
sbom-utility-scripts/scripts/add-image-reference-script/add_image_reference.py
Show resolved
Hide resolved
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.
I'm not a direct maintainer of this script, but from my understanding, the add_image_reference
script is currently meant for adding the output image to the SBOM, so the proposed change is stretching its goal and recontextualizing it a bit.
I don't think this is a bad choice, though, since the alternative would be to add it to the base_images_sbom_script
, which only works by parsing the Containerfile and getting the base images from it. Trying to incorporate these changes to base_images_sbom_script
would result in much bigger changes, and I don't see how to do it smoothly.
So I think that your approach is probably the best one, but we'll need to change the README to recontextualize the add_image_reference
script's goal and document the new behavior.
sbom-utility-scripts/scripts/add-image-reference-script/add_image_reference.py
Outdated
Show resolved
Hide resolved
# Add base image property to image_component | ||
image_component["properties"]: [{ | ||
"name": "konflux:container:is_builder_image:for_stage", | ||
"value": "1", |
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.
I think hardcoding this as 1 wouldn't be correct, since this can be added to an image that already has several konflux:container:is_builder_image:for_stage
, and potentially have one that is already stage 1. Maybe we'll need to increment this accordingly?
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.
Yeah. A hardcoded 1 is wrong. the discussion about the property will condition what we do here :)
#254 (comment)
I was also wondering if it could be confusing to a user when he inspects the SBOM and finds an additional builder image that is not part of the Containerfile. I imagine that the fact that it is coming from an image used in a specific pipeline task would not be immediately obvious. That being said, I don't think that SPDX or CycloneDX have any standard means of dealing with "additional images that were used as part of the build pipeline", so probably adding it as a builder image makes the most sense. It'd be nice if we could figure out any additional info that can be added to the SBOM to make this property meaning's clearer. The only thing that comes to mind is to add the name of the task instead of a integer as value for |
This is a great appreciation, and I wondered the same thing :) This image is not really part of the multi stage dockerfile, so for_stage and an integer does not codify properly what this image was used for. I don't have enough knowledge around sbom formats to make a decision here either :)
I need some help to answer those questions and make a decision here :) |
I believe we can. These
Yes, the value field type is string (CycloneDx docs). As for SPDX, things are a little different. We tend to simply covert the CycloneDX into annotations, but if you look at the |
Since they are defined by us, it would make more sense to not use Something like |
This is great info. I miss something similar to https://github.com/konflux-ci/build-tasks-dockerfiles/blob/main/sbom-utility-scripts/scripts/base-images-sbom-script/app/base_images_sbom_script.py#L201 then for the spdx, at least the annotation part :) |
Signed-off-by: Julen Landa Alustiza <[email protected]>
/ok-to-test |
Naming things is always hard 😓 I still like For SPDX, I like |
Signed-off-by: Julen Landa Alustiza <[email protected]>
Signed-off-by: Julen Landa Alustiza <[email protected]>
Signed-off-by: Julen Landa Alustiza <[email protected]>
cdb8c47
to
e7e488f
Compare
Haha, just finished implementation and tests without this. Will update after lunch |
Signed-off-by: Julen Landa Alustiza <[email protected]>
@brunoapimentel changed the annotation name/value. wdyt now? Ready to start updating docstrings and the README ? |
It's fine by me. Any more considerations, @mmorhun? |
The intent of this PR is to extend the funcionality of
add_image_reference.py
script to be able to inject build image references when the script is called with--build-image
flag.This is useful for konflux-ci/build-definitions#2044 to be able to inject the image that was used to run the script as part of the build images on the final sbom.
The script's default functionality continues being the same when is executed without
--build-image
.Calling it with the new flag will change the functionality to:
properties
block to the package injected on the sbom. The resultant package will be something like this:For cyclone format:
metadata[component]
blockformulation
section instead ofcomponents
sectionFor SPDX format:
BUILD_TOOL_OF
relationship with the root package.These changes are following the same format
base-images-sbom-script
uses to inject the base images coming from the Containerfile.The main reason to colocate the functionality here and not on
base-images-sbom-script
is that thebase-images-sbom-script
logic is dependant on the content of the Dockerfile to inject the images. The changes the script would need to add arbitrary new build images that are not present on the Dockerfile would be big. Meanwhile the changes to repurpose this script to handle the original case and the new case are much smaller. An independent new script would be an option too, but the overlap of the code betweenadd_image_reference
and the new script would be huge.TODO