Skip to content

Commit fa846d9

Browse files
authored
Merge pull request #1698 from robnester-rh/EC-1679
Use valid sha256 digest formats in test data
2 parents d8be74d + 6a06aff commit fa846d9

30 files changed

+627
-421
lines changed

policy/lib/konflux/konflux_test.rego

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import data.lib.konflux
77

88
test_is_image_index if {
99
konflux.is_validating_image_index with input.attestations as [_attestation]
10-
with input.image.ref as "registry.local/ham@sha256:fff"
10+
with input.image.ref as "registry.local/ham@sha256:fff0000000000000000000000000000000000000000000000000000000000fff"
1111
}
1212

1313
test_is_image_index_unknown_digest if {
1414
not konflux.is_validating_image_index with input.attestations as [_attestation]
15-
with input.image.ref as "registry.local/ham@sha256:bbb"
15+
with input.image.ref as "registry.local/ham@sha256:bbb0000000000000000000000000000000000000000000000000000000000bbb"
1616
}
1717

1818
test_is_image_index_empty_images if {
@@ -21,7 +21,7 @@ test_is_image_index_empty_images if {
2121
[{"op": "add", "path": "/statement/predicate/buildConfig/tasks/0/results/0/value", "value": ""}],
2222
)
2323
not konflux.is_validating_image_index with input.attestations as [att]
24-
with input.image.ref as "registry.local/ham@sha256:fff"
24+
with input.image.ref as "registry.local/ham@sha256:fff0000000000000000000000000000000000000000000000000000000000fff"
2525
}
2626

2727
_attestation := {"statement": {
@@ -32,7 +32,8 @@ _attestation := {"statement": {
3232
{
3333
"name": "IMAGES",
3434
"type": "string",
35-
"value": "registry.local/spam@sha256:abc, registry.local/bacon@sha256:bcd",
35+
# regal ignore:line-length
36+
"value": "registry.local/spam@sha256:abc0000000000000000000000000000000000000000000000000000000000abc, registry.local/bacon@sha256:bcd0000000000000000000000000000000000000000000000000000000000bcd",
3637
},
3738
{
3839
"name": "IMAGE_URL",
@@ -42,7 +43,7 @@ _attestation := {"statement": {
4243
{
4344
"name": "IMAGE_DIGEST",
4445
"type": "string",
45-
"value": "sha256:fff",
46+
"value": "sha256:fff0000000000000000000000000000000000000000000000000000000000fff",
4647
},
4748
]}]},
4849
},

policy/lib/sbom/sbom.rego

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ image_ref_from_purl(raw_purl) := image_ref if {
120120
# other SPDX creators might reasonably use "pkg:docker/" in the purl.
121121
# purl.type in {"oci", "docker"}
122122

123-
# Example image_digest: "sha256:012abc"
123+
# Example image_digest: "sha256:012abc0000000000000000000000000000000000000000000000000000012abc"
124124
image_digest := purl.version
125125

126126
some qualifier in purl.qualifiers

policy/lib/sbom/sbom_test.rego

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ test_cyclonedx_sboms if {
3030
{
3131
"name": "IMAGE_DIGEST",
3232
"type": "string",
33-
"value": "sha256:284e3029",
33+
"value": "sha256:284e302900000000000000000000000000000000000000000000000284e3029",
3434
},
3535
{
3636
"name": "IMAGE_URL",
@@ -40,7 +40,7 @@ test_cyclonedx_sboms if {
4040
{
4141
"name": "SBOM_BLOB_URL",
4242
"type": "string",
43-
"value": "registry.io/repository/image@sha256:f0cacc1a",
43+
"value": "registry.io/repository/image@sha256:f0cacc1a00000000000000000000000000000000000000000000000f0cacc1a0",
4444
},
4545
]}]},
4646
},
@@ -72,7 +72,7 @@ test_spdx_sboms if {
7272
{
7373
"name": "IMAGE_DIGEST",
7474
"type": "string",
75-
"value": "sha256:284e3029",
75+
"value": "sha256:284e302900000000000000000000000000000000000000000000000284e3029",
7676
},
7777
{
7878
"name": "IMAGE_URL",
@@ -82,7 +82,7 @@ test_spdx_sboms if {
8282
{
8383
"name": "SBOM_BLOB_URL",
8484
"type": "string",
85-
"value": "registry.io/repository/image@sha256:f0cacc1a",
85+
"value": "registry.io/repository/image@sha256:f0cacc1a00000000000000000000000000000000000000000000000f0cacc1a0",
8686
},
8787
]}]},
8888
},
@@ -103,7 +103,7 @@ test_ignore_unrelated_sboms if {
103103
{
104104
"name": "IMAGE_DIGEST",
105105
"type": "string",
106-
"value": "sha256:0000000",
106+
"value": "sha256:0000000000000000000000000000000000000000000000000000000000000000",
107107
},
108108
{
109109
"name": "IMAGE_URL",
@@ -113,7 +113,7 @@ test_ignore_unrelated_sboms if {
113113
{
114114
"name": "SBOM_BLOB_URL",
115115
"type": "string",
116-
"value": "registry.io/repository/image@sha256:f0cacc1a",
116+
"value": "registry.io/repository/image@sha256:f0cacc1a00000000000000000000000000000000000000000000000f0cacc1a0",
117117
},
118118
]}]},
119119
}}},
@@ -123,7 +123,7 @@ test_ignore_unrelated_sboms if {
123123
{
124124
"name": "IMAGE_DIGEST",
125125
"type": "string",
126-
"value": "sha256:1111111",
126+
"value": "sha256:1111111000000000000000000000000000000000000000000000000001111111",
127127
},
128128
{
129129
"name": "IMAGE_URL",
@@ -133,14 +133,15 @@ test_ignore_unrelated_sboms if {
133133
{
134134
"name": "SBOM_BLOB_URL",
135135
"type": "string",
136-
"value": "registry.io/repository/image@sha256:f0cacc1b",
136+
"value": "registry.io/repository/image@sha256:f0cacc1b00000000000000000000000000000000000000000000000f0cacc1b0",
137137
},
138138
]}]},
139139
}}},
140140
]
141141

142142
lib.assert_equal(sbom.all_sboms, []) with input.attestations as attestations
143-
with input.image as {"ref": "registry.io/repository/image@sha256:284e3029"}
143+
# regal ignore:line-length
144+
with input.image as {"ref": "registry.io/repository/image@sha256:284e302900000000000000000000000000000000000000000000000284e3029"}
144145
with ec.oci.blob as ""
145146
with ec.oci.descriptor as {"mediaType": "application/vnd.oci.image.manifest.v1+json"}
146147
}
@@ -159,11 +160,11 @@ mock_ec_oci_cyclonedx_blob := `{"sbom": "from oci blob", "bomFormat": "CycloneDX
159160
mock_ec_oci_spdx_blob := `{"sbom": "from oci blob", "SPDXID": "SPDXRef-DOCUMENT"}`
160161

161162
_cyclonedx_image := {
162-
"ref": "registry.io/repository/image@sha256:284e3029",
163+
"ref": "registry.io/repository/image@sha256:284e302900000000000000000000000000000000000000000000000284e3029",
163164
"config": {"Labels": {"vendor": "Red Hat, Inc."}},
164165
}
165166

166167
_spdx_image := {
167-
"ref": "registry.io/repository/image@sha256:284e3029",
168+
"ref": "registry.io/repository/image@sha256:284e302900000000000000000000000000000000000000000000000284e3029",
168169
"config": {"Labels": {"vendor": "Red Hat, Inc."}},
169170
}

policy/lib/tekton/pipeline_test.rego

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test_pipeline_label_selector_build_task_slsa_v1_0 if {
1212
task_w_labels,
1313
[
1414
{"name": "IMAGE_URL", "value": "localhost:5000/repo:latest"},
15-
{"name": "IMAGE_DIGEST", "value": "sha256:abc"},
15+
{"name": "IMAGE_DIGEST", "value": "sha256:abc0000000000000000000000000000000000000000000000000000000000abc"},
1616
],
1717
)
1818

@@ -30,7 +30,8 @@ test_pipeline_label_selector_build_task_slsa_v0_2 if {
3030
"ref": {"name": "build-container", "kind": "Task"},
3131
"results": [
3232
{"name": "IMAGE_URL", "type": "string", "value": "localhost:5000/repo:latest"},
33-
{"name": "IMAGE_DIGEST", "type": "string", "value": "sha256:abc"},
33+
# regal ignore:line-length
34+
{"name": "IMAGE_DIGEST", "type": "string", "value": "sha256:abc0000000000000000000000000000000000000000000000000000000000abc"},
3435
],
3536
"invocation": {"environment": {"labels": {tekton.task_label: "generic"}}},
3637
}
@@ -64,7 +65,8 @@ test_pipeline_label_selector_pipeline_run_slsa_v0_2 if {
6465
"ref": {"name": "build-container", "kind": "Task"},
6566
"results": [
6667
{"name": "IMAGE_URL", "type": "string", "value": "localhost:5000/repo:latest"},
67-
{"name": "IMAGE_DIGEST", "type": "string", "value": "sha256:abc"},
68+
# regal ignore:line-length
69+
{"name": "IMAGE_DIGEST", "type": "string", "value": "sha256:abc0000000000000000000000000000000000000000000000000000000000abc"},
6870
],
6971
}
7072

policy/lib/tekton/refs_test.rego

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import rego.v1
55
import data.lib
66
import data.lib.tekton
77

8-
_image := "registry.img/test@sha256:digest"
8+
_image := "registry.img/test@sha256:d19e5700000000000000000000000000000000000000000000000000d19e5700"
99

1010
_image_key := "oci://registry.img/test"
1111

12-
_image_digest := "sha256:digest"
12+
_image_digest := "sha256:d19e5700000000000000000000000000000000000000000000000000d19e5700"
1313

1414
_unpinned_image := "registry.img/test:latest"
1515

policy/lib/tekton/task_results_test.rego

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ test_artifact_result if {
5454
test_images_result if {
5555
results := [{
5656
"name": "IMAGES",
57-
"value": "img1@sha256:digest1, img2@sha256:digest2\n",
57+
# regal ignore:line-length
58+
"value": "img1@sha256:d19e5701000000000000000000000000000000000000000000000000d19e5701, img2@sha256:d19e5702000000000000000000000000000000000000000000000000d19e5702\n",
5859
}]
5960
lib.assert_equal(["img1", "img2"], tekton.task_result_artifact_url(resolved_slsav1_task("task1", [], results)))
6061
lib.assert_equal(
61-
["sha256:digest1", "sha256:digest2"],
62+
# regal ignore:line-length
63+
["sha256:d19e5701000000000000000000000000000000000000000000000000d19e5701", "sha256:d19e5702000000000000000000000000000000000000000000000000d19e5702"],
6264
tekton.task_result_artifact_digest(resolved_slsav1_task("task1", [], results)),
6365
)
6466
}
@@ -153,43 +155,46 @@ test_mixed_results if {
153155
},
154156
{
155157
"name": "IMAGES",
156-
"value": "images-1@sha256:4567,images-2@sha256:5678",
158+
# regal ignore:line-length
159+
"value": "images-1@sha256:4567000000000000000000000000000000000000000000000000000000004567,images-2@sha256:5678000000000000000000000000000000000000000000000000000000005678",
157160
},
158161
{
159162
"name": "image1_ARTIFACT_URI",
160163
"value": "image-artifact-1",
161164
},
162165
{
163166
"name": "image1_ARTIFACT_DIGEST",
164-
"value": "sha256:6789",
167+
"value": "sha256:6789000000000000000000000000000000000000000000000000000000006789",
165168
},
166169
{
167170
"name": "image2_ARTIFACT_URI",
168171
"value": "image-artifact-1",
169172
},
170173
{
171174
"name": "image2_ARTIFACT_DIGEST",
172-
"value": "sha256:7890",
175+
"value": "sha256:7890000000000000000000000000000000000000000000000000000000007890",
173176
},
174177
{
175178
"name": "image1_ARTIFACT_OUTPUTS",
176-
"value": {"uri": "artifact-outputs-img1", "digest": "sha256:1234"},
179+
# regal ignore:line-length
180+
"value": {"uri": "artifact-outputs-img1", "digest": "sha256:1234000000000000000000000000000000000000000000000000000000001234"},
177181
},
178182
{
179183
"name": "image2_ARTIFACT_OUTPUTS",
180-
"value": {"uri": "artifact-outputs-img2", "digest": "sha256:9801"},
184+
# regal ignore:line-length
185+
"value": {"uri": "artifact-outputs-img2", "digest": "sha256:9801000000000000000000000000000000000000000000000000000000009801"},
181186
},
182187
]
183188

184189
expected := [
185190
"image-url-img1@2345",
186191
"image-url-img2@3456",
187-
"image-artifact-1@sha256:6789",
188-
"image-artifact-1@sha256:7890",
189-
"images-1@sha256:4567",
190-
"images-2@sha256:5678",
191-
"artifact-outputs-img1@sha256:1234",
192-
"artifact-outputs-img2@sha256:9801",
192+
"image-artifact-1@sha256:6789000000000000000000000000000000000000000000000000000000006789",
193+
"image-artifact-1@sha256:7890000000000000000000000000000000000000000000000000000000007890",
194+
"images-1@sha256:4567000000000000000000000000000000000000000000000000000000004567",
195+
"images-2@sha256:5678000000000000000000000000000000000000000000000000000000005678",
196+
"artifact-outputs-img1@sha256:1234000000000000000000000000000000000000000000000000000000001234",
197+
"artifact-outputs-img2@sha256:9801000000000000000000000000000000000000000000000000000000009801",
193198
]
194199

195200
lib.assert_equal(expected, tekton.images_with_digests([resolved_slsav1_task("task1", [], results)]))

policy/lib/tekton/task_test.rego

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ test_build_task_with_images if {
234234
{
235235
"op": "replace",
236236
"path": "/statement/predicate/buildConfig/tasks/0/results/0/value",
237-
"value": "img1@sha256:digest1, img2@sha256:digest2",
237+
# regal ignore:line-length
238+
"value": "img1@sha256:d19e5701000000000000000000000000000000000000000000000000d19e5701, img2@sha256:d19e5702000000000000000000000000000000000000000000000000d19e5702",
238239
},
239240
{
240241
"op": "remove",
@@ -503,12 +504,14 @@ test_missing_required_tasks_data if {
503504

504505
test_task_step_image_ref if {
505506
lib.assert_equal(
506-
"redhat.io/openshift/rhel8@sha256:af7dd5b3b",
507-
tekton.task_step_image_ref({"name": "mystep", "imageID": "redhat.io/openshift/rhel8@sha256:af7dd5b3b"}),
507+
"redhat.io/openshift/rhel8@sha256:af7dd5b3b0000000000000000000000000000000000000000000000af7dd5b3b",
508+
# regal ignore:line-length
509+
tekton.task_step_image_ref({"name": "mystep", "imageID": "redhat.io/openshift/rhel8@sha256:af7dd5b3b0000000000000000000000000000000000000000000000af7dd5b3b"}),
508510
)
509511
lib.assert_equal(
510-
"redhat.io/openshift/rhel8@sha256:af7dd5b3b",
511-
tekton.task_step_image_ref({"environment": {"image": "redhat.io/openshift/rhel8@sha256:af7dd5b3b"}}),
512+
"redhat.io/openshift/rhel8@sha256:af7dd5b3b0000000000000000000000000000000000000000000000af7dd5b3b",
513+
# regal ignore:line-length
514+
tekton.task_step_image_ref({"environment": {"image": "redhat.io/openshift/rhel8@sha256:af7dd5b3b0000000000000000000000000000000000000000000000af7dd5b3b"}}),
512515
)
513516
}
514517

@@ -733,7 +736,8 @@ with_params(task, task_params) := json.patch(
733736
)
734737

735738
# Helper to set results on an existing task
736-
# Usage: with_results(slsav1_task("build"), [{"name": "IMAGE_DIGEST", "value": "sha256:abc"}])
739+
# regal ignore:line-length
740+
# Usage: with_results(slsav1_task("build"), [{"name": "IMAGE_DIGEST", "value": "sha256:abc0000000000000000000000000000000000000000000000000000000000abc"}])
737741
with_results(task, task_results) := json.patch(
738742
task,
739743
[{"op": "replace", "path": "/status/results", "value": task_results}],
@@ -764,7 +768,8 @@ with_annotations(task, annotations) := json.patch(
764768
)
765769

766770
# Helper to set the bundle reference on an existing task
767-
# Usage: with_bundle(slsav1_task("build"), "quay.io/konflux/task-buildah:0.1@sha256:abc")
771+
# regal ignore:line-length
772+
# Usage: with_bundle(slsav1_task("build"), "quay.io/konflux/task-buildah:0.1@sha256:abc0000000000000000000000000000000000000000000000000000000000abc")
768773
with_bundle(task, bundle) := json.patch(
769774
task,
770775
[{

0 commit comments

Comments
 (0)