Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package grant for openSUSE:Factory checked in at 2026-11-17 17:20:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/grant (Old) and /work/SRC/openSUSE:Factory/.grant.new.1251 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "grant" Tue Nov 17 17:20:35 2026 rev:28 rq:1398067 version:0.8.0 Changes: -------- --- /work/SRC/openSUSE:Factory/grant/grant.changes 2026-11-10 14:44:44.660434090 +0100 +++ /work/SRC/openSUSE:Factory/.grant.new.1251/grant.changes 2026-11-17 17:23:11.472682167 +0100 @@ -1,0 +2,31 @@ +Tue Nov 17 06:09:24 UTC 2026 - Johannes Kastl <[email protected]> + +- Update to version 0.8.0: + * Added Features + - Request ability to ignore licenseConcluded [Issue #217] [PR + #638] + * Dependencies + 11 dependency changes (10 updated, 1 added). 1 vulnerability + remediated. + - Remediated (1) + - GHSA-q7gw-24fr-5p69 (Medium) — + go.opentelemetry.io/otel/sdk, + go.opentelemetry.io/otel/trace + - Updated (10 packages) + - github.com/anchore/stereoscope v0.4.1 → v0.4.2 + - github.com/anchore/syft v1.57.1 → v1.57.2 + - github.com/docker/cli v29.9.2+incompatible → + v29.9.3+incompatible + - go.opentelemetry.io/otel v1.46.0 → v1.47.0 + - go.opentelemetry.io/otel/metric v1.46.0 → v1.47.0 + - go.opentelemetry.io/otel/metric/x v0.68.0 → v0.69.0 + - go.opentelemetry.io/otel/sdk v1.46.0 → v1.47.0 + (remediated GHSA-q7gw-24fr-5p69) + - go.opentelemetry.io/otel/sdk/metric v1.46.0 → v1.47.0 + - go.opentelemetry.io/otel/trace v1.46.0 → v1.47.0 + (remediated GHSA-q7gw-24fr-5p69) + - modernc.org/sqlite v1.61.0 → v1.61.1 + - Added (1 package) + - go.opentelemetry.io/otel/log v1.47.0 + +------------------------------------------------------------------- Old: ---- grant-0.7.1.obscpio New: ---- grant-0.8.0.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ grant.spec ++++++ --- /var/tmp/diff_new_pack.Gwumas/_old 2026-11-17 17:23:15.302845224 +0100 +++ /var/tmp/diff_new_pack.Gwumas/_new 2026-11-17 17:23:15.303845266 +0100 @@ -17,7 +17,7 @@ Name: grant -Version: 0.7.1 +Version: 0.8.0 Release: 0 Summary: Search an SBOM for licenses and the packages they belong to License: Apache-2.0 @@ -26,7 +26,7 @@ Source1: vendor.tar.gz BuildRequires: bash-completion BuildRequires: fish -BuildRequires: go1.26 >= 1.26.3 +BuildRequires: go1.26 >= 1.26.8 BuildRequires: zsh %description ++++++ _service ++++++ --- /var/tmp/diff_new_pack.Gwumas/_old 2026-11-17 17:23:15.332846501 +0100 +++ /var/tmp/diff_new_pack.Gwumas/_new 2026-11-17 17:23:15.335846628 +0100 @@ -3,7 +3,7 @@ <param name="url">https://github.com/anchore/grant.git</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">refs/tags/v0.7.1</param> + <param name="revision">refs/tags/v0.8.0</param> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.Gwumas/_old 2026-11-17 17:23:15.356847523 +0100 +++ /var/tmp/diff_new_pack.Gwumas/_new 2026-11-17 17:23:15.359847650 +0100 @@ -3,6 +3,6 @@ <param name="url">https://github.com/anchore/grant</param> <param name="changesrevision">2d9a6408e4dc1fba0a41101dd9bfb5c8e2200d74</param></service><service name="tar_scm"> <param name="url">https://github.com/anchore/grant.git</param> - <param name="changesrevision">c87af8bb5165d4e9fe38b31c48d7eae4b4d68333</param></service></servicedata> + <param name="changesrevision">4ee1dddc6f0d585d7a2dd47a650eb623d9d417a0</param></service></servicedata> (No newline at EOF) ++++++ grant-0.7.1.obscpio -> grant-0.8.0.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/cmd/grant/cli/command/config.go new/grant-0.8.0/cmd/grant/cli/command/config.go --- old/grant-0.7.1/cmd/grant/cli/command/config.go 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/cmd/grant/cli/command/config.go 2026-11-16 22:58:47.000000000 +0100 @@ -20,10 +20,11 @@ Verbose bool `yaml:"verbose"` // Core policy configuration (fields from grant.Policy but without omitempty for booleans) - Allow []string `yaml:"allow,omitempty"` - IgnorePackages []string `yaml:"ignore-packages"` - RequireLicense bool `yaml:"require-license"` - RequireKnownLicense bool `yaml:"require-known-license"` + Allow []string `yaml:"allow,omitempty"` + IgnorePackages []string `yaml:"ignore-packages"` + RequireLicense bool `yaml:"require-license"` + RequireKnownLicense bool `yaml:"require-known-license"` + IgnoreConcludedLicenses bool `yaml:"ignore-concluded-licenses"` // Command-specific options DisableFileSearch bool `yaml:"disable-file-search"` @@ -93,12 +94,13 @@ "Apache-2.0", "BSD-3-Clause", }, - IgnorePackages: []string{}, - RequireLicense: true, - RequireKnownLicense: false, - DisableFileSearch: false, - Summary: false, - OnlyUnlicensed: false, + IgnorePackages: []string{}, + RequireLicense: true, + RequireKnownLicense: false, + IgnoreConcludedLicenses: false, + DisableFileSearch: false, + Summary: false, + OnlyUnlicensed: false, } // Generate YAML with comments @@ -176,6 +178,8 @@ ` + line + " # When true, deny packages with no detected licenses\n") case "require-known-license:": result.WriteString(line + " # When true, deny non-SPDX / unparsable licenses\n") + case "ignore-concluded-licenses:": + result.WriteString(line + " # When true, ignore concluded licenses and only consider declared licenses\n") case "disable-file-search:": result.WriteString(` # ============================================================================ @@ -196,7 +200,7 @@ func getFieldName(line string) string { for _, prefix := range []string{ "config:", "format:", "quiet:", "verbose:", "allow:", "ignore-packages:", - "require-license:", "require-known-license:", "disable-file-search:", + "require-license:", "require-known-license:", "ignore-concluded-licenses:", "disable-file-search:", "summary:", "only-unlicensed:", } { if strings.HasPrefix(line, prefix) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/cmd/grant/cli/internal/config.go new/grant-0.8.0/cmd/grant/cli/internal/config.go --- old/grant-0.7.1/cmd/grant/cli/internal/config.go 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/cmd/grant/cli/internal/config.go 2026-11-16 22:58:47.000000000 +0100 @@ -166,8 +166,9 @@ # - "mycompany-*" # Policy options -require-license: true # Deny packages with no detected licenses -require-known-license: false # Deny non-SPDX / unparsable licenses +require-license: true # Deny packages with no detected licenses +require-known-license: false # Deny non-SPDX / unparsable licenses +ignore-concluded-licenses: false # Ignore concluded licenses and only consider declared licenses ` // Create directory if it doesn't exist diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/go.mod new/grant-0.8.0/go.mod --- old/grant-0.7.1/go.mod 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/go.mod 2026-11-16 22:58:47.000000000 +0100 @@ -7,8 +7,8 @@ github.com/anchore/go-collections v0.1.1 github.com/anchore/go-logger v0.2.0 github.com/anchore/packageurl-go v0.2.0 - github.com/anchore/stereoscope v0.4.1 - github.com/anchore/syft v1.57.1 + github.com/anchore/stereoscope v0.4.2 + github.com/anchore/syft v1.57.2 github.com/cyphar/filepath-securejoin v0.7.0 github.com/github/go-spdx/v2 v2.8.0 github.com/google/licenseclassifier/v2 v2.0.0 @@ -22,7 +22,7 @@ github.com/wagoodman/go-progress v0.0.0-20260303201901-10176f79b2c0 golang.org/x/term v0.47.0 gopkg.in/yaml.v3 v3.0.1 - modernc.org/sqlite v1.61.0 + modernc.org/sqlite v1.61.1 ) require ( @@ -125,7 +125,7 @@ github.com/deitch/magic v1.0.0 // indirect github.com/diskfs/go-diskfs v1.9.4 // indirect github.com/distribution/reference v0.6.0 // indirect - github.com/docker/cli v29.9.2+incompatible // indirect + github.com/docker/cli v29.9.3+incompatible // indirect github.com/docker/docker-credential-helpers v0.9.10 // indirect github.com/docker/go-connections v0.8.2 // indirect github.com/docker/go-units v0.5.0 // indirect @@ -278,11 +278,12 @@ go.opentelemetry.io/contrib/detectors/gcp v1.44.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.71.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0 // indirect - go.opentelemetry.io/otel v1.46.0 // indirect - go.opentelemetry.io/otel/metric v1.46.0 // indirect - go.opentelemetry.io/otel/sdk v1.46.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.46.0 // indirect - go.opentelemetry.io/otel/trace v1.46.0 // indirect + go.opentelemetry.io/otel v1.47.0 // indirect + go.opentelemetry.io/otel/log v1.47.0 // indirect + go.opentelemetry.io/otel/metric v1.47.0 // indirect + go.opentelemetry.io/otel/sdk v1.47.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.47.0 // indirect + go.opentelemetry.io/otel/trace v1.47.0 // indirect go.podman.io/image/v5 v5.42.0 // indirect go.podman.io/storage v1.65.0 // indirect go.yaml.in/yaml/v3 v3.0.6 // indirect diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/go.sum new/grant-0.8.0/go.sum --- old/grant-0.7.1/go.sum 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/go.sum 2026-11-16 22:58:47.000000000 +0100 @@ -148,10 +148,10 @@ github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b/go.mod h1:Bkc+JYWjMCF8OyZ340IMSIi2Ebf3uwByOk6ho4wne1E= github.com/anchore/packageurl-go v0.2.0 h1:CkrM4RMUwrEGAiE1OVlxaZNzWj0TuHRey7o4T/EAErk= github.com/anchore/packageurl-go v0.2.0/go.mod h1:2JCgOQMIsqZ7TmliXG4PnUthPJAKE3mWQbsW2XHjAOE= -github.com/anchore/stereoscope v0.4.1 h1:7mxw24JCabbJIAcyvQDjBd2pbzo+0HSFVgjYlE8Zm+k= -github.com/anchore/stereoscope v0.4.1/go.mod h1:hYJsi3M8a8N1O66u+rMQSgv5TREGM7QIjKBjPPnwiD8= -github.com/anchore/syft v1.57.1 h1:lrbWhc8hbZJSKekMdB3PKetO0upE+lv9ihUfv9CXgfU= -github.com/anchore/syft v1.57.1/go.mod h1:PHj+bXUGr1sxpMLsuogjX86P5wZ+A+XZRY6WgfsIgnE= +github.com/anchore/stereoscope v0.4.2 h1:tiLX01TpChU4+k1Jlv+uwF5lVdSCJVKuh8hQXl8iqQI= +github.com/anchore/stereoscope v0.4.2/go.mod h1:Cru29+t2nps1BJxWzAEc4RN9RQI7AAizzoCVM9cheR0= +github.com/anchore/syft v1.57.2 h1:Vm+22QHzQfwy9WBlWeGOWBSByH6dt6SEjxrfOvQZsfM= +github.com/anchore/syft v1.57.2/go.mod h1:mJYUdqH4fYE1GHl/Qcw0d8M0+0GND1awsCi876ULI1I= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/andybalholm/brotli v1.2.8 h1:H9F6r7RNwzSRsx/lytpIYkbjNFMt2yNBwsJ2+0gpx78= github.com/andybalholm/brotli v1.2.8/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= @@ -337,8 +337,8 @@ github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c= github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0= -github.com/docker/cli v29.9.2+incompatible h1:trup/vUxx5uUo2t+87Cd9AmITR+DvKUe4H2tTtZN8FY= -github.com/docker/cli v29.9.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v29.9.3+incompatible h1:SBaMp7ecohadEHMDrUJg22t9I3awqsAVhnJ7GOcWpfE= +github.com/docker/cli v29.9.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker-credential-helpers v0.9.10 h1:LCWwv7UmS7fQVmdKDWeMuureOeY5kkbC5kZfkzxkS6k= @@ -1026,20 +1026,22 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.71.0/go.mod h1:dylvB+ZiiwMvsDij9O84Uy7SijLgHMX4mbkncds+4Sw= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0 h1:3g7B90UzBltIDKq1/5mrTGxTnOFDV0ICOhLoxiZ8jlg= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.71.0/go.mod h1:Ef8SuTh59BT7+ofpDxN9z+yOlc4t2GjLmKDgYNJL/NU= -go.opentelemetry.io/otel v1.46.0 h1:FHt5/CDyVxi/8IM1CH7VE/rRgq3kLHa2mSTVMO8AWyc= -go.opentelemetry.io/otel v1.46.0/go.mod h1:Gj3SEScelsNC45tp4nSxRYlS+f5iez7W8XPMCt905kE= +go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM= +go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.44.0 h1:hqxVTu/GtBF+vJ8d1fzW7fRxZFvgoDjWcxwwCaFDYpU= go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.44.0/go.mod h1:z5fVEF4X5v0ESvlJqBrrFlBVoj5EQuefZpzsu7R+x5Q= -go.opentelemetry.io/otel/metric v1.46.0 h1:yBnkXvgV7AXFILZc5K6IZe/CBFF3OS7BJ8ov6/lj0K8= -go.opentelemetry.io/otel/metric v1.46.0/go.mod h1:iPmdWqifKUdzziPkvvzIJXITl56fQx2mGM/DHLB3/2o= -go.opentelemetry.io/otel/metric/x v0.68.0 h1:TA/cBT23D3MnxYPwHL7YFOdYGdx0A0v+s7Mzotpd1dU= -go.opentelemetry.io/otel/metric/x v0.68.0/go.mod h1:agudOmvWhwUTjgibWDzxD2PoWYnpw5Ht5jISYOD2Hd4= -go.opentelemetry.io/otel/sdk v1.46.0 h1:h5CNQQjEbuQXY/JfZtgt3i7HVFV3aHPO2OAwO2eTYPI= -go.opentelemetry.io/otel/sdk v1.46.0/go.mod h1:GAERFXFt5SYCEB+YiKUbMBeza6UaDH7GmGOZEfh2gSM= -go.opentelemetry.io/otel/sdk/metric v1.46.0 h1:0piZ26EG4RBfebb2jhDH6ERCYHoVWduc3kLgPCwSnSE= -go.opentelemetry.io/otel/sdk/metric v1.46.0/go.mod h1:I1PbKrdVc8Qu8HYVDNtqVIwLwjNrhsV/uFuxfwg8mO4= -go.opentelemetry.io/otel/trace v1.46.0 h1:OULy7ccdJnZtJ0UDYFOIGaCmiWzJ8Vi2G/Rsu60qs1c= -go.opentelemetry.io/otel/trace v1.46.0/go.mod h1:J7GAXweO77XSFkB/rmAqk9D6ihszhFjLU+d9WuUxDLI= +go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI= +go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw= +go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY= +go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU= +go.opentelemetry.io/otel/metric/x v0.69.0 h1:DjRLr15H83v+hCW7JA9NoJvOkYTtmq5YoDRbe9deYpM= +go.opentelemetry.io/otel/metric/x v0.69.0/go.mod h1:uVvsMPMFFyj/HUQfrUnH3JjnOQ1dwFDorgFLRBasM0k= +go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I= +go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0= +go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV3jdXtsPnKw= +go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw= +go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM= +go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.podman.io/image/v5 v5.42.0 h1:C//Ix0Thj2LYOQO6++NjU3McLFLQbf4czgUyH98R9gc= go.podman.io/image/v5 v5.42.0/go.mod h1:mmIgf9EdpF68j8vdX1/OxhOSIknU1PO3G6/ClRkrwm4= @@ -1598,8 +1600,8 @@ modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= -modernc.org/sqlite v1.61.0 h1:sQi63oLQ9uquAUA4CzOisH35Q3pEszkPBuHM0tFL8CY= -modernc.org/sqlite v1.61.0/go.mod h1:f4gr5tbpx2umklaT/QVtbi/50hNdM+4ng+2zMo8KXJ0= +modernc.org/sqlite v1.61.1 h1:TBEE49wz7VlxS+qXRXMQiPUZYOXHJ4ku83daYv1fe04= +modernc.org/sqlite v1.61.1/go.mod h1:f4gr5tbpx2umklaT/QVtbi/50hNdM+4ng+2zMo8KXJ0= modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/grant/case.go new/grant-0.8.0/grant/case.go --- old/grant-0.7.1/grant/case.go 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/grant/case.go 2026-11-16 22:58:47.000000000 +0100 @@ -75,20 +75,33 @@ Package *Package } +// GetLicenses returns the packages of the case keyed by license, the licenses by name, and the +// packages without licenses. It takes no policy, so it always includes concluded licenses: +// Policy.IgnoreConcludedLicenses is applied by Case.Evaluate, Orchestrator.Check and +// Orchestrator.List. func (c Case) GetLicenses() (map[string][]*Package, map[string]License, []Package) { - licensePackages, licenses, packagesNoLicenses, _ := c.getLicenses() + licensePackages, licenses, packagesNoLicenses, _ := c.getLicenses(false) return licensePackages, licenses, packagesNoLicenses } // getLicenses is GetLicenses plus the license declarations of each package with licenses, which -// evaluation needs to apply SPDX expression operators -func (c Case) getLicenses() (map[string][]*Package, map[string]License, []Package, declarations) { +// evaluation needs to apply SPDX expression operators. With ignoreConcluded, concluded licenses are +// dropped before conversion (see Policy.IgnoreConcludedLicenses), so a package whose only licenses +// are concluded is returned as a package without licenses. What was dropped is logged, since nothing +// in the result records it. +func (c Case) getLicenses(ignoreConcluded bool) (map[string][]*Package, map[string]License, []Package, declarations) { + var ignored ignoredConcluded declared := make(declarations) licensePackages := make(map[string][]*Package) licenses := make(map[string]License) packagesNoLicenses := make([]Package, 0) for _, sb := range c.SBOMS { for pkg := range sb.Artifacts.Packages.Enumerate() { + if ignoreConcluded { + var dropped int + pkg.Licenses, dropped = withoutConcludedLicenses(pkg.Licenses) + ignored.add(dropped, pkg.Licenses.Empty()) + } grantPkg, terms := convertSyftPackage(pkg) // TODO: how do we express packages without licenses in list if len(grantPkg.Licenses) == 0 { @@ -99,10 +112,45 @@ buildLicenseMaps(licensePackages, licenses, grantPkg) } } + ignored.log() return licensePackages, licenses, packagesNoLicenses, declared } +// ignoredConcluded counts what Policy.IgnoreConcludedLicenses removed from a case +type ignoredConcluded struct { + // licenses is the number of concluded licenses dropped + licenses int + // packages is the number of packages that had a concluded license dropped + packages int + // unlicensed is the number of those packages left with no licenses + unlicensed int +} + +func (i *ignoredConcluded) add(dropped int, leftUnlicensed bool) { + if dropped == 0 { + return + } + i.licenses += dropped + i.packages++ + if leftUnlicensed { + i.unlicensed++ + } +} + +func (i ignoredConcluded) String() string { + return fmt.Sprintf("ignored %d concluded licenses on %d packages, %d of which are left with no licenses", + i.licenses, i.packages, i.unlicensed) +} + +// log reports what was ignored: the output of a run does not otherwise show that a package had +// licenses that were dropped +func (i ignoredConcluded) log() { + if i.licenses > 0 { + log.Infof("ignore-concluded-licenses: %s", i) + } +} + func buildLicenseMaps(licensePackages map[string][]*Package, licenses map[string]License, pkg *Package) { for _, license := range pkg.Licenses { if license.IsSPDX() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/grant/concluded_licenses_test.go new/grant-0.8.0/grant/concluded_licenses_test.go --- old/grant-0.7.1/grant/concluded_licenses_test.go 1970-01-01 01:00:00.000000000 +0100 +++ new/grant-0.8.0/grant/concluded_licenses_test.go 2026-11-16 22:58:47.000000000 +0100 @@ -0,0 +1,319 @@ +package grant + +import ( + "encoding/json" + "path/filepath" + "testing" + + "github.com/anchore/syft/syft/license" + "github.com/anchore/syft/syft/pkg" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// The SBOMs under testdata/tomcat-9.0.98-jdk17 were generated by syft 1.51.1 from the image of +// https://github.com/anchore/grant/issues/217 (tomcat:9.0.98-jdk17), one per format from the same +// scan, and trimmed to four packages and the fields grant reads: +// +// - libexpat1: declared MIT +// - fontconfig: concluded HPND-sell-variant, nothing declared +// - libapr1t64: concluded Apache-2.0, BSD-4-Clause-UC, ISC and Zlib, nothing declared +// - openssl: no licenses +// +// SPDX JSON and syft JSON record which licenses are concluded. CycloneDX as written and decoded by +// syft does not, so every license in it is read as declared. +const ( + tomcatSPDX = "sbom.spdx.json" + tomcatSyftJSON = "sbom.syft.json" + tomcatCycloneDX = "sbom.cdx.json" +) + +func tomcatSBOM(name string) string { + return filepath.Join("testdata", "tomcat-9.0.98-jdk17", name) +} + +// concludedFinding is the part of a package finding these tests look at +type concludedFinding struct { + decision string + licenses []string +} + +func findingsByPackage(t *testing.T, response *RunResponse) (TargetEvaluation, map[string]concludedFinding) { + t.Helper() + require.Len(t, response.Run.Targets, 1) + evaluation := response.Run.Targets[0].Evaluation + + findings := make(map[string]concludedFinding) + for _, p := range evaluation.Findings.Packages { + f := concludedFinding{decision: p.Decision, licenses: []string{}} + for _, l := range p.Licenses { + f.licenses = append(f.licenses, l.ID) + } + findings[p.Name] = f + } + return evaluation, findings +} + +func assertConcludedFindings(t *testing.T, want, got map[string]concludedFinding) { + t.Helper() + require.Len(t, got, len(want)) + for name, w := range want { + g, ok := got[name] + if !assert.True(t, ok, "package %q missing from the findings", name) { + continue + } + assert.Equal(t, w.decision, g.decision, "decision for %q", name) + assert.ElementsMatch(t, w.licenses, g.licenses, "licenses for %q", name) + } +} + +func TestCheck_IgnoreConcludedLicenses(t *testing.T) { + allow := []string{"MIT", "Apache-2.0"} + + // what every format reports when concluded licenses are judged like declared ones: a denied + // package lists the licenses that denied it + concludedJudged := map[string]concludedFinding{ + "libexpat1": {decision: DecisionAllow, licenses: []string{"MIT"}}, + "openssl": {decision: DecisionAllow, licenses: []string{}}, + "fontconfig": {decision: DecisionDeny, licenses: []string{"HPND-sell-variant"}}, + "libapr1t64": {decision: DecisionDeny, licenses: []string{"BSD-4-Clause-UC", "ISC", "Zlib"}}, + } + concludedIgnored := map[string]concludedFinding{ + "libexpat1": {decision: DecisionAllow, licenses: []string{"MIT"}}, + "openssl": {decision: DecisionAllow, licenses: []string{}}, + "fontconfig": {decision: DecisionAllow, licenses: []string{}}, + "libapr1t64": {decision: DecisionAllow, licenses: []string{}}, + } + + tests := []struct { + name string + sbom string + policy *Policy + wantStatus string + wantUnlicensed int + wantFindings map[string]concludedFinding + }{ + // the option is unset: this is the behavior grant had before the option existed + { + name: "SPDX by default", + sbom: tomcatSPDX, + policy: &Policy{Allow: allow}, + wantStatus: StatusNonCompliant, + wantUnlicensed: 1, + wantFindings: concludedJudged, + }, + { + name: "syft JSON by default", + sbom: tomcatSyftJSON, + policy: &Policy{Allow: allow}, + wantStatus: StatusNonCompliant, + wantUnlicensed: 1, + wantFindings: concludedJudged, + }, + { + name: "CycloneDX by default", + sbom: tomcatCycloneDX, + policy: &Policy{Allow: allow}, + wantStatus: StatusNonCompliant, + wantUnlicensed: 1, + wantFindings: concludedJudged, + }, + { + name: "SPDX ignoring concluded", + sbom: tomcatSPDX, + policy: &Policy{Allow: allow, IgnoreConcludedLicenses: true}, + wantStatus: StatusCompliant, + wantUnlicensed: 3, + wantFindings: concludedIgnored, + }, + { + name: "syft JSON ignoring concluded", + sbom: tomcatSyftJSON, + policy: &Policy{Allow: allow, IgnoreConcludedLicenses: true}, + wantStatus: StatusCompliant, + wantUnlicensed: 3, + wantFindings: concludedIgnored, + }, + { + // CycloneDX does not say which licenses are concluded, so nothing is ignored + name: "CycloneDX ignoring concluded", + sbom: tomcatCycloneDX, + policy: &Policy{Allow: allow, IgnoreConcludedLicenses: true}, + wantStatus: StatusNonCompliant, + wantUnlicensed: 1, + wantFindings: concludedJudged, + }, + { + // a package left with no licenses is subject to require-license like any other + name: "SPDX ignoring concluded with require-license", + sbom: tomcatSPDX, + policy: &Policy{Allow: allow, IgnoreConcludedLicenses: true, RequireLicense: true}, + wantStatus: StatusNonCompliant, + wantUnlicensed: 3, + wantFindings: map[string]concludedFinding{ + "libexpat1": {decision: DecisionAllow, licenses: []string{"MIT"}}, + "openssl": {decision: DecisionDeny, licenses: []string{}}, + "fontconfig": {decision: DecisionDeny, licenses: []string{}}, + "libapr1t64": {decision: DecisionDeny, licenses: []string{}}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + orchestrator, err := NewOrchestrator(tt.policy) + require.NoError(t, err) + defer orchestrator.Close() + + response, err := orchestrator.Check([]string{"grant", "check"}, tomcatSBOM(tt.sbom)) + require.NoError(t, err) + + evaluation, findings := findingsByPackage(t, response) + assert.Equal(t, tt.wantStatus, evaluation.Status) + assert.Equal(t, 4, evaluation.Summary.Packages.Total) + assert.Equal(t, tt.wantUnlicensed, evaluation.Summary.Packages.Unlicensed) + assertConcludedFindings(t, tt.wantFindings, findings) + }) + } +} + +func TestList_IgnoreConcludedLicenses(t *testing.T) { + declaredOnly := map[string]concludedFinding{ + "libexpat1": {decision: DecisionUnevaluated, licenses: []string{"MIT"}}, + "openssl": {decision: DecisionUnevaluated, licenses: []string{}}, + "fontconfig": {decision: DecisionUnevaluated, licenses: []string{}}, + "libapr1t64": {decision: DecisionUnevaluated, licenses: []string{}}, + } + everyLicense := map[string]concludedFinding{ + "libexpat1": {decision: DecisionUnevaluated, licenses: []string{"MIT"}}, + "openssl": {decision: DecisionUnevaluated, licenses: []string{}}, + "fontconfig": {decision: DecisionUnevaluated, licenses: []string{"HPND-sell-variant"}}, + "libapr1t64": {decision: DecisionUnevaluated, licenses: []string{"Apache-2.0", "BSD-4-Clause-UC", "ISC", "Zlib"}}, + } + + tests := []struct { + name string + policy *Policy + wantUniqueLicenses int + wantUnlicensed int + wantFindings map[string]concludedFinding + }{ + { + name: "by default", + policy: &Policy{}, + wantUniqueLicenses: 6, + wantUnlicensed: 1, + wantFindings: everyLicense, + }, + { + name: "ignoring concluded", + policy: &Policy{IgnoreConcludedLicenses: true}, + wantUniqueLicenses: 1, + wantUnlicensed: 3, + wantFindings: declaredOnly, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + orchestrator, err := NewOrchestrator(tt.policy) + require.NoError(t, err) + defer orchestrator.Close() + + response, err := orchestrator.List([]string{"grant", "list"}, tomcatSBOM(tomcatSPDX)) + require.NoError(t, err) + + evaluation, findings := findingsByPackage(t, response) + assert.Equal(t, tt.wantUniqueLicenses, evaluation.Summary.Licenses.Unique) + assert.Equal(t, tt.wantUnlicensed, evaluation.Summary.Packages.Unlicensed) + assertConcludedFindings(t, tt.wantFindings, findings) + }) + } +} + +func TestLoadPolicy_IgnoreConcludedLicenses(t *testing.T) { + policy, err := LoadPolicy([]byte("allow:\n - MIT\n")) + require.NoError(t, err) + assert.False(t, policy.IgnoreConcludedLicenses, "the option is off unless the policy sets it") + + policy, err = LoadPolicy([]byte("allow:\n - MIT\nignore-concluded-licenses: true\n")) + require.NoError(t, err) + assert.True(t, policy.IgnoreConcludedLicenses) +} + +func TestRunResponse_PolicyJSON_IgnoreConcludedLicenses(t *testing.T) { + policyJSON := func(policy *Policy) string { + encoded, err := json.Marshal(NewRunResponse(nil, policy).Run.Policy) + require.NoError(t, err) + return string(encoded) + } + + // the report of a run without the option has exactly the fields it had before the option existed + assert.JSONEq(t, + `{"rules":{"allow":["MIT"],"ignorePackages":null},"requireLicense":true,"requireKnownLicense":false}`, + policyJSON(&Policy{Allow: []string{"MIT"}, RequireLicense: true})) + + assert.JSONEq(t, + `{"rules":{"allow":["MIT"],"ignorePackages":null},"requireLicense":true,"requireKnownLicense":false,"ignoreConcludedLicenses":true}`, + policyJSON(&Policy{Allow: []string{"MIT"}, RequireLicense: true, IgnoreConcludedLicenses: true})) +} + +func TestWithoutConcludedLicenses(t *testing.T) { + declared := func(value string) pkg.License { + return pkg.License{Value: value, SPDXExpression: value, Type: license.Declared} + } + concluded := func(value string) pkg.License { + return pkg.License{Value: value, SPDXExpression: value, Type: license.Concluded} + } + + tests := []struct { + name string + licenses []pkg.License + want []pkg.License + wantDropped int + }{ + { + name: "no licenses", + want: []pkg.License{}, + }, + { + name: "declared only", + licenses: []pkg.License{declared("MIT")}, + want: []pkg.License{declared("MIT")}, + }, + { + name: "concluded only", + licenses: []pkg.License{concluded("MIT"), concluded("ISC")}, + want: []pkg.License{}, + wantDropped: 2, + }, + { + // the same license declared and concluded is two entries, and the declared one stays + name: "same license declared and concluded", + licenses: []pkg.License{declared("MIT"), concluded("MIT")}, + want: []pkg.License{declared("MIT")}, + wantDropped: 1, + }, + { + // only an explicit concluded type is dropped + name: "no type", + licenses: []pkg.License{{Value: "MIT", SPDXExpression: "MIT"}}, + want: []pkg.License{{Value: "MIT", SPDXExpression: "MIT"}}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, dropped := withoutConcludedLicenses(pkg.NewLicenseSet(tt.licenses...)) + assert.Equal(t, tt.wantDropped, dropped) + assert.ElementsMatch(t, pkg.NewLicenseSet(tt.want...).ToSlice(), got.ToSlice()) + }) + } +} + +func TestIgnoredConcluded(t *testing.T) { + var ignored ignoredConcluded + ignored.add(0, true) // a package with no licenses to begin with is not counted + ignored.add(2, true) + ignored.add(1, false) + + assert.Equal(t, ignoredConcluded{licenses: 3, packages: 2, unlicensed: 1}, ignored) + assert.Equal(t, "ignored 3 concluded licenses on 2 packages, 1 of which are left with no licenses", ignored.String()) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/grant/evaluation.go new/grant-0.8.0/grant/evaluation.go --- old/grant-0.7.1/grant/evaluation.go 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/grant/evaluation.go 2026-11-16 22:58:47.000000000 +0100 @@ -69,7 +69,7 @@ } // Get all licenses and packages from the case - licensePackages, _, packagesNoLicenses, declared := c.getLicenses() + licensePackages, _, packagesNoLicenses, declared := c.getLicenses(policy.IgnoreConcludedLicenses) // An SBOM can catalog the same package more than once: the same // version may appear with a license from one source and without a license from diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/grant/license.go new/grant-0.8.0/grant/license.go --- old/grant-0.7.1/grant/license.go 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/grant/license.go 2026-11-16 22:58:47.000000000 +0100 @@ -8,6 +8,7 @@ "github.com/anchore/grant/internal/log" "github.com/anchore/grant/internal/spdxlicense" + syftLicense "github.com/anchore/syft/syft/license" syftPkg "github.com/anchore/syft/syft/pkg" ) @@ -265,3 +266,17 @@ } return true } + +// withoutConcludedLicenses returns the licenses of the set that are not concluded, and how many were +// dropped. A concluded license is what a scanner or the author of the SBOM determined, for example +// by classifying license text, as opposed to what the package's metadata declares. +func withoutConcludedLicenses(set syftPkg.LicenseSet) (syftPkg.LicenseSet, int) { + all := set.ToUnorderedSlice() + kept := make([]syftPkg.License, 0, len(all)) + for _, l := range all { + if l.Type != syftLicense.Concluded { + kept = append(kept, l) + } + } + return syftPkg.NewLicenseSet(kept...), len(all) - len(kept) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/grant/orchestrator.go new/grant-0.8.0/grant/orchestrator.go --- old/grant-0.7.1/grant/orchestrator.go 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/grant/orchestrator.go 2026-11-16 22:58:47.000000000 +0100 @@ -130,8 +130,8 @@ return createErrorTargetEvaluation() } - licensePackages, licenses, packagesNoLicenses := c.GetLicenses() - // GetLicenses keys packages by license, so a package with more than one + licensePackages, licenses, packagesNoLicenses, _ := c.getLicenses(o.Policy.IgnoreConcludedLicenses) + // getLicenses keys packages by license, so a package with more than one // license appears under each of them. Merge first, the same way Evaluate // does, so each real package is listed and counted exactly once. packages, _ := mergeDuplicatePackages(licensePackages, packagesNoLicenses, nil) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/grant/policy.go new/grant-0.8.0/grant/policy.go --- old/grant-0.7.1/grant/policy.go 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/grant/policy.go 2026-11-16 22:58:47.000000000 +0100 @@ -31,6 +31,14 @@ // RequireKnownLicense when true, denies non-SPDX / unparsable licenses RequireKnownLicense bool `yaml:"require-known-license,omitempty"` + + // IgnoreConcludedLicenses when true, leaves concluded licenses (SPDX licenseConcluded, syft license + // type "concluded") out of Case.Evaluate, Orchestrator.Check and Orchestrator.List, so only declared + // licenses are considered. Case.GetLicenses takes no policy and still returns them. A package + // whose only licenses are concluded is then treated as having no licenses, which RequireLicense + // decides. SBOM formats that do not record the distinction (CycloneDX as decoded by syft) are read + // as declared. + IgnoreConcludedLicenses bool `yaml:"ignore-concluded-licenses,omitempty"` } // IsLicensePermitted checks if a license string matches an allow entry, literally or as a glob. It diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/grant/response.go new/grant-0.8.0/grant/response.go --- old/grant-0.7.1/grant/response.go 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/grant/response.go 2026-11-16 22:58:47.000000000 +0100 @@ -40,6 +40,8 @@ Rules PolicyRules `json:"rules"` RequireLicense bool `json:"requireLicense"` RequireKnownLicense bool `json:"requireKnownLicense"` + // IgnoreConcludedLicenses is only present when the option is set + IgnoreConcludedLicenses bool `json:"ignoreConcludedLicenses,omitempty"` } // PolicyRules contains the allow and ignore rules @@ -142,8 +144,9 @@ Allow: policy.Allow, IgnorePackages: policy.IgnorePackages, }, - RequireLicense: policy.RequireLicense, - RequireKnownLicense: policy.RequireKnownLicense, + RequireLicense: policy.RequireLicense, + RequireKnownLicense: policy.RequireKnownLicense, + IgnoreConcludedLicenses: policy.IgnoreConcludedLicenses, }, Targets: []TargetResult{}, }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/grant/testdata/tomcat-9.0.98-jdk17/sbom.cdx.json new/grant-0.8.0/grant/testdata/tomcat-9.0.98-jdk17/sbom.cdx.json --- old/grant-0.7.1/grant/testdata/tomcat-9.0.98-jdk17/sbom.cdx.json 1970-01-01 01:00:00.000000000 +0100 +++ new/grant-0.8.0/grant/testdata/tomcat-9.0.98-jdk17/sbom.cdx.json 2026-11-16 22:58:47.000000000 +0100 @@ -0,0 +1,92 @@ +{ + "$schema": "http://cyclonedx.org/schema/bom-1.7.schema.json", + "bomFormat": "CycloneDX", + "specVersion": "1.7", + "serialNumber": "urn:uuid:e79ddd89-c3ce-46dc-9155-d7814aa0b754", + "version": 1, + "metadata": { + "timestamp": "2026-11-16T09:57:58-05:00", + "tools": { + "components": [ + { + "type": "application", + "author": "anchore", + "name": "syft", + "version": "1.51.1" + } + ] + }, + "component": { + "bom-ref": "ca03ef8431c44cdb", + "type": "container", + "name": "tomcat", + "version": "9.0.98-jdk17" + } + }, + "components": [ + { + "bom-ref": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04&package-id=39255e9e59685b5f", + "type": "library", + "name": "fontconfig", + "version": "2.15.0-1.1ubuntu2", + "licenses": [ + { + "license": { + "id": "HPND-sell-variant" + } + } + ], + "purl": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04" + }, + { + "bom-ref": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04&package-id=8736998fcaef3ad3&upstream=apr", + "type": "library", + "name": "libapr1t64", + "version": "1.7.2-3.1ubuntu0.1", + "licenses": [ + { + "license": { + "id": "Apache-2.0" + } + }, + { + "license": { + "id": "BSD-4-Clause-UC" + } + }, + { + "license": { + "id": "ISC" + } + }, + { + "license": { + "id": "Zlib" + } + } + ], + "purl": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04&upstream=apr" + }, + { + "bom-ref": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04&package-id=786e451bdf925775&upstream=expat", + "type": "library", + "name": "libexpat1", + "version": "2.6.1-2ubuntu0.2", + "licenses": [ + { + "license": { + "id": "MIT" + } + } + ], + "purl": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04&upstream=expat" + }, + { + "bom-ref": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04&package-id=a53bac2593393e6b", + "type": "library", + "name": "openssl", + "version": "3.0.13-0ubuntu3.4", + "purl": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04" + } + ] +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/grant/testdata/tomcat-9.0.98-jdk17/sbom.spdx.json new/grant-0.8.0/grant/testdata/tomcat-9.0.98-jdk17/sbom.spdx.json --- old/grant-0.7.1/grant/testdata/tomcat-9.0.98-jdk17/sbom.spdx.json 1970-01-01 01:00:00.000000000 +0100 +++ new/grant-0.8.0/grant/testdata/tomcat-9.0.98-jdk17/sbom.spdx.json 2026-11-16 22:58:47.000000000 +0100 @@ -0,0 +1,49 @@ +{ + "spdxVersion": "SPDX-2.3", + "dataLicense": "CC0-1.0", + "SPDXID": "SPDXRef-DOCUMENT", + "name": "tomcat", + "documentNamespace": "https://anchore.com/syft/image/tomcat-557e69a9-b4b0-43e1-bf44-7f2d8a9d16ba", + "creationInfo": { + "licenseListVersion": "3.28", + "creators": [ + "Organization: Anchore, Inc", + "Tool: syft-1.51.1" + ], + "created": "2026-11-16T14:57:58Z" + }, + "packages": [ + { + "name": "fontconfig", + "SPDXID": "SPDXRef-Package-deb-fontconfig-39255e9e59685b5f", + "versionInfo": "2.15.0-1.1ubuntu2", + "downloadLocation": "NOASSERTION", + "licenseConcluded": "HPND-sell-variant", + "licenseDeclared": "NOASSERTION" + }, + { + "name": "libapr1t64", + "SPDXID": "SPDXRef-Package-deb-libapr1t64-8736998fcaef3ad3", + "versionInfo": "1.7.2-3.1ubuntu0.1", + "downloadLocation": "NOASSERTION", + "licenseConcluded": "Apache-2.0 AND BSD-4-Clause-UC AND ISC AND Zlib", + "licenseDeclared": "NOASSERTION" + }, + { + "name": "libexpat1", + "SPDXID": "SPDXRef-Package-deb-libexpat1-786e451bdf925775", + "versionInfo": "2.6.1-2ubuntu0.2", + "downloadLocation": "NOASSERTION", + "licenseConcluded": "NOASSERTION", + "licenseDeclared": "MIT" + }, + { + "name": "openssl", + "SPDXID": "SPDXRef-Package-deb-openssl-a53bac2593393e6b", + "versionInfo": "3.0.13-0ubuntu3.4", + "downloadLocation": "NOASSERTION", + "licenseConcluded": "NOASSERTION", + "licenseDeclared": "NOASSERTION" + } + ] +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/grant/testdata/tomcat-9.0.98-jdk17/sbom.syft.json new/grant-0.8.0/grant/testdata/tomcat-9.0.98-jdk17/sbom.syft.json --- old/grant-0.7.1/grant/testdata/tomcat-9.0.98-jdk17/sbom.syft.json 1970-01-01 01:00:00.000000000 +0100 +++ new/grant-0.8.0/grant/testdata/tomcat-9.0.98-jdk17/sbom.syft.json 2026-11-16 22:58:47.000000000 +0100 @@ -0,0 +1,120 @@ +{ + "artifacts": [ + { + "id": "39255e9e59685b5f", + "name": "fontconfig", + "version": "2.15.0-1.1ubuntu2", + "type": "deb", + "foundBy": "dpkg-db-cataloger", + "locations": [], + "licenses": [ + { + "value": "HPND-sell-variant", + "spdxExpression": "HPND-sell-variant", + "type": "concluded", + "urls": [], + "locations": [] + } + ], + "language": "", + "cpes": [], + "purl": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04" + }, + { + "id": "8736998fcaef3ad3", + "name": "libapr1t64", + "version": "1.7.2-3.1ubuntu0.1", + "type": "deb", + "foundBy": "dpkg-db-cataloger", + "locations": [], + "licenses": [ + { + "value": "Apache-2.0", + "spdxExpression": "Apache-2.0", + "type": "concluded", + "urls": [], + "locations": [] + }, + { + "value": "BSD-4-Clause-UC", + "spdxExpression": "BSD-4-Clause-UC", + "type": "concluded", + "urls": [], + "locations": [] + }, + { + "value": "ISC", + "spdxExpression": "ISC", + "type": "concluded", + "urls": [], + "locations": [] + }, + { + "value": "Zlib", + "spdxExpression": "Zlib", + "type": "concluded", + "urls": [], + "locations": [] + } + ], + "language": "", + "cpes": [], + "purl": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04&upstream=apr" + }, + { + "id": "786e451bdf925775", + "name": "libexpat1", + "version": "2.6.1-2ubuntu0.2", + "type": "deb", + "foundBy": "dpkg-db-cataloger", + "locations": [], + "licenses": [ + { + "value": "MIT", + "spdxExpression": "MIT", + "type": "declared", + "urls": [], + "locations": [] + } + ], + "language": "", + "cpes": [], + "purl": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04&upstream=expat" + }, + { + "id": "a53bac2593393e6b", + "name": "openssl", + "version": "3.0.13-0ubuntu3.4", + "type": "deb", + "foundBy": "dpkg-db-cataloger", + "locations": [], + "licenses": [], + "language": "", + "cpes": [], + "purl": "pkg:deb/ubuntu/[email protected]?arch=amd64&distro=ubuntu-24.04" + } + ], + "source": { + "id": "0be2baad519781bb554e880e706235dc0bdd78a8c80a04b6563b62390fdc6fdf", + "name": "tomcat", + "version": "9.0.98-jdk17", + "type": "image", + "metadata": { + "userInput": "tomcat:9.0.98-jdk17" + } + }, + "distro": { + "name": "Ubuntu", + "id": "ubuntu", + "version": "24.04.1 LTS (Noble Numbat)", + "versionID": "24.04" + }, + "descriptor": { + "name": "syft", + "version": "1.51.1" + }, + "schema": { + "version": "16.1.10", + "url": "https://raw.githubusercontent.com/anchore/syft/main/schema/json/schema-16.1.10.json" + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/tests/cli/concluded_test.go new/grant-0.8.0/tests/cli/concluded_test.go --- old/grant-0.7.1/tests/cli/concluded_test.go 1970-01-01 01:00:00.000000000 +0100 +++ new/grant-0.8.0/tests/cli/concluded_test.go 2026-11-16 22:58:47.000000000 +0100 @@ -0,0 +1,135 @@ +package cli + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// tomcatSPDXSBOM is an SPDX JSON SBOM generated by syft from the image of +// https://github.com/anchore/grant/issues/217 (tomcat:9.0.98-jdk17), trimmed to four packages and the fields grant reads. +// fontconfig and libapr1t64 only have concluded licenses, see grant/concluded_licenses_test.go. +func tomcatSPDXSBOM(t *testing.T) string { + t.Helper() + return filepath.Join(repoRoot(t), "grant", "testdata", "tomcat-9.0.98-jdk17", "sbom.spdx.json") +} + +func TestCheckCmdIgnoreConcludedLicenses(t *testing.T) { + const policy = "allow:\n - MIT\n - Apache-2.0\n" + const ignoreConcluded = policy + "ignore-concluded-licenses: true\n" + sbom := tomcatSPDXSBOM(t) + + concludedIgnored := []expressionCase{ + {pkg: "libexpat1", wantDecision: "allow", wantLicenses: []string{"MIT"}}, + {pkg: "openssl", wantDecision: "allow", wantLicenses: []string{}}, + {pkg: "fontconfig", wantDecision: "allow", wantLicenses: []string{}}, + {pkg: "libapr1t64", wantDecision: "allow", wantLicenses: []string{}}, + } + + t.Run("concluded licenses are judged by default", func(t *testing.T) { + stdout, stderr, rc := runGrant(t, "", "-c", writeConfig(t, policy), "-o", "json", "check", sbom) + assert.NotZero(t, rc) + assertFindings(t, parseFindings(t, stdout, stderr), []expressionCase{ + {pkg: "libexpat1", wantDecision: "allow", wantLicenses: []string{"MIT"}}, + {pkg: "openssl", wantDecision: "allow", wantLicenses: []string{}}, + {pkg: "fontconfig", wantDecision: "deny", wantLicenses: []string{"HPND-sell-variant"}}, + {pkg: "libapr1t64", wantDecision: "deny", wantLicenses: []string{"BSD-4-Clause-UC", "ISC", "Zlib"}}, + }) + assert.NotContains(t, stdout, "ignoreConcludedLicenses", "the report only names the option when it is set") + assert.NotContains(t, stderr, "concluded") + }) + + t.Run("config", func(t *testing.T) { + stdout, stderr, rc := runGrant(t, "", "-c", writeConfig(t, ignoreConcluded), "-o", "json", "check", sbom) + assert.Zero(t, rc) + assertFindings(t, parseFindings(t, stdout, stderr), concludedIgnored) + assert.Contains(t, stdout, `"ignoreConcludedLicenses": true`) + assert.NotContains(t, stderr, "concluded") + }) + + t.Run("verbose logs what was ignored", func(t *testing.T) { + _, stderr, rc := runGrant(t, "", "-v", "-c", writeConfig(t, ignoreConcluded), "-o", "json", "check", sbom) + assert.Zero(t, rc) + assert.Contains(t, stderr, "ignored 2 concluded licenses on 2 packages, 2 of which are left with no licenses") + }) + + t.Run("a package left without licenses is subject to require-license", func(t *testing.T) { + stdout, stderr, rc := runGrant(t, "", "-c", writeConfig(t, ignoreConcluded+"require-license: true\n"), "-o", "json", "check", sbom) + assert.NotZero(t, rc) + assertFindings(t, parseFindings(t, stdout, stderr), []expressionCase{ + {pkg: "fontconfig", wantDecision: "deny", wantLicenses: []string{}}, + {pkg: "libapr1t64", wantDecision: "deny", wantLicenses: []string{}}, + }) + }) + + t.Run("table output", func(t *testing.T) { + stdout, stderr, rc := runGrant(t, "", "-c", writeConfig(t, policy), "check", sbom) + assert.NotZero(t, rc) + assertInOutput("HPND-sell-variant")(t, stdout, stderr, rc) + + stdout, stderr, rc = runGrant(t, "", "-c", writeConfig(t, ignoreConcluded), "check", sbom) + assert.Zero(t, rc) + assertNotInOutput("HPND-sell-variant")(t, stdout, stderr, rc) + }) + + t.Run("stdin", func(t *testing.T) { + content, err := os.ReadFile(sbom) + require.NoError(t, err) + findings, rc := findingsByName(t, string(content), ignoreConcluded) + assert.Zero(t, rc) + assertFindings(t, findings, concludedIgnored) + }) +} + +func TestListCmdIgnoreConcludedLicenses(t *testing.T) { + sbom := tomcatSPDXSBOM(t) + + stdout, stderr, rc := runGrant(t, "", "-c", emptyConfig(t), "-o", "json", "list", sbom) + assert.Zero(t, rc) + assertFindings(t, parseFindings(t, stdout, stderr), []expressionCase{ + {pkg: "libexpat1", wantDecision: "unevaluated", wantLicenses: []string{"MIT"}}, + {pkg: "fontconfig", wantDecision: "unevaluated", wantLicenses: []string{"HPND-sell-variant"}}, + {pkg: "libapr1t64", wantDecision: "unevaluated", wantLicenses: []string{"Apache-2.0", "BSD-4-Clause-UC", "ISC", "Zlib"}}, + }) + + stdout, stderr, rc = runGrant(t, "", "-c", writeConfig(t, "ignore-concluded-licenses: true\n"), "-o", "json", "list", sbom) + assert.Zero(t, rc) + assertFindings(t, parseFindings(t, stdout, stderr), []expressionCase{ + {pkg: "libexpat1", wantDecision: "unevaluated", wantLicenses: []string{"MIT"}}, + {pkg: "fontconfig", wantDecision: "unevaluated", wantLicenses: []string{}}, + {pkg: "libapr1t64", wantDecision: "unevaluated", wantLicenses: []string{}}, + }) +} + +// a package can carry both a concluded and a declared license, which the tomcat SBOM has no example of +func TestCheckCmdIgnoreConcludedLicensesKeepsDeclared(t *testing.T) { + sbom := spdxJSONSBOM(spdxJSONPackage("concluded-and-declared", "GPL-3.0-only", "MIT OR GPL-3.0-only") + "," + + spdxJSONPackage("concluded-same-as-declared", "MIT", "MIT") + "," + + spdxJSONPackage("declared-and", "NOASSERTION", "MIT AND GPL-3.0-only")) + + findings, rc := findingsByName(t, sbom, "allow:\n - MIT\n") + assert.NotZero(t, rc) + assertFindings(t, findings, []expressionCase{ + {pkg: "concluded-and-declared", wantDecision: "deny", wantLicenses: []string{"GPL-3.0-only"}}, + {pkg: "concluded-same-as-declared", wantDecision: "allow", wantLicenses: []string{"MIT"}}, + {pkg: "declared-and", wantDecision: "deny", wantLicenses: []string{"GPL-3.0-only"}}, + }) + + findings, rc = findingsByName(t, sbom, "allow:\n - MIT\nignore-concluded-licenses: true\n") + assert.NotZero(t, rc, "a declared license that is not allowed still denies") + assertFindings(t, findings, []expressionCase{ + {pkg: "concluded-and-declared", wantDecision: "allow", wantLicenses: []string{"MIT", "GPL-3.0-only"}}, + // the declared entry of a license that is also concluded stays + {pkg: "concluded-same-as-declared", wantDecision: "allow", wantLicenses: []string{"MIT"}}, + {pkg: "declared-and", wantDecision: "deny", wantLicenses: []string{"GPL-3.0-only"}}, + }) +} + +func TestConfigCmdListsIgnoreConcludedLicenses(t *testing.T) { + stdout, stderr, rc := runGrant(t, "", "config") + assert.Zero(t, rc) + assertInOutput("ignore-concluded-licenses: false # When true, ignore concluded licenses and only consider declared licenses")(t, stdout, stderr, rc) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grant-0.7.1/tests/cli/expression_test.go new/grant-0.8.0/tests/cli/expression_test.go --- old/grant-0.7.1/tests/cli/expression_test.go 2026-11-09 15:49:30.000000000 +0100 +++ new/grant-0.8.0/tests/cli/expression_test.go 2026-11-16 22:58:47.000000000 +0100 @@ -28,6 +28,12 @@ func findingsByName(t *testing.T, sbom, policy string) (map[string]packageFinding, int) { t.Helper() stdout, stderr, rc := runGrant(t, sbom, "-c", writeConfig(t, policy), "-o", "json", "check", "-") + return parseFindings(t, stdout, stderr), rc +} + +// parseFindings reads the package findings of the single target in a JSON report +func parseFindings(t *testing.T, stdout, stderr string) map[string]packageFinding { + t.Helper() var report struct { Run struct { @@ -57,7 +63,7 @@ } findings[p.Name] = f } - return findings, rc + return findings } type expressionCase struct { ++++++ grant.obsinfo ++++++ --- /var/tmp/diff_new_pack.Gwumas/_old 2026-11-17 17:23:15.506853909 +0100 +++ /var/tmp/diff_new_pack.Gwumas/_new 2026-11-17 17:23:15.509854036 +0100 @@ -1,5 +1,5 @@ name: grant -version: 0.7.1 -mtime: 1794235770 -commit: c87af8bb5165d4e9fe38b31c48d7eae4b4d68333 +version: 0.8.0 +mtime: 1794866327 +commit: 4ee1dddc6f0d585d7a2dd47a650eb623d9d417a0 ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/grant/vendor.tar.gz /work/SRC/openSUSE:Factory/.grant.new.1251/vendor.tar.gz differ: char 134, line 1
