From c3e9597eaf168270a585edecf2f63337908a72bd Mon Sep 17 00:00:00 2001 From: "Wilson E. Husin" Date: Tue, 12 Apr 2022 01:42:30 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20missing=20bootstrap=20path?= =?UTF-8?q?=20for=20cosign?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- program/cosign.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/program/cosign.go b/program/cosign.go index e3dce90..8a99231 100644 --- a/program/cosign.go +++ b/program/cosign.go @@ -28,6 +28,7 @@ import ( ) var ( + bootstrapCosignPath string bootstrapCosignOnce sync.Once bootstrapCosignArgs = []string{"get", "--bootstrap", "cosign", "--silent"} ) @@ -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 { @@ -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()) }