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

Clean up InTotoVerify and rsa public key loading #12

Merged
merged 5 commits into from
Jan 8, 2019

Conversation

lukpueh
Copy link
Member

@lukpueh lukpueh commented Nov 14, 2018

This PR provides a few small code refactors for clean up:

Copy link
Member

@SantiagoTorres SantiagoTorres left a comment

Choose a reason for hiding this comment

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

Mostly aesthetics. Otherwise lgtm

@@ -14,6 +14,29 @@ import (
"reflect"
)

func ParseRSAPublicKeyFromPEM(pemBytes []byte) (*rsa.PublicKey, error) {
// TODO: There could be more key data in _, which we silently ignore here.
// Should we handle it / fail / say something about it?
Copy link
Member

Choose a reason for hiding this comment

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

If we were to merge this, could we ticketize this issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Done. #14.

in_toto/model.go Outdated
@@ -68,6 +68,27 @@ type Layout struct {
Readme string `json:"readme"`
}

// Go does not allow to pass `[]T` (slice with certain type) to a function
// the accepts `[]interface{}` (slice with generic type)
Copy link
Member

Choose a reason for hiding this comment

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

s/the/that/

Copy link
Member Author

Choose a reason for hiding this comment

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

inspectionsI[i] = v
}
return inspectionsI
}
Copy link
Member

Choose a reason for hiding this comment

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

Aside: is this just another instance of lolnogenerics?

Copy link
Member Author

Choose a reason for hiding this comment

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

:)

Steps and inspections (supply chain items) share some common
fields that used to be defined redundantly before.
This commit adds a new struct `SupplyChainItem` that defines the
common fields, and adds SupplyChainItem as anonymous field to
the Step and Inspection struct definitions (which is akin to
inheritance).
Move two type conversion loops out of InTotoVerify, into two
new layout helper. See code comments for reasoning.
Create helper function to reuse rsa public key parsing
functionality that used to be implemented in both
VerifySignature and LoadPublicKey.
@lukpueh
Copy link
Member Author

lukpueh commented Jan 8, 2019

@SantiagoTorres, thanks for your review! I addressed you comments, except for the one about lolnogenerics, I fear I can't fix that one. :P I also had to quickly fix the test layout expiration (#15) and rebase.

@SantiagoTorres
Copy link
Member

Thanks @lukpueh !

@SantiagoTorres SantiagoTorres merged commit 0ffe145 into in-toto:master Jan 8, 2019
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.

2 participants