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

[TEP-0091] add condition for trusted resources #6654

Closed
wants to merge 1 commit into from

Conversation

Yongxuanzhang
Copy link
Member

@Yongxuanzhang Yongxuanzhang commented May 12, 2023

Changes

This commit adds the ConditionTrustedResourcesVerified for trusted resources into pipelinerun/taskrun status to show if the resources passes verification. Failing to verify will add a false condition to the taskrun/pipelinerun status and passing the verification will add a true status condition.

Though this is a big size PR, it contains several changes which can be grouped into:

  1. Add VerificationResult to indicate different cases when the Verification doesn't return error (Files: verify.go)
  2. Update GetTask and GetPipeline and all the functions in call stack to return VerificationResult back to reconcile (Files: pipelineref.go, pipelinerunresolution.go, pipelinespec.go, taskref.go, taskspec.go)
  3. Update TrustedResources condition based on VerificationResult (Files: taskrun.go, pipelinerun.go)
  4. Unit tests to cover those cases. (all test files)

Those changes cannot be split into separate PRs.

/kind feature

Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Add ConditionTrustedResourcesVerified condition to pipelinerun/taskrun status indicate whether trusted resources fails verification or not. Functions including GetTask, GetTaskData, GetPipeline, GetPipelineData are updated to return VerificationResult

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label May 12, 2023
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 12, 2023
@Yongxuanzhang
Copy link
Member Author

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label May 12, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 88.8% -0.4
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.7% 0.1
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 94.8% -0.8
test/trustedresources.go 10.8% 10.6% -0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 88.8% -0.4
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.7% 0.1
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 94.8% -0.8
test/trustedresources.go 10.8% 10.6% -0.1

@Yongxuanzhang
Copy link
Member Author

/assign @wlynch

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from wlynch after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

// VerifyTask verifies the signature and public key against task.
// Skip the verification when no policies are found and trusted-resources-verification-no-match-policy is set to ignore or warn
// Return an error when no policies are found and trusted-resources-verification-no-match-policy is set to fail,
// or the resource fails to pass matched enforce verification policy
// refSource contains the source information of the task.
func VerifyTask(ctx context.Context, taskObj *v1beta1.Task, k8s kubernetes.Interface, refSource *v1beta1.RefSource, verificationpolicies []*v1alpha1.VerificationPolicy) error {
func VerifyTask(ctx context.Context, taskObj *v1beta1.Task, k8s kubernetes.Interface, refSource *v1beta1.RefSource, verificationpolicies []*v1alpha1.VerificationPolicy) (*VerificationResult, error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

VerifyTask and VerifyPipeline share lots of common code, I think we may merge them into 1 function in a follow-up pr

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.1% -0.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.7% 0.1
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 94.8% -0.8
test/trustedresources.go 10.8% 10.6% -0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.1% -0.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.7% 0.1
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 94.8% -0.8
test/trustedresources.go 10.8% 10.6% -0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.4% 0.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.7% 0.1
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 95.9% 0.3
test/trustedresources.go 10.8% 10.6% -0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.4% 0.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.7% 0.1
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 95.9% 0.3
test/trustedresources.go 10.8% 10.6% -0.1

@lbernick
Copy link
Member

@Yongxuanzhang Thank you for taking the time to write a detailed/helpful commit message! It might be a bit tricky, but I do think it's possible to split this into multiple PRs. For example:

  • you could introduce a PR where a VerificationResult is just an empty struct
  • you could introduce the VerificationResult struct by itself and not use it
  • you could have GetPipeline/GetTask return a verification result and not use it in the pipelinerun reconciler yet
  • it also seems like there are some unrelated changes in test/trustedresources.go?

Can you play around with this a bit and see what PR splits are possible?

@Yongxuanzhang
Copy link
Member Author

@Yongxuanzhang Thank you for taking the time to write a detailed/helpful commit message! It might be a bit tricky, but I do think it's possible to split this into multiple PRs. For example:

  • you could introduce a PR where a VerificationResult is just an empty struct
  • you could introduce the VerificationResult struct by itself and not use it
  • you could have GetPipeline/GetTask return a verification result and not use it in the pipelinerun reconciler yet
  • it also seems like there are some unrelated changes in test/trustedresources.go?

Can you play around with this a bit and see what PR splits are possible?

Thanks for the suggestions! Let me try to split it as you suggested!
The changes in test/trustedresources.go is used for unit testing across different pkgs

@Yongxuanzhang
Copy link
Member Author

Yongxuanzhang commented May 15, 2023

/hold
I will try to break it down into smaller prs

  1. [TEP-0091] add VerificationResult #6663

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 15, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.4% 0.2
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.8% 91.3% -2.4
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 96.7% 0.1
pkg/reconciler/taskrun/resources/taskref.go 90.0% 88.2% -1.8
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 95.9% 0.3
test/trustedresources.go 10.8% 10.6% -0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.4% 0.2
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.8% 91.3% -2.4
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 96.7% 0.1
pkg/reconciler/taskrun/resources/taskref.go 90.0% 88.2% -1.8
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 95.9% 0.3
test/trustedresources.go 10.8% 10.6% -0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.4% 0.2
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.8% 91.3% -2.4
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 96.7% 0.1
pkg/reconciler/taskrun/resources/taskref.go 90.0% 88.2% -1.8
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 95.9% 0.3
test/trustedresources.go 10.8% 10.6% -0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.4% 0.2
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.8% 91.3% -2.4
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 96.7% 0.1
pkg/reconciler/taskrun/resources/taskref.go 90.0% 88.2% -1.8
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 95.9% 0.3
test/trustedresources.go 10.8% 10.6% -0.1

This commit adds the ConditionTrustedResourcesVerified for trusted
resources into pipelinerun/taskrun status to show if the resources passes verification. Failing
to verify will add a false condition to the taskrun/pipelinerun
status and passing the verification will add a true status condition.

Signed-off-by: Yongxuan Zhang yongxuanzhang@google.com
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.4% 0.2
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.8% 91.3% -2.4
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 96.7% 0.1
pkg/reconciler/taskrun/resources/taskref.go 90.0% 88.2% -1.8
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 95.9% 0.3
test/trustedresources.go 10.8% 10.6% -0.1

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 89.2% 89.4% 0.2
pkg/reconciler/pipelinerun/resources/pipelineref.go 93.8% 91.3% -2.4
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.6% 96.7% 0.1
pkg/reconciler/taskrun/resources/taskref.go 90.0% 88.2% -1.8
pkg/reconciler/taskrun/taskrun.go 85.0% 85.2% 0.2
pkg/trustedresources/verify.go 95.6% 95.9% 0.3
test/trustedresources.go 10.8% 10.6% -0.1

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 19, 2023
@tekton-robot
Copy link
Collaborator

@Yongxuanzhang: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/feature Categorizes issue or PR as related to a new feature. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants