From 30d6eb53ac0693cbf356e19ab49a6ee621992f87 Mon Sep 17 00:00:00 2001 From: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> Date: Tue, 17 Sep 2024 12:29:20 -0400 Subject: [PATCH] feat: add fullText as optional field to syft model Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com> --- syft/file/license.go | 3 ++- syft/format/syftjson/model/package.go | 1 + syft/format/syftjson/to_format_model.go | 1 + syft/pkg/cataloger/ocaml/parse_opam_test.go | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/syft/file/license.go b/syft/file/license.go index 089bada6a..97e51b968 100644 --- a/syft/file/license.go +++ b/syft/file/license.go @@ -1,9 +1,10 @@ package file import ( + "strings" + "github.com/anchore/syft/internal/log" licensepkg "github.com/anchore/syft/syft/license" - "strings" ) type License struct { diff --git a/syft/format/syftjson/model/package.go b/syft/format/syftjson/model/package.go index 503709d1f..83cfe693d 100644 --- a/syft/format/syftjson/model/package.go +++ b/syft/format/syftjson/model/package.go @@ -48,6 +48,7 @@ type licenses []License type License struct { Value string `json:"value"` SPDXExpression string `json:"spdxExpression"` + FullText string `json:"fullText,omitempty"` Type license.Type `json:"type"` URLs []string `json:"urls"` Locations []file.Location `json:"locations"` diff --git a/syft/format/syftjson/to_format_model.go b/syft/format/syftjson/to_format_model.go index 42ec48f77..5ca86d3ef 100644 --- a/syft/format/syftjson/to_format_model.go +++ b/syft/format/syftjson/to_format_model.go @@ -225,6 +225,7 @@ func toLicenseModel(pkgLicenses []pkg.License) (modelLicenses []model.License) { modelLicenses = append(modelLicenses, model.License{ Value: l.Value, SPDXExpression: l.SPDXExpression, + FullText: l.FullText, Type: l.Type, URLs: urls, Locations: locations, diff --git a/syft/pkg/cataloger/ocaml/parse_opam_test.go b/syft/pkg/cataloger/ocaml/parse_opam_test.go index f25563be4..63b5fc9d3 100644 --- a/syft/pkg/cataloger/ocaml/parse_opam_test.go +++ b/syft/pkg/cataloger/ocaml/parse_opam_test.go @@ -3,11 +3,12 @@ package ocaml import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/file" "github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest" - "github.com/stretchr/testify/assert" ) func TestParseOpamPackage(t *testing.T) {