Skip to content

Commit ff82142

Browse files
committed
Fix step_images.step_images_accessible check
Although the implementation of ec.oci.image_manifest does return nil if the Image Manifest is not found, rego converts that to no value at all. Thus, asserting that the returned value is nil will never be true causing this policy rule to always pass. This commit changes the rule evaluation to check for the lack of a value instead. Signed-off-by: Luiz Carvalho <[email protected]>
1 parent 158a985 commit ff82142

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

antora/docs/modules/ROOT/pages/task_policy.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Confirm that each step in the Task uses a container image that is accessible.
2121
* Rule type: [rule-type-indicator failure]#FAILURE#
2222
* FAILURE message: `Step %d uses inaccessible image ref '%s'`
2323
* Code: `step_images.step_images_accessible`
24+
* Effective from: `2025-01-10T00:00:00Z`
2425
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/task/step_images/step_images.rego#L14[Source, window="_blank"]
2526
2627
[#step_image_registries_package]

policy/task/step_images/step_images.rego

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ import data.lib
2121
# solution: >-
2222
# Make sure the container image used in each step of the Task is pushed to the
2323
# registry and that it can be fetched.
24+
# effective_on: 2025-01-10T00:00:00Z
2425
#
2526
deny contains result if {
2627
input.kind == "Task"
2728

2829
some step_index, step in input.spec.steps
2930
image_ref := step.image
30-
is_null(ec.oci.image_manifest(image_ref))
31+
not ec.oci.image_manifest(image_ref)
3132

3233
result := lib.result_helper_with_term(
3334
rego.metadata.chain(),

policy/task/step_images/step_images_test.rego

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ test_task_with_invalid_steps if {
6565
mock_image_manifest(ref) := m if {
6666
startswith(ref, "registry.io/repository/ok")
6767
m := {}
68-
} else := null
68+
}

0 commit comments

Comments
 (0)