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

Calculate subjects per formatter #1132

Merged

Conversation

renzodavid9
Copy link
Contributor

@renzodavid9 renzodavid9 commented Jun 4, 2024

Fixes: #1133

Changes

The way v2alpha3 and v2alpha4 calculate the subjects are different; calling extract.RetrieveAllArtifactURIs to generate the subjects is wrong if using v2alpha4. This PR add a new method to the payload formatter that returns the subjects according to the logic of each version. It also changes grafeas backend to generate the subject through the payloader and not calling the extract.RetrieveAllArtifactURIs directly.

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)
  • 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

@tekton-robot
Copy link

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 the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 4, 2024
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 4, 2024
@renzodavid9 renzodavid9 force-pushed the issue-subjects-per-formatter branch from 875cbc7 to 47c808b Compare June 6, 2024 04:33
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 6, 2024
@renzodavid9
Copy link
Contributor Author

/test all

@tekton-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/chains/formats/format.go 16.7% 20.0% 3.3
pkg/chains/formats/format.go Do not exist 40.0%
pkg/chains/formats/format.go Do not exist 20.0%
pkg/chains/formats/format.go Do not exist 20.0%
pkg/chains/formats/format.go Do not exist 33.3%
pkg/chains/formats/format.go Do not exist 16.7%
pkg/chains/formats/simple/simple.go 72.7% 66.7% -6.1
pkg/chains/formats/slsa/v1/intotoite6.go 30.8% 26.7% -4.1
pkg/chains/formats/slsa/v2alpha3/slsav2.go 87.5% 58.3% -29.2
pkg/chains/formats/slsa/v2alpha4/slsav2.go 75.0% 33.3% -41.7
pkg/chains/storage/grafeas/grafeas.go 78.2% 78.2% -0.0

@renzodavid9 renzodavid9 marked this pull request as ready for review June 6, 2024 21:11
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 6, 2024
@tekton-robot tekton-robot requested a review from lcarva June 6, 2024 21:11
@tekton-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/chains/formats/format.go 16.7% 20.0% 3.3
pkg/chains/formats/format.go Do not exist 35.0%
pkg/chains/formats/format.go Do not exist 20.0%
pkg/chains/formats/format.go Do not exist 20.0%
pkg/chains/formats/format.go Do not exist 33.3%
pkg/chains/formats/format.go Do not exist 16.7%
pkg/chains/formats/simple/simple.go 72.7% 66.7% -6.1
pkg/chains/formats/slsa/v1/intotoite6.go 30.8% 26.7% -4.1
pkg/chains/formats/slsa/v2alpha3/slsav2.go 87.5% 58.3% -29.2
pkg/chains/formats/slsa/v2alpha4/slsav2.go 75.0% 33.3% -41.7
pkg/chains/storage/grafeas/grafeas.go 78.2% 78.2% -0.0

@chitrangpatel
Copy link
Member

/un-approve

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 7, 2024
@chitrangpatel
Copy link
Member

/un-approve

@chitrangpatel
Copy link
Member

/remove-approve

@tekton-robot tekton-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 7, 2024
@chitrangpatel
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 7, 2024
@chitrangpatel
Copy link
Member

/lgtm

@chitrangpatel
Copy link
Member

/approve

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chitrangpatel

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

The pull request process is described 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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 8, 2024
@tekton-robot tekton-robot merged commit 750a98e into tektoncd:main Jun 8, 2024
17 checks passed
@chitrangpatel
Copy link
Member

/kind bug

@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 8, 2024
@chitrangpatel
Copy link
Member

/cherry-pick release-v0.21.x

1 similar comment
@chitrangpatel
Copy link
Member

/cherry-pick release-v0.21.x

chitrangpatel pushed a commit to chitrangpatel/chains that referenced this pull request Jun 8, 2024
* Calculate subjects per formatter

* Tests for new retrieve full uris in grafeas
renzodavid9 added a commit to renzodavid9/chains that referenced this pull request Jun 9, 2024
* Calculate subjects per formatter

* Tests for new retrieve full uris in grafeas

(cherry picked from commit 750a98e)
@renzodavid9 renzodavid9 mentioned this pull request Jun 9, 2024
6 tasks
tekton-robot pushed a commit that referenced this pull request Jun 10, 2024
* Fix field names in generated json statement (#1129)

To keep backwards compatibility with previous struct versions (e.g, github.com/in-toto/in-toto-golang/in_toto) we have to use protojson.Marshal function to transform the struct to its json representation so the tags defined in the intoto.Statement are follow and applied to the resulting string.

(cherry picked from commit 3bf8cac)

* Fix no repeated subjects for v2alpha4 pipelineruns (#1130)

Change the pipelinerun v2alpha4 method that calculates the subjects to use `artifact.AppendSubjects` instead of `append` to avoid duplicated subjects.

(cherry picked from commit badc734)

* Calculate subjects per formatter (#1132)

* Calculate subjects per formatter

* Tests for new retrieve full uris in grafeas

(cherry picked from commit 750a98e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong subjects returned when storing in grafeas
3 participants