Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
🐛 Fix missing bootstrap path for cosign
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonehusin committed Apr 12, 2022
1 parent 6f393d2 commit c3e9597
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions program/cosign.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
)

var (
bootstrapCosignPath string
bootstrapCosignOnce sync.Once
bootstrapCosignArgs = []string{"get", "--bootstrap", "cosign", "--silent"}
)
Expand Down Expand Up @@ -55,13 +56,13 @@ func cosignPath(ctx context.Context) (string, error) {
bootstrapErr = fmt.Errorf("bootstrapping through bindl binary: %s", stderr.String())
return
}
bootstrapCosignPath = strings.TrimSpace(stdout.String())
})
if bootstrapErr != nil {
return "", fmt.Errorf("bootstrapping cosign: %w", bootstrapErr)
}
cosignPath := strings.TrimSpace(stdout.String())
internal.Log().Debug().Str("cosign", cosignPath).Msg("found cosign")
return cosignPath, nil
internal.Log().Debug().Str("cosign", bootstrapCosignPath).Msg("found cosign")
return bootstrapCosignPath, nil
}

type CosignBundle struct {
Expand Down Expand Up @@ -112,14 +113,14 @@ func (c *CosignBundle) VerifySignature(ctx context.Context) error {

err = cmd.Run()
if err == nil {
internal.Log().Debug().Str("cosign", stderr.String()).Send()
internal.Log().Debug().Str("cosign", strings.TrimSpace(stderr.String())).Send()
os.RemoveAll(dir)
return nil
}

cmdStr := append([]string{p}, cosignArgs...)

internal.Log().Debug().Strs("cmd", cmdStr).Err(err).Str("stderr", stderr.String()).Send()
internal.Log().Debug().Strs("cmd", cmdStr).Err(err).Str("stderr", strings.TrimSpace(stderr.String())).Send()

return fmt.Errorf("failed to verify signature: %s", stderr.String())
}

0 comments on commit c3e9597

Please sign in to comment.