Skip to content

Commit 83dc2cb

Browse files
committed
return an error if signature is attempted with json boms
Signed-off-by: Leon <leon@1ux.dev>
1 parent 336ee2f commit 83dc2cb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CycloneDX/ExitCode.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ enum ExitCode
2525
LocalPackageCacheError,
2626
DotnetRestoreFailed,
2727
GitHubLicenseResolutionFailed,
28-
UnableToLocateDependencyBomRef
28+
UnableToLocateDependencyBomRef,
29+
UnsupportedSignatureFormat
2930
}
3031
}

CycloneDX/Runner.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,16 @@ public async Task<int> HandleCommandAsync(RunOptions options)
445445

446446
if (!string.IsNullOrEmpty(signingKeyPath))
447447
{
448-
IBomSigner signer = new XmlBomSigner();
449-
bomContents = await signer.SignAsync(signingKeyPath, bomContents);
448+
if (format == OutputFileFormat.Xml)
449+
{
450+
IBomSigner signer = new XmlBomSigner();
451+
bomContents = await signer.SignAsync(signingKeyPath, bomContents);
452+
}
453+
else
454+
{
455+
Console.WriteLine("Signing the BOM is only supported with XML BOMs at the moment.");
456+
return (int)ExitCode.UnsupportedSignatureFormat;
457+
}
450458
}
451459

452460

0 commit comments

Comments
 (0)