mirror of
https://github.com/anchore/syft.git
synced 2026-11-02 07:26:34 +01:00
fix: unicode output in cyclonedx-json format (#1420)
This commit is contained in:
@@ -15,6 +15,7 @@ func TestSPDXJSONDirectoryEncoder(t *testing.T) {
|
||||
Format(),
|
||||
testutils.DirectoryInput(t),
|
||||
*updateSpdxJson,
|
||||
true,
|
||||
spdxJsonRedactor,
|
||||
)
|
||||
}
|
||||
@@ -26,6 +27,7 @@ func TestSPDXJSONImageEncoder(t *testing.T) {
|
||||
testutils.ImageInput(t, testImage, testutils.FromSnapshot()),
|
||||
testImage,
|
||||
*updateSpdxJson,
|
||||
true,
|
||||
spdxJsonRedactor,
|
||||
)
|
||||
}
|
||||
@@ -39,17 +41,18 @@ func TestSPDXRelationshipOrder(t *testing.T) {
|
||||
s,
|
||||
testImage,
|
||||
*updateSpdxJson,
|
||||
true,
|
||||
spdxJsonRedactor,
|
||||
)
|
||||
}
|
||||
|
||||
func spdxJsonRedactor(s []byte) []byte {
|
||||
// each SBOM reports the time it was generated, which is not useful during snapshot testing
|
||||
s = regexp.MustCompile(`"created": .*`).ReplaceAll(s, []byte("redacted"))
|
||||
s = regexp.MustCompile(`"created":\s+"[^"]*",?`).ReplaceAll(s, []byte(""))
|
||||
|
||||
// each SBOM reports a unique documentNamespace when generated, this is not useful for snapshot testing
|
||||
s = regexp.MustCompile(`"documentNamespace": .*`).ReplaceAll(s, []byte("redacted"))
|
||||
s = regexp.MustCompile(`"documentNamespace":\s+"[^"]*",?`).ReplaceAll(s, []byte(""))
|
||||
|
||||
// the license list will be updated periodically, the value here should not be directly tested in snapshot tests
|
||||
return regexp.MustCompile(`"licenseListVersion": .*`).ReplaceAll(s, []byte("redacted"))
|
||||
return regexp.MustCompile(`"licenseListVersion":\s+"[^"]*",?`).ReplaceAll(s, []byte(""))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user