Skip to content

Commit 4bfe04a

Browse files
authored
Merge pull request #1236 from simonbaird/rhtap-multi-ci-improvements
More code reuse for RHTAP Multi-CI rego
2 parents 567c9f5 + b3ddaa6 commit 4bfe04a

File tree

12 files changed

+235
-361
lines changed

12 files changed

+235
-361
lines changed

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

Lines changed: 20 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ a| A set of policy rules to validate artifacts built using RHTAP Jenkins pipelin
211211

212212
Rules included:
213213

214-
* xref:release_policy.adoc#rhtap_jenkins__invocation_id_found[RHTAP Jenkins: RHTAP Jenkins SLSA Invocation ID present]
215-
* xref:release_policy.adoc#rhtap_jenkins__attestation_found[RHTAP Jenkins: RHTAP Jenkins SLSA Provenance Attestation Found]
214+
* xref:release_policy.adoc#rhtap_multi_ci__attestation_format[RHTAP Multi-CI: SLSA Provenance Attestation Format]
215+
* xref:release_policy.adoc#rhtap_multi_ci__attestation_found[RHTAP Multi-CI: SLSA Provenance Attestation Found]
216216

217217
| [#slsa3]`slsa3`
218218
a| Includes policy rules required to meet SLSA Level 3.
@@ -959,74 +959,36 @@ Check the image metadata for the presence of a "quay.expires-after" label. If it
959959
* Code: `quay_expiration.expires_label`
960960
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/quay_expiration/quay_expiration.rego#L16[Source, window="_blank"]
961961

962-
[#rhtap_github_package]
963-
== link:#rhtap_github_package[RHTAP GitHub]
962+
[#rhtap_multi_ci_package]
963+
== link:#rhtap_multi_ci_package[RHTAP Multi-CI]
964964

965-
Some initial checks for images built using an RHTAP GitHub build pipeline. Note that the RHTAP GitHub pipeline is WIP currently, but will be shipped in an upcoming release of RHTAP. It's expected more useful checks will be added in future. RHTAP GitHub pipelines are defined under https://github.com/redhat-appstudio/tssc-sample-templates/tree/main/skeleton/ci
965+
Checks for images built using an RHTAP build pipeline in either Jenkins, GitLab or GitHub. RHTAP pipelines are defined under https://github.com/redhat-appstudio/tssc-sample-templates/tree/main/skeleton/ci
966966

967-
* Package name: `rhtap_github`
967+
* Package name: `rhtap_multi_ci`
968968

969-
[#rhtap_github__attestation_found]
970-
=== link:#rhtap_github__attestation_found[RHTAP GitHub SLSA Provenance Attestation Found]
969+
[#rhtap_multi_ci__attestation_format]
970+
=== link:#rhtap_multi_ci__attestation_format[SLSA Provenance Attestation Format]
971971

972-
Verify an attestation created by the RHTAP GitHub build pipeline is present.
972+
Confirm the attestation created by the RHTAP Multi-CI build pipeline matches the expected format.
973973

974-
*Solution*: It appears the build pipeline did not create a SLSA provenance attestation. Check the logs in GitHub for the cosign-sign-attest stage to see if you can find out why.
974+
*Solution*: This check looks for some fields expected to be present in the SLSA attestation. Modifying the scripts that produce the attestation predicate might cause this to fail. See also the `att-predicate-*.sh` scripts at https://github.com/redhat-appstudio/tssc-dev-multi-ci/tree/main/rhtap
975975

976976
* Rule type: [rule-type-indicator failure]#FAILURE#
977-
* FAILURE message: `The expected SLSA v1.0 provenance with build type %s was not found.`
978-
* Code: `rhtap_github.attestation_found`
979-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/rhtap_github/rhtap_github.rego#L17[Source, window="_blank"]
977+
* FAILURE message: `RHTAP %s attestation problem: %s`
978+
* Code: `rhtap_multi_ci.attestation_format`
979+
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/rhtap_multi_ci/rhtap_multi_ci.rego#L40[Source, window="_blank"]
980980

981-
[#rhtap_gitlab_package]
982-
== link:#rhtap_gitlab_package[RHTAP GitLab]
981+
[#rhtap_multi_ci__attestation_found]
982+
=== link:#rhtap_multi_ci__attestation_found[SLSA Provenance Attestation Found]
983983

984-
Some initial checks for images built using an RHTAP GitLab build pipeline. Note that the RHTAP GitLab pipeline is WIP currently, but will be shipped in an upcoming release of RHTAP. It's expected more useful checks will be added in future. RHTAP GitLab pipelines are defined under https://github.com/redhat-appstudio/tssc-sample-templates/tree/main/skeleton/ci
984+
Verify an attestation created by the RHTAP Multi-CI build pipeline is present.
985985

986-
* Package name: `rhtap_gitlab`
987-
988-
[#rhtap_gitlab__attestation_found]
989-
=== link:#rhtap_gitlab__attestation_found[RHTAP GitLab SLSA Provenance Attestation Found]
990-
991-
Verify an attestation created by the RHTAP GitLab build pipeline is present.
992-
993-
*Solution*: It appears the build pipeline did not create a SLSA provenance attestation. Check the logs in GitLab for the cosign-sign-attest stage to see if you can find out why.
994-
995-
* Rule type: [rule-type-indicator failure]#FAILURE#
996-
* FAILURE message: `The expected SLSA v1.0 provenance with build type %s was not found.`
997-
* Code: `rhtap_gitlab.attestation_found`
998-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/rhtap_gitlab/rhtap_gitlab.rego#L17[Source, window="_blank"]
999-
1000-
[#rhtap_jenkins_package]
1001-
== link:#rhtap_jenkins_package[RHTAP Jenkins]
1002-
1003-
Some initial checks for images built using an RHTAP Jenkins build pipeline. Note that the RHTAP Jenkins pipeline is WIP currently, but will be shipped in an upcoming release of RHTAP. It's expected more useful checks will be added in future. RHTAP Jenkins pipelines are defined under https://github.com/redhat-appstudio/tssc-sample-templates/tree/main/skeleton/ci
1004-
1005-
* Package name: `rhtap_jenkins`
1006-
1007-
[#rhtap_jenkins__invocation_id_found]
1008-
=== link:#rhtap_jenkins__invocation_id_found[RHTAP Jenkins SLSA Invocation ID present]
1009-
1010-
Confirm that an invocation ID was found in the attestation in the expected location.
1011-
1012-
*Solution*: For some reason the invocation id was missing or empty in the build provenance. It should be located at `predicate.runDetails.metadata.invocationID` in the attestation statement.
1013-
1014-
* Rule type: [rule-type-indicator failure]#FAILURE#
1015-
* FAILURE message: `The build provenance metadata did not contain an invocation id.`
1016-
* Code: `rhtap_jenkins.invocation_id_found`
1017-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/rhtap_jenkins/rhtap_jenkins.rego#L36[Source, window="_blank"]
1018-
1019-
[#rhtap_jenkins__attestation_found]
1020-
=== link:#rhtap_jenkins__attestation_found[RHTAP Jenkins SLSA Provenance Attestation Found]
1021-
1022-
Verify an attestation created by the RHTAP Jenkins build pipeline is present.
1023-
1024-
*Solution*: It appears the build pipeline did not create a SLSA provenance attestation. Check the logs in Jenkins for the cosign-sign-attest stage to see if you can find out why.
986+
*Solution*: It appears the build pipeline did not create the expected SLSA provenance attestation. Check for relevant error messages in the 'cosign-sign-attest' pipeline step logs.
1025987

1026988
* Rule type: [rule-type-indicator failure]#FAILURE#
1027-
* FAILURE message: `The expected SLSA v1.0 provenance with build type %s was not found.`
1028-
* Code: `rhtap_jenkins.attestation_found`
1029-
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/rhtap_jenkins/rhtap_jenkins.rego#L17[Source, window="_blank"]
989+
* FAILURE message: `A SLSA v1.0 provenance with one of the following RHTAP Multi-CI build types was not found: %s.`
990+
* Code: `rhtap_multi_ci.attestation_found`
991+
* https://github.com/enterprise-contract/ec-policies/blob/{page-origin-refhash}/policy/release/rhtap_multi_ci/rhtap_multi_ci.rego#L16[Source, window="_blank"]
1030992

1031993
[#rpm_repos_package]
1032994
== link:#rpm_repos_package[RPM Repos]

antora/docs/modules/ROOT/partials/release_policy_nav.adoc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,9 @@
7171
**** xref:release_policy.adoc#provenance_materials__git_clone_task_found[Git clone task found]
7272
*** xref:release_policy.adoc#quay_expiration_package[Quay expiration]
7373
**** xref:release_policy.adoc#quay_expiration__expires_label[Expires label]
74-
*** xref:release_policy.adoc#rhtap_github_package[RHTAP GitHub]
75-
**** xref:release_policy.adoc#rhtap_github__attestation_found[RHTAP GitHub SLSA Provenance Attestation Found]
76-
*** xref:release_policy.adoc#rhtap_gitlab_package[RHTAP GitLab]
77-
**** xref:release_policy.adoc#rhtap_gitlab__attestation_found[RHTAP GitLab SLSA Provenance Attestation Found]
78-
*** xref:release_policy.adoc#rhtap_jenkins_package[RHTAP Jenkins]
79-
**** xref:release_policy.adoc#rhtap_jenkins__invocation_id_found[RHTAP Jenkins SLSA Invocation ID present]
80-
**** xref:release_policy.adoc#rhtap_jenkins__attestation_found[RHTAP Jenkins SLSA Provenance Attestation Found]
74+
*** xref:release_policy.adoc#rhtap_multi_ci_package[RHTAP Multi-CI]
75+
**** xref:release_policy.adoc#rhtap_multi_ci__attestation_format[SLSA Provenance Attestation Format]
76+
**** xref:release_policy.adoc#rhtap_multi_ci__attestation_found[SLSA Provenance Attestation Found]
8177
*** xref:release_policy.adoc#rpm_repos_package[RPM Repos]
8278
**** xref:release_policy.adoc#rpm_repos__ids_known[All rpms have known repo ids]
8379
**** xref:release_policy.adoc#rpm_repos__rule_data_provided[Known repo id list provided]

policy/release/lib/attestations.rego

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,6 @@ taskrun_attestations := [att |
8484
att.statement.predicate.buildType in taskrun_att_build_types
8585
]
8686

87-
# For attestations created using an RHTAP build pipeline. See also:
88-
# - https://github.com/redhat-appstudio/tssc-sample-jenkins
89-
# - https://github.com/redhat-appstudio/tssc-sample-templates/tree/main/skeleton/ci/source-repo/jenkins
90-
# - https://github.com/redhat-appstudio/tssc-sample-templates/tree/main/skeleton/ci/gitops-template/jenkins
91-
# - https://github.com/redhat-appstudio/tssc-dev-multi-ci/blob/main/rhtap/att-predicate-jenkins.sh
92-
# - https://github.com/redhat-appstudio/tssc-dev-multi-ci/blob/main/rhtap/att-predicate-github.sh
93-
# - https://github.com/redhat-appstudio/tssc-dev-multi-ci/blob/main/rhtap/att-predicate-gitlab.sh
94-
#
95-
rhtap_build_type(rhtap_ci_type) := sprintf("https://redhat.com/rhtap/slsa-build-types/%s-build/v1", [rhtap_ci_type])
96-
97-
rhtap_attestations(rhtap_ci_type) := [att |
98-
some att in input.attestations
99-
att.statement.predicateType == slsa_provenance_predicate_type_v1
100-
att.statement.predicate.buildDefinition.buildType == rhtap_build_type(rhtap_ci_type)
101-
]
102-
10387
tasks_from_pipelinerun := [task |
10488
some att in pipelinerun_attestations
10589
some task in tekton.tasks(att)

policy/release/lib/attestations_test.rego

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,3 @@ test_result_values if {
416416

417417
not lib.result_values(123)
418418
}
419-
420-
test_rhtap_build_type if {
421-
lib.assert_equal(
422-
"https://redhat.com/rhtap/slsa-build-types/bacon-build/v1",
423-
lib.rhtap_build_type("bacon"),
424-
)
425-
}

policy/release/rhtap_github/rhtap_github.rego

Lines changed: 0 additions & 40 deletions
This file was deleted.

policy/release/rhtap_github/rhtap_github_test.rego

Lines changed: 0 additions & 36 deletions
This file was deleted.

policy/release/rhtap_gitlab/rhtap_gitlab.rego

Lines changed: 0 additions & 40 deletions
This file was deleted.

policy/release/rhtap_gitlab/rhtap_gitlab_test.rego

Lines changed: 0 additions & 36 deletions
This file was deleted.

policy/release/rhtap_jenkins/rhtap_jenkins.rego

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)