Skip to content

Commit 5afb819

Browse files
author
construct agent
committed
fix: scrub hex-encoded hashes in E2E snapshot tests and update snapshots for spec 1.7
The hash scrubbing regex targeted base64 but CycloneDX emits hashes as uppercase hex. SHA-512 is 128 hex chars; the old pattern matched only the base64-looking prefix and left a hex tail in every snapshot. Replace with word-boundary hex regexes for all standard hash lengths (128/64/40/32). Also update snapshots to reflect the BOM namespace change from 1.6 to 1.7 introduced by CycloneDX.Core 11.0.0.
1 parent 5131847 commit 5afb819

7 files changed

Lines changed: 32 additions & 18 deletions

CycloneDX.E2ETests/Infrastructure/VerifyConfig.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,24 @@ public static void Initialize()
7070
@"(<version>)\d+\.\d+\.\d+(?:\.\d+)?(?:-[^<]+)?(</version>)",
7171
"$1{scrubbed-version}$2");
7272

73-
// SHA-512 hashes (base64, ~88 chars ending in ==)
73+
// Hex-encoded hash values as emitted by CycloneDX in <hash> elements.
74+
// SHA-512 = 128 hex chars, SHA-256 = 64, SHA-1 = 40, MD5 = 32.
75+
// Match uppercase or lowercase hex strings of those lengths (longest first).
7476
line = Regex.Replace(
7577
line,
76-
@"(?:[A-Za-z0-9+/]{86,88}={0,2})",
78+
@"\b[0-9A-Fa-f]{128}\b",
79+
"{scrubbed-hash}");
80+
line = Regex.Replace(
81+
line,
82+
@"\b[0-9A-Fa-f]{64}\b",
83+
"{scrubbed-hash}");
84+
line = Regex.Replace(
85+
line,
86+
@"\b[0-9A-Fa-f]{40}\b",
87+
"{scrubbed-hash}");
88+
line = Regex.Replace(
89+
line,
90+
@"\b[0-9A-Fa-f]{32}\b",
7791
"{scrubbed-hash}");
7892

7993
return line;

CycloneDX.E2ETests/Snapshots/DevDependencyTests.DevDependency_ExcludedWithFlag.verified.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.6">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.7">
33
<metadata>
44
<timestamp>{scrubbed-timestamp}</timestamp>
55
<tools>
@@ -26,7 +26,7 @@
2626
<description>Test package TestPkg.A</description>
2727
<scope>required</scope>
2828
<hashes>
29-
<hash alg="SHA-512">{scrubbed-hash}531C6F999C3D7E54935AF23D43D1F34E34F13C64</hash>
29+
<hash alg="SHA-512">{scrubbed-hash}</hash>
3030
</hashes>
3131
<licenses>
3232
<license>

CycloneDX.E2ETests/Snapshots/ProjectReferencesTests.ProjectReference_IncludedWithFlag.verified.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.6">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.7">
33
<metadata>
44
<timestamp>{scrubbed-timestamp}</timestamp>
55
<tools>
@@ -31,7 +31,7 @@
3131
<description>Test package TestPkg.A</description>
3232
<scope>required</scope>
3333
<hashes>
34-
<hash alg="SHA-512">{scrubbed-hash}531C6F999C3D7E54935AF23D43D1F34E34F13C64</hash>
34+
<hash alg="SHA-512">{scrubbed-hash}</hash>
3535
</hashes>
3636
<licenses>
3737
<license>
@@ -51,7 +51,7 @@
5151
<description>Test package TestPkg.C</description>
5252
<scope>required</scope>
5353
<hashes>
54-
<hash alg="SHA-512">{scrubbed-hash}4404F2F30EF98F8B90397BAC9D0F93926F6F3D3B</hash>
54+
<hash alg="SHA-512">{scrubbed-hash}</hash>
5555
</hashes>
5656
<licenses>
5757
<license>

CycloneDX.E2ETests/Snapshots/SimpleProjectTests.SinglePackage_ProducesValidBom.verified.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.6">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.7">
33
<metadata>
44
<timestamp>{scrubbed-timestamp}</timestamp>
55
<tools>
@@ -26,7 +26,7 @@
2626
<description>Test package TestPkg.A</description>
2727
<scope>required</scope>
2828
<hashes>
29-
<hash alg="SHA-512">{scrubbed-hash}531C6F999C3D7E54935AF23D43D1F34E34F13C64</hash>
29+
<hash alg="SHA-512">{scrubbed-hash}</hash>
3030
</hashes>
3131
<licenses>
3232
<license>

CycloneDX.E2ETests/Snapshots/SimpleProjectTests.TransitiveDependency_AppearsInBom.verified.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.6">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.7">
33
<metadata>
44
<timestamp>{scrubbed-timestamp}</timestamp>
55
<tools>
@@ -26,7 +26,7 @@
2626
<description>Test package TestPkg.A</description>
2727
<scope>required</scope>
2828
<hashes>
29-
<hash alg="SHA-512">{scrubbed-hash}531C6F999C3D7E54935AF23D43D1F34E34F13C64</hash>
29+
<hash alg="SHA-512">{scrubbed-hash}</hash>
3030
</hashes>
3131
<licenses>
3232
<license>
@@ -46,7 +46,7 @@
4646
<description>Test package TestPkg.B</description>
4747
<scope>required</scope>
4848
<hashes>
49-
<hash alg="SHA-512">{scrubbed-hash}7AF7D3337A25066504E7B4C4523499392B7D5F7F</hash>
49+
<hash alg="SHA-512">{scrubbed-hash}</hash>
5050
</hashes>
5151
<licenses>
5252
<license>

CycloneDX.E2ETests/Snapshots/SimpleProjectTests.TwoDirectPackages_BothAppearInBom.verified.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.6">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.7">
33
<metadata>
44
<timestamp>{scrubbed-timestamp}</timestamp>
55
<tools>
@@ -26,7 +26,7 @@
2626
<description>Test package TestPkg.A</description>
2727
<scope>required</scope>
2828
<hashes>
29-
<hash alg="SHA-512">{scrubbed-hash}531C6F999C3D7E54935AF23D43D1F34E34F13C64</hash>
29+
<hash alg="SHA-512">{scrubbed-hash}</hash>
3030
</hashes>
3131
<licenses>
3232
<license>
@@ -46,7 +46,7 @@
4646
<description>Test package TestPkg.C</description>
4747
<scope>required</scope>
4848
<hashes>
49-
<hash alg="SHA-512">{scrubbed-hash}4404F2F30EF98F8B90397BAC9D0F93926F6F3D3B</hash>
49+
<hash alg="SHA-512">{scrubbed-hash}</hash>
5050
</hashes>
5151
<licenses>
5252
<license>

CycloneDX.E2ETests/Snapshots/SolutionScanTests.TwoProjects_BothPackagesInBom.verified.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.6">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:{scrubbed}" version="1" xmlns="http://cyclonedx.org/schema/bom/1.7">
33
<metadata>
44
<timestamp>{scrubbed-timestamp}</timestamp>
55
<tools>
@@ -26,7 +26,7 @@
2626
<description>Test package TestPkg.A</description>
2727
<scope>required</scope>
2828
<hashes>
29-
<hash alg="SHA-512">{scrubbed-hash}531C6F999C3D7E54935AF23D43D1F34E34F13C64</hash>
29+
<hash alg="SHA-512">{scrubbed-hash}</hash>
3030
</hashes>
3131
<licenses>
3232
<license>
@@ -46,7 +46,7 @@
4646
<description>Test package TestPkg.C</description>
4747
<scope>required</scope>
4848
<hashes>
49-
<hash alg="SHA-512">{scrubbed-hash}4404F2F30EF98F8B90397BAC9D0F93926F6F3D3B</hash>
49+
<hash alg="SHA-512">{scrubbed-hash}</hash>
5050
</hashes>
5151
<licenses>
5252
<license>

0 commit comments

Comments
 (0)