From 64ff6656ff954666b1b0398b3cd4419c016270a0 Mon Sep 17 00:00:00 2001 From: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> Date: Wed, 5 Feb 2025 17:19:51 -0500 Subject: [PATCH] feat: update tests and spdxjson to omit empty Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> --- cmd/syft/internal/commands/attest_test.go | 3 +-- syft/format/common/spdxhelpers/to_syft_model.go | 2 +- syft/format/syftjson/model/document.go | 2 +- .../test-fixtures/snapshot/TestDirectoryEncoder.golden | 1 - .../test-fixtures/snapshot/TestEncodeFullJSONDocument.golden | 1 - .../syftjson/test-fixtures/snapshot/TestImageEncoder.golden | 1 - 6 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cmd/syft/internal/commands/attest_test.go b/cmd/syft/internal/commands/attest_test.go index b50cb0a66ea..41a26822664 100644 --- a/cmd/syft/internal/commands/attest_test.go +++ b/cmd/syft/internal/commands/attest_test.go @@ -72,8 +72,7 @@ func Test_writeSBOMToFormattedFile(t *testing.T) { "distro": {}, "descriptor": { "name": "syft-test", - "version": "non-version", - "supplier": "" + "version": "non-version" }, "schema": {} }`, diff --git a/syft/format/common/spdxhelpers/to_syft_model.go b/syft/format/common/spdxhelpers/to_syft_model.go index e34f2a66943..e593ff2d9e0 100644 --- a/syft/format/common/spdxhelpers/to_syft_model.go +++ b/syft/format/common/spdxhelpers/to_syft_model.go @@ -145,7 +145,7 @@ func containerSource(p *spdx.Package) source.Description { supplier := "" if p.PackageSupplier != nil { - // we also don't want NOASSERTION transfered to the syft format + // we also don't want NOASSERTION transferred to the syft format // NOASSERTION == "" if p.PackageSupplier.Supplier != helpers.NOASSERTION { supplier = p.PackageSupplier.Supplier diff --git a/syft/format/syftjson/model/document.go b/syft/format/syftjson/model/document.go index 52e1f0e0b88..0f5f578b70c 100644 --- a/syft/format/syftjson/model/document.go +++ b/syft/format/syftjson/model/document.go @@ -19,7 +19,7 @@ type Document struct { type Descriptor struct { Name string `json:"name"` Version string `json:"version"` - Supplier string `json:"supplier",omitempty` + Supplier string `json:"supplier,omitempty"` Configuration interface{} `json:"configuration,omitempty"` } diff --git a/syft/format/syftjson/test-fixtures/snapshot/TestDirectoryEncoder.golden b/syft/format/syftjson/test-fixtures/snapshot/TestDirectoryEncoder.golden index 92713390d4d..0ae05a3aa5f 100644 --- a/syft/format/syftjson/test-fixtures/snapshot/TestDirectoryEncoder.golden +++ b/syft/format/syftjson/test-fixtures/snapshot/TestDirectoryEncoder.golden @@ -99,7 +99,6 @@ "descriptor": { "name": "syft", "version": "v0.42.0-bogus", - "supplier": "", "configuration": { "config-key": "config-value" } diff --git a/syft/format/syftjson/test-fixtures/snapshot/TestEncodeFullJSONDocument.golden b/syft/format/syftjson/test-fixtures/snapshot/TestEncodeFullJSONDocument.golden index bdc6dad3026..6fc9041e9f1 100644 --- a/syft/format/syftjson/test-fixtures/snapshot/TestEncodeFullJSONDocument.golden +++ b/syft/format/syftjson/test-fixtures/snapshot/TestEncodeFullJSONDocument.golden @@ -199,7 +199,6 @@ "descriptor": { "name": "syft", "version": "v0.42.0-bogus", - "supplier": "", "configuration": { "config-key": "config-value" } diff --git a/syft/format/syftjson/test-fixtures/snapshot/TestImageEncoder.golden b/syft/format/syftjson/test-fixtures/snapshot/TestImageEncoder.golden index b7fd070aec2..5168d855cdc 100644 --- a/syft/format/syftjson/test-fixtures/snapshot/TestImageEncoder.golden +++ b/syft/format/syftjson/test-fixtures/snapshot/TestImageEncoder.golden @@ -122,7 +122,6 @@ "descriptor": { "name": "syft", "version": "v0.42.0-bogus", - "supplier": "", "configuration": { "config-key": "config-value" }