-
Notifications
You must be signed in to change notification settings - Fork 153
Add cosign-based signing, attestation, and verification for modelkits #1023
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
base: main
Are you sure you want to change the base?
Add cosign-based signing, attestation, and verification for modelkits #1023
Conversation
Signed-off-by: Keerthan KK <[email protected]>
…cific flags Signed-off-by: Keerthan KK <[email protected]>
Signed-off-by: Keerthan KK <[email protected]>
Signed-off-by: Keerthan KK <[email protected]>
Signed-off-by: Keerthan KK <[email protected]>
| ) | ||
|
|
||
| func RunSign(ctx context.Context, options *signOptions) error { | ||
| cmd := exec.CommandContext(ctx, "cosign", options.cosignArgs...) |
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.
Commands will panic with "executable file not found" when cosign binary is not installed on the system. This needs pre-flight checks before making these calls. Also is there a possibility to use cosign as a library instead of an external CLI ?
| "os/exec" | ||
| ) | ||
|
|
||
| func RunAttest(context context.Context, options *attestOptions) any { |
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.
Why does this return any and not error?
| return cmd | ||
| } | ||
|
|
||
| func runCommand(opts []verifyOptions) func(cmd *cobra.Command, args []string) error { |
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.
While this code works due to reassignment of opts it's confusing. The function signature runCommand([]verifyOptions{})suggests it takes an initialized slice, but it's always called with an empty slice and immediately populated. Refactor to use local variable for opts
|
|
||
| err := cmd.Run() | ||
| if err != nil { | ||
| return fmt.Errorf("signing failed %s", err) |
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.
Should use %w instead of %s
| func VerifyCommand() *cobra.Command { | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "verify [FLAGS]", |
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.
FLAGS -> flags
|
|
||
| func AttestCommand() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "attest [FLAGS]", |
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.
FLAGS -> flags
| return output.Fatalf("Failed to %s: %s", commands[i], err) | ||
| } | ||
| } | ||
| output.Infof("Modelkit signed") |
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.
Looks like a copy/paste error should be output.Infof("Modelkit verification successful")
Description
This PR adds support for signing, attesting, and verifying modelkits using the kit commands directly. These commands use cosign internally. The users doesn't have to switch between multiple tools. The verify command enables the user to run both verify and verify attestation using a single command.
Linked issues
closes #857
AI-Assisted Code