-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore missing SBOM for Image Indexes
Currently, Konflux does not create an SBOM for Image Indexes: https://issues.redhat.com/browse/KONFLUX-4330 Until then, do not trigger a violation when an SBOM is not found for such images. Today, it's not possible to determine if the image being validated is an Image Index or an Image Manifest, see enterprise-contract/ec-cli#2121. The Image Index detection is done via Konflux-specific heuristics as a workaround. Fixes 1210 Resolves: EC-996 Signed-off-by: Luiz Carvalho <[email protected]>
- Loading branch information
Showing
7 changed files
with
147 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package lib.konflux | ||
|
||
import rego.v1 | ||
|
||
import data.lib | ||
import data.lib.image | ||
import data.lib.tekton | ||
|
||
# Currently, it's not possible to determine if the image being validated is an Image Index or an | ||
# Image Manifest, see https://github.com/enterprise-contract/ec-cli/issues/2121. This function is | ||
# implemented as a workaround. It uses Konflux-specific heuristics to determine if the provided | ||
# image is an Image Index. | ||
is_validating_image_index if { | ||
image_index_digests := {digest | | ||
some attestation in lib.pipelinerun_attestations | ||
some task in tekton.build_tasks(attestation) | ||
|
||
# In Konflux, the Task that creates an Image Index emits the IMAGES result which contains | ||
# all of the related Image Manifests. | ||
count(trim_space(tekton.task_result(task, "IMAGES"))) > 0 | ||
digest := trim_space(tekton.task_result(task, "IMAGE_DIGEST")) | ||
count(digest) > 0 | ||
} | ||
|
||
image.parse(input.image.ref).digest in image_index_digests | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package lib.konflux_test | ||
|
||
import rego.v1 | ||
|
||
import data.lib | ||
import data.lib.konflux | ||
|
||
test_is_image_index if { | ||
konflux.is_validating_image_index with input.attestations as [_attestation] | ||
with input.image.ref as "registry.local/ham@sha256:fff" | ||
} | ||
|
||
test_is_image_index_unknown_digest if { | ||
not konflux.is_validating_image_index with input.attestations as [_attestation] | ||
with input.image.ref as "registry.local/ham@sha256:bbb" | ||
} | ||
|
||
test_is_image_index_empty_images if { | ||
att := json.patch( | ||
_attestation, | ||
[{"op": "add", "path": "/statement/predicate/buildConfig/tasks/0/results/0/value", "value": ""}], | ||
) | ||
not konflux.is_validating_image_index with input.attestations as [att] | ||
with input.image.ref as "registry.local/ham@sha256:fff" | ||
} | ||
|
||
_attestation := {"statement": {"predicate": { | ||
"buildType": lib.tekton_pipeline_run, | ||
"buildConfig": {"tasks": [{"results": [ | ||
{ | ||
"name": "IMAGES", | ||
"type": "string", | ||
"value": "registry.local/spam@sha256:abc, registry.local/bacon@sha256:bcd", | ||
}, | ||
{ | ||
"name": "IMAGE_URL", | ||
"type": "string", | ||
"value": "registry.local/eggs:latest", | ||
}, | ||
{ | ||
"name": "IMAGE_DIGEST", | ||
"type": "string", | ||
"value": "sha256:fff", | ||
}, | ||
]}]}, | ||
}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters