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

refactor: migrate to intoto/attestations go library -> in-toto 1.0 bump #397

Merged
merged 6 commits into from
Oct 23, 2023

Conversation

migmartri
Copy link
Member

@migmartri migmartri commented Oct 20, 2023

Attestation rendering logic refactoring to support in-toto v1.0.

Previously, we did some work #103 adopting resourceDescriptors in our custom predicate, but now, in-toto 1.0 spec is fully supported.

In practice, this patch:

Closes #60

Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
@@ -107,6 +109,9 @@ func (action *AttestationPush) Run(runtimeAnnotations map[string]string) (*Attes

action.Logger.Debug().Msg("validation completed")

// Indicate that we are done with the attestation
action.c.CraftingState.Attestation.FinishedAt = timestamppb.New(time.Now())
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 finishedAt timestamp is now in the attestation state. This simplifies testing by making rendering idempotent.

@@ -26,7 +26,7 @@ import (
"github.com/chainloop-dev/chainloop/internal/attestation/renderer/chainloop"
sigs "github.com/sigstore/cosign/v2/pkg/signature"

"github.com/in-toto/in-toto-golang/in_toto"
Copy link
Member Author

Choose a reason for hiding this comment

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

moved away from github.com/in-toto/in-toto-golang/in_toto

@@ -0,0 +1,96 @@
{
"type": "https://in-toto.io/Statement/v1",
Copy link
Member Author

Choose a reason for hiding this comment

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

in-toto v1! 🎉

@@ -0,0 +1,96 @@
{
"type": "https://in-toto.io/Statement/v1",
Copy link
Member Author

Choose a reason for hiding this comment

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

in-toto v1! 🎉

// transform to structpb.Struct in a two steps process
// 1 - ProvenancePredicate -> json -> map[string]interface{}
// 2 - map[string]interface{} -> structpb.Struct
predicateJSON, err := json.Marshal(p)
Copy link
Member Author

Choose a reason for hiding this comment

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

a little bit of trickery to transform to structpb :(

@@ -43,8 +44,7 @@ type AttestationRenderer struct {
}

type r interface {
Header() (*in_toto.StatementHeader, error)
Predicate() (interface{}, error)
Statement() (*intoto.Statement, 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.

the interface has been simplified now.

@migmartri migmartri marked this pull request as ready for review October 20, 2023 13:13
@migmartri
Copy link
Member Author

@adityasaky, re this comment #60 (comment)

I can see some deprecation warnings in the in-toto-golang repo but not an actual implementation using those new proto bindings.

Am I missing anything? Is the path forward recommended by the in-toto team to adopt the bindings at in-toto/attestation/go still?

Thank you!

@marcelamelara
Copy link

marcelamelara commented Oct 20, 2023

I can see some deprecation warnings in the in-toto-golang repo but not an actual implementation using those new proto bindings.

@migmartri Adding support for the proto bindings to in-toto-golang is in-flight: in-toto/in-toto-golang#268 We were blocked on something until last week, so I should be able to complete this PR now.

@migmartri
Copy link
Member Author

migmartri commented Oct 20, 2023

I can see some deprecation warnings in the in-toto-golang repo but not an actual implementation using those new proto bindings.

@migmartri Adding support for the proto bindings to in-toto-golang is in-flight: in-toto/in-toto-golang#268 We were blocked on something until last week, so I should be able to complete this PR now.

hi @marcelamelara, thanks for the information.

So great! We are both considering using in-toto/attestation/go as the source of truth for the bindings.

It seems that in your PR you are also adding some exciting generators, I might use them in the future :)

Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Copy link
Member

@danlishka danlishka left a comment

Choose a reason for hiding this comment

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

LGTM

@migmartri migmartri merged commit 38505dc into chainloop-dev:main Oct 23, 2023
12 checks passed
@migmartri migmartri deleted the migrate-intoto branch October 23, 2023 15:48
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.

in-toto 1.0 support
3 participants