-
Notifications
You must be signed in to change notification settings - Fork 51
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
Conversation
There was a problem hiding this 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? |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/the/that/
There was a problem hiding this comment.
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 | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@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. |
Thanks @lukpueh ! |
This PR provides a few small code refactors for clean up: