Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/cyclonedx/Commands/MergeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public static async Task<int> Merge(MergeCommandOptions options)
}
else
{
// otherwise use the first non-null component from the input BOMs as the default
// otherwise use the first non-null component from the input
// BOMs as the default; note CleanupMetadataComponent() below
// to ensure that such bom-ref exists in the document only once.
foreach (var bom in inputBoms)
{
if(bom.Metadata != null && bom.Metadata.Component != null)
Expand All @@ -101,8 +103,19 @@ public static async Task<int> Merge(MergeCommandOptions options)
}
}

outputBom = CycloneDXUtils.CleanupMetadataComponent(outputBom);
outputBom = CycloneDXUtils.CleanupEmptyLists(outputBom);

outputBom.Version = 1;
outputBom.SerialNumber = "urn:uuid:" + System.Guid.NewGuid().ToString();
if (outputBom.Metadata is null)
{
outputBom.Metadata = new Metadata();
}
if (outputBom.Metadata.Timestamp is null)
{
outputBom.Metadata.Timestamp = DateTime.Now;
}

if (!outputToConsole)
{
Expand Down