Skip to content

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
Signed-off-by: Marcela Melara <[email protected]>
  • Loading branch information
marcelamelara committed Oct 31, 2023
1 parent ed74e18 commit b08b909
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions scai-gen/cmd/sigstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
"github.com/sigstore/cosign/v2/cmd/cosign/cli/sign"
"github.com/sigstore/cosign/v2/pkg/providers"
"github.com/sigstore/sigstore/pkg/signature/dsse"
"github.com/spf13/cobra"
"github.com/slsa-framework/slsa-github-generator/signing/sigstore"
"github.com/slsa-framework/slsa-github-generator/signing/envelope"
"github.com/slsa-framework/slsa-github-generator/signing/sigstore"
"github.com/spf13/cobra"
"google.golang.org/protobuf/encoding/protojson"
)

Expand Down Expand Up @@ -72,7 +72,7 @@ func getNewFulcioSigner(ctx context.Context) (*fulcio.Signer, error) {

func signWithSigstore(_ *cobra.Command, args []string) error {
fmt.Println("EXPERIMENTAL FEATURE. DO NOT USE IN PRODUCTION.")

statementFile := args[0]
statement := &ita.Statement{}
err := fileio.ReadPbFromFile(statementFile, statement)
Expand All @@ -95,25 +95,25 @@ func signWithSigstore(_ *cobra.Command, args []string) error {

attBytes, err := protojson.Marshal(statement)
if err != nil {
return fmt.Errorf("Error marshalling Statement: %w", err)
return fmt.Errorf("error marshalling Statement: %w", err)
}

k, err := getNewFulcioSigner(ctx)
if err != nil {
return fmt.Errorf("Error creating Fulcio signer: %w", err)
return fmt.Errorf("error creating Fulcio signer: %w", err)
}

dsseSigner := dsse.WrapSigner(k, "application/vnd.in-toto")
signedAtt, err := dsseSigner.SignMessage(bytes.NewReader(attBytes))
if err != nil {
return fmt.Errorf("Error signing DSSE: %w", err)
return fmt.Errorf("error signing DSSE: %w", err)
}

// Add certificate to envelope. This is needed for
// Rekor compatibility.
signedAttWithCert, err := envelope.AddCertToEnvelope(signedAtt, k.Cert)
if err != nil {
return fmt.Errorf("Error adding Fulcio certificate to DSSE: %w", err)
return fmt.Errorf("error adding Fulcio certificate to DSSE: %w", err)
}

tlog := sigstore.NewDefaultRekor()
Expand All @@ -122,8 +122,8 @@ func signWithSigstore(_ *cobra.Command, args []string) error {
cert: k.Cert,
})
if err != nil {
return fmt.Errorf("Error uploading signed DSSE to public Rekor log: %w", err)
return fmt.Errorf("error uploading signed DSSE to public Rekor log: %w", err)
}

return fileio.WriteDSSEToFile(signedAtt, outFile)
}
2 changes: 1 addition & 1 deletion scai-gen/fileio/dsse.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ func ReadStatementFromDSSEFile(path string) (*ita.Statement, error) {

func WriteDSSEToFile(envBytes []byte, outFile string) error {
return os.WriteFile(outFile, envBytes, 0644) //nolint:gosec
}
}

0 comments on commit b08b909

Please sign in to comment.