Skip to content

Commit

Permalink
Merge pull request #273 from candrews/serialNumber
Browse files Browse the repository at this point in the history
Set serialNumber when merging
  • Loading branch information
coderpatros authored Oct 12, 2022
2 parents eabd721 + 3ce25d2 commit 6ecb85e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cyclonedx/Commands/MergeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public static async Task<int> Merge(MergeCommandOptions options)
}

outputBom.Version = 1;
outputBom.SerialNumber = "urn:uuid:" + System.Guid.NewGuid().ToString();

if (!outputToConsole)
{
Expand Down
3 changes: 3 additions & 0 deletions tests/cyclonedx.tests/MergeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Xunit;
using Snapshooter;
Expand Down Expand Up @@ -70,6 +71,8 @@ public async Task Merge(

Assert.Equal(0, exitCode);
var bom = File.ReadAllText(fullOutputPath);
bom = Regex.Replace(bom, @"\s*""serialNumber"": "".*?"",\r?\n", ""); // json
bom = Regex.Replace(bom, @"\s+serialNumber="".*?""", ""); // xml
Snapshot.Match(bom, SnapshotNameExtension.Create(hierarchical ? "Hierarchical" : "Flat", snapshotInputFilenames, inputFormat, outputFilename, outputFormat));
}
}
Expand Down

0 comments on commit 6ecb85e

Please sign in to comment.