cosign: clear errors if manifest or bundle payload found

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2026-01-13 12:17:40 +01:00
parent 7397cfe37c
commit 0162b2cf8b
2 changed files with 6 additions and 7 deletions

View File

@@ -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,

View File

@@ -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'}`);
}
}
}