mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 15:50:15 -08:00
refactor(python): use once + debug for License acquired from METADATA... logs (#8175)
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/textproto"
|
"net/textproto"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
@@ -15,6 +16,8 @@ import (
|
|||||||
xio "github.com/aquasecurity/trivy/pkg/x/io"
|
xio "github.com/aquasecurity/trivy/pkg/x/io"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var licenseMetadataInfoOnce sync.Once
|
||||||
|
|
||||||
type Parser struct {
|
type Parser struct {
|
||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
}
|
}
|
||||||
@@ -70,7 +73,10 @@ func (p *Parser) Parse(r xio.ReadSeekerAt) ([]ftypes.Package, []ftypes.Dependenc
|
|||||||
|
|
||||||
if l := h.Get("License"); l != "" {
|
if l := h.Get("License"); l != "" {
|
||||||
if len(licenses) != 0 {
|
if len(licenses) != 0 {
|
||||||
p.logger.Info("License acquired from METADATA classifiers may be subject to additional terms",
|
licenseMetadataInfoOnce.Do(func() {
|
||||||
|
p.logger.Info("Licenses acquired from one or more METADATA files may be subject to additional terms. Use `--debug` flag to see all affected packages.")
|
||||||
|
})
|
||||||
|
p.logger.Debug("License acquired from METADATA classifiers may be subject to additional terms",
|
||||||
log.String("name", name), log.String("version", version))
|
log.String("name", name), log.String("version", version))
|
||||||
} else {
|
} else {
|
||||||
license = l
|
license = l
|
||||||
|
|||||||
Reference in New Issue
Block a user