Skip to content

Commit 0162b2c

Browse files
committed
cosign: clear errors if manifest or bundle payload found
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 7397cfe commit 0162b2c

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/cosign/cosign.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,12 @@ export class Cosign {
142142
bundlePayload = obj as SerializedBundle;
143143
}
144144

145-
if (bundlePayload && signatureManifestDigest) {
145+
if (bundlePayload && (signatureManifestDigest || signatureManifestFallbackDigest)) {
146+
errors = undefined; // clear errors if we have both payload and manifest digest
146147
break;
147148
}
148149
}
149150

150-
if (!errors && !bundlePayload) {
151-
throw new Error(`Cannot find signature bundle from cosign command output: ${logs}`);
152-
}
153-
154151
return {
155152
bundle: bundlePayload,
156153
signatureManifestDigest: signatureManifestDigest || signatureManifestFallbackDigest,

src/sigstore/sigstore.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ export class Sigstore {
106106
const errorMessages = signResult.errors.map(e => `- [${e.code}] ${e.message} : ${e.detail}`).join('\n');
107107
throw new Error(`Cosign sign command failed with errors:\n${errorMessages}`);
108108
} else {
109-
throw new Error(`Cosign sign command failed with exit code ${execRes.exitCode}`);
109+
// prettier-ignore
110+
throw new Error(`Cosign sign command failed with: ${execRes.stderr.trim().split(/\r?\n/).filter(line => line.length > 0).pop() ?? 'unknown error'}`);
110111
}
111112
}
112113
const parsedBundle = Sigstore.parseBundle(bundleFromJSON(signResult.bundle));
@@ -209,7 +210,8 @@ export class Sigstore {
209210
throw lastError;
210211
}
211212
} else {
212-
throw new Error(`Cosign verify command failed: ${execRes.stderr}`);
213+
// prettier-ignore
214+
throw new Error(`Cosign verify command failed with: ${execRes.stderr.trim().split(/\r?\n/).filter(line => line.length > 0).pop() ?? 'unknown error'}`);
213215
}
214216
}
215217
}

0 commit comments

Comments
 (0)