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

dsse type #596

Closed
wants to merge 1 commit into from
Closed

dsse type #596

wants to merge 1 commit into from

Conversation

mikhailswift
Copy link
Contributor

Summary

Adds a DSSE type that validated each signature on the envelope. If the payload is an in-toto statement all in-toto subjects will be indexed. The hash of the payload, PAE encoded payload, and public keys are also indexed.

I've tested this locally and it works but I need to write tests and add it to the e2e test script yet. I'm opening this draft for discussion and input.

Ticket Link

Fixes #582

Release Note


@mikhailswift mikhailswift force-pushed the dsse-type branch 2 times, most recently from c7d0209 to 92bcffe Compare January 13, 2022 23:35
Copy link
Member

@bobcallaway bobcallaway left a comment

Choose a reason for hiding this comment

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

looking good so far, a couple minor things.

Does it make sense to move any of the verifier logic into sigstore/sigstore for reuse?


in, ok := pe.(*models.Dsse)
if !ok {
return nil, errors.New("cannot unmarshal non-Rekord types")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, errors.New("cannot unmarshal non-Rekord types")
return nil, errors.New("cannot unmarshal non-DSSE types")

Comment on lines 143 to 144
_, err := verifyEnvelope(allPubKeyBytes, env)
if err != nil {
return fmt.Errorf("could not verify envelope: %w", err)
}

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_, err := verifyEnvelope(allPubKeyBytes, env)
if err != nil {
return fmt.Errorf("could not verify envelope: %w", err)
}
if _, err := verifyEnvelope(allPubKeyBytes, env); err != nil {
return fmt.Errorf("could not verify envelope: %w", err)
}

@mikhailswift mikhailswift force-pushed the dsse-type branch 4 times, most recently from ff7ad21 to b688645 Compare January 16, 2022 01:16
@dlorenc
Copy link
Member

dlorenc commented Jan 16, 2022

Thanks for the PR and much needed cleanup!

@mikhailswift
Copy link
Contributor Author

Sorry for the delay in getting this finished up -- lost power over the weekend. I'm going to try and get this cleaned up and a full PR up today.

@pxp928
Copy link
Contributor

pxp928 commented May 18, 2022

@mikhailswift I just ran into this issue recently. Do you need any help pushing this over the finish line?

@mikhailswift mikhailswift force-pushed the dsse-type branch 2 times, most recently from f624a37 to 2b52d1e Compare May 20, 2022 19:00
@codecov-commenter
Copy link

codecov-commenter commented May 20, 2022

Codecov Report

Merging #596 (85d1a9e) into main (547eb3c) will increase coverage by 0.00%.
The diff coverage is 37.03%.

@@           Coverage Diff           @@
##             main     #596   +/-   ##
=======================================
  Coverage   46.56%   46.57%           
=======================================
  Files          60       61    +1     
  Lines        5094     5121   +27     
=======================================
+ Hits         2372     2385   +13     
- Misses       2447     2460   +13     
- Partials      275      276    +1     
Impacted Files Coverage Δ
cmd/rekor-cli/app/root.go 20.68% <ø> (ø)
pkg/types/entries.go 6.25% <ø> (ø)
pkg/types/dsse/dsse.go 37.03% <37.03%> (ø)
pkg/types/alpine/v0.0.1/entry.go 56.25% <0.00%> (+1.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 547eb3c...85d1a9e. Read the comment docs.

@mikhailswift mikhailswift force-pushed the dsse-type branch 2 times, most recently from 85d1a9e to 009fb0b Compare May 23, 2022 17:36
@mikhailswift mikhailswift marked this pull request as ready for review May 23, 2022 17:36
@mikhailswift mikhailswift requested a review from a team as a code owner May 23, 2022 17:36
@mikhailswift mikhailswift changed the title [DRAFT] dsse type dsse type May 23, 2022
Copy link
Member

@dlorenc dlorenc left a comment

Choose a reason for hiding this comment

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

A few comments.

pkg/types/dsse/v0.0.1/dsse_v0_0_1_schema.json Outdated Show resolved Hide resolved
pkg/types/dsse/v0.0.1/dsse_v0_0_1_schema.json Outdated Show resolved Hide resolved
pkg/types/dsse/v0.0.1/entry.go Outdated Show resolved Hide resolved
allPubKeyBytes = append(allPubKeyBytes, props.PublicKeyBytes)
}

allPubKeyBytes = append(allPubKeyBytes, props.PublicKeysBytes...)
Copy link
Member

Choose a reason for hiding this comment

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

I might be misunderstanding this, but it looks like the props.PublicKeyBytes will get appended twice. Is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PublicKeyBytes vs PublicKeysBytes

Part of the discussion on the issue was how to handle passing multiple public keys for cases where we would want to validate multiple signatures on the envelope. To handle this a new prop called PublicKeysBytes was added to handle that case. It's not a very nice solution though, so definitely open to alternatives here.

pkg/types/dsse/v0.0.1/entry.go Outdated Show resolved Hide resolved
@mikhailswift mikhailswift force-pushed the dsse-type branch 3 times, most recently from a8f7d0e to b6b476e Compare June 6, 2022 18:33
Copy link
Member

@bobcallaway bobcallaway left a comment

Choose a reason for hiding this comment

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

A few comments/questions inline; I think we should also update pkg/types/README.md with some info about this type and how it explicitly differs from intoto.

pkg/types/dsse/v0.0.1/dsse_v0_0_1_schema.json Outdated Show resolved Hide resolved
pkg/types/dsse/v0.0.1/entry.go Outdated Show resolved Hide resolved
pkg/types/dsse/dsse.go Outdated Show resolved Hide resolved
pkg/types/dsse/v0.0.1/entry.go Outdated Show resolved Hide resolved
return nil, fmt.Errorf("could not parse public key as x509: %w", err)
}

vfr, err := signature.LoadVerifier(key.CryptoPubKey(), crypto.SHA256)
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 hash algorithm always going to be SHA256 for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While not part of the DSSE spec it seems that all current users of DSSE default to using SHA256 during signing.

Adds a DSSE envelope type to rekor.  If the DSSE envelope's payload is
an in-toto statement the in-toto subjects will be used as indices for
the envelope's rekord.  If the envelope's payload is within the server's
configured attestation size the payload will be stored as an
attestation.

Signed-off-by: Mikhail Swift <mikhail@testifysec.com>
@dlorenc
Copy link
Member

dlorenc commented Aug 29, 2022

This can get closed out now!

@dlorenc dlorenc closed this Aug 29, 2022
@jmeth
Copy link

jmeth commented Sep 19, 2022

Sorry to comment on a closed PR but it seems like this was closed but never merged in to main. Was that the intention here?

@pxp928
Copy link
Contributor

pxp928 commented Sep 19, 2022

Sorry to comment on a closed PR but it seems like this was closed but never merged in to main. Was that the intention here?

@jmeth All the changes here were incorporated in another PR #973

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 records don't contain signatures
6 participants