Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MergeCommand.cs: ensure a timestamp and use new cyclonedx-dotnet-library features… #334

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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