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

Add a check for the RPM build pipleline #1273

Merged
merged 7 commits into from
Jan 28, 2025

Conversation

jorris
Copy link
Contributor

@jorris jorris commented Jan 22, 2025

Ensure that all tasks building the RPM come from an approved pipeline.

Ensure that all tasks building the RPM come from an approved
pipeline.
@jorris
Copy link
Contributor Author

jorris commented Jan 22, 2025

@joejstuart
Copy link
Member

@jorris I'm trying to learn more about how this will be used. Will it be assumed that each task in a pipeline will have the build.appstudio.redhat.com/pipeline annotation?

Comment on lines 41 to 42
some p in allowed_pipelines
p != pipeline
Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly, I think you want something like this.

Suggested change
some p in allowed_pipelines
p != pipeline
not (pipeline in allowed_pipelines)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I was indeed trying to do that, but having problems with 'not' syntax.

"buildConfig": {"tasks": [_valid_pipeline_task, _valid_pipeline_task_2]},
}}}]

lib.assert_empty(rpm_pipeline.deny) with data.rule_data.allowed_rpm_build_pipelines as [["foobar", "baz"]] with input.attestations as 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 think you want a list of strings.

Suggested change
lib.assert_empty(rpm_pipeline.deny) with data.rule_data.allowed_rpm_build_pipelines as [["foobar", "baz"]] with input.attestations as attestations
lib.assert_empty(rpm_pipeline.deny) with data.rule_data.allowed_rpm_build_pipelines as ["foobar", "baz"] with input.attestations as attestations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. It's concerning that the tests passed despite my mistake.

Copy link
Member

Choose a reason for hiding this comment

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

Welcome to Rego. :)

"name": "get-rpm-sources",
"status": "Succeeded",
"ref": {"name": "init", "kind": "Task", "bundle": "quay.io/konflux-ci/tekton-catalog/task-init"},
"invocation": {"environment": {"annotations": {"build.appstudio.redhat.com/pipeline": "biff"}}},
Copy link
Member

@joejstuart joejstuart Jan 23, 2025

Choose a reason for hiding this comment

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

According to the test, do you want this to be "baz"?

Suggested change
"invocation": {"environment": {"annotations": {"build.appstudio.redhat.com/pipeline": "biff"}}},
"invocation": {"environment": {"annotations": {"build.appstudio.redhat.com/pipeline": "baz"}}},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. It's concerning that the tests passed despite my mistake.

@jorris
Copy link
Contributor Author

jorris commented Jan 23, 2025

@jorris I'm trying to learn more about how this will be used. Will it be assumed that each task in a pipeline will have the build.appstudio.redhat.com/pipeline annotation?

Yes. The rpmbuild pipeline as it stands will consistently have this value set. This is for an MVP to meet product security requirements that only an approved pipeline may be used.

@joejstuart
Copy link
Member

joejstuart commented Jan 23, 2025

@jorris I'm trying to learn more about how this will be used. Will it be assumed that each task in a pipeline will have the build.appstudio.redhat.com/pipeline annotation?

Yes. The rpmbuild pipeline as it stands will consistently have this value set. This is for an MVP to meet product security requirements that only an approved pipeline may be used.

Thanks, that sounds good. We have a rule that enforces a build ran with certain required tasks. https://github.com/enterprise-contract/ec-policies/blob/main/policy/release/tasks/tasks.rego#L182

The task list is stored in https://github.com/release-engineering/rhtap-ec-policy/blob/main/data/required_tasks.yml and the keys fbc, docker, etc are stored in an annotation in the identified build task of each pipeline. https://github.com/enterprise-contract/ec-policies/blob/main/policy/lib/tekton/pipeline.rego#L9

Not sure if that's exactly what you're looking for, but just wanted to let you know.

@jorris
Copy link
Contributor Author

jorris commented Jan 24, 2025

Also see #1272 where I had some conversation with Simon. Abandoned that MR since I accidentally pushed unsigned changes.

@joejstuart joejstuart merged commit ffacf03 into enterprise-contract:main Jan 28, 2025
4 checks passed
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.

2 participants