diff --git a/src/cosign/cosign.ts b/src/cosign/cosign.ts index 0e4e430..f280caf 100644 --- a/src/cosign/cosign.ts +++ b/src/cosign/cosign.ts @@ -142,15 +142,12 @@ export class Cosign { bundlePayload = obj as SerializedBundle; } - if (bundlePayload && signatureManifestDigest) { + if (bundlePayload && (signatureManifestDigest || signatureManifestFallbackDigest)) { + errors = undefined; // clear errors if we have both payload and manifest digest break; } } - if (!errors && !bundlePayload) { - throw new Error(`Cannot find signature bundle from cosign command output: ${logs}`); - } - return { bundle: bundlePayload, signatureManifestDigest: signatureManifestDigest || signatureManifestFallbackDigest, diff --git a/src/sigstore/sigstore.ts b/src/sigstore/sigstore.ts index 6c57afe..8c2b3e5 100644 --- a/src/sigstore/sigstore.ts +++ b/src/sigstore/sigstore.ts @@ -106,7 +106,8 @@ export class Sigstore { const errorMessages = signResult.errors.map(e => `- [${e.code}] ${e.message} : ${e.detail}`).join('\n'); throw new Error(`Cosign sign command failed with errors:\n${errorMessages}`); } else { - throw new Error(`Cosign sign command failed with exit code ${execRes.exitCode}`); + // prettier-ignore + throw new Error(`Cosign sign command failed with: ${execRes.stderr.trim().split(/\r?\n/).filter(line => line.length > 0).pop() ?? 'unknown error'}`); } } const parsedBundle = Sigstore.parseBundle(bundleFromJSON(signResult.bundle)); @@ -209,7 +210,8 @@ export class Sigstore { throw lastError; } } else { - throw new Error(`Cosign verify command failed: ${execRes.stderr}`); + // prettier-ignore + throw new Error(`Cosign verify command failed with: ${execRes.stderr.trim().split(/\r?\n/).filter(line => line.length > 0).pop() ?? 'unknown error'}`); } } }