Skip to content
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

More code reuse for RHTAP Multi-CI rego #1236

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

simonbaird
Copy link
Member

No description provided.

result := lib.result_helper(rego.metadata.chain(), [lib.quoted_values_string(_known_build_types)])
}

_attestations := lib.rhtap_attestations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to see a policy rule that applies to all slsa provenance attestations regardless of the CI system (beyond RHTAP). It could, optionally, filter attestations based on some criteria that is driven purely by policy rule data. For example:

rule_data:
  slsa_provenance_build_types:
      - https://redhat.com/rhtap/slsa-build-types/jenkins-build/v1
      - https://redhat.com/rhtap/slsa-build-types/gitlab-build/v1
_attestations contains att if {
  some att in input.attestations
  # Ok to hard-code this I think since it should be v1 going forward.
  att.statement.predicateType == slsa_provenance_predicate_type_v1
  some build_type in lib.rule_data("slsa_provenance_build_types")
  att.statement.predicate.buildDefinition.buildType == build_type
}  

We could use that today in Konflux as well if we wanted to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do own/manage the config file that RHTAP users get, so we could include the rule data in that. 🤔 .

It's intended to handle the github, gitlab, and jenkins RHTAP
attestation varieties, which will be removed in the next commit.

Ref: https://issues.redhat.com/browse/EC-1032
This does strip out potentially useful Jenkins specific invocation
id check, but let's not worry about that for now. Once we have a
sensible plan for how to do this, we can bring it back fairly
easily.

Ref: https://issues.redhat.com/browse/EC-1032
I'm trying to move towards more generic rego, and this feels like a
step in the right direction.
Comment on lines +39 to +44
_known_build_types := [_build_type(known_ci_type) | some known_ci_type in _known_ci_types]

_build_type(ci_type) := sprintf("https://redhat.com/rhtap/slsa-build-types/%s-build/v1", [ci_type])

# RHTAP Multi-CI currently supports these environments
_known_ci_types := ["jenkins", "github", "gitlab"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not over complicate this

Suggested change
_known_build_types := [_build_type(known_ci_type) | some known_ci_type in _known_ci_types]
_build_type(ci_type) := sprintf("https://redhat.com/rhtap/slsa-build-types/%s-build/v1", [ci_type])
# RHTAP Multi-CI currently supports these environments
_known_ci_types := ["jenkins", "github", "gitlab"]
_known_build_types := [
"https://redhat.com/rhtap/slsa-build-types/jenkins-build/v1",
"https://redhat.com/rhtap/slsa-build-types/github-build/v1",
"https://redhat.com/rhtap/slsa-build-types/gitlab-build/v1",
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants