refactor(python): use once + debug for License acquired from METADATA... logs (#8175)

This commit is contained in:
DmitriyLewen
2024-12-25 12:17:08 +06:00
committed by GitHub
parent 03db7fc1ba
commit 4f111b9342

View File

@@ -6,6 +6,7 @@ import (
"io"
"net/textproto"
"strings"
"sync"
"golang.org/x/xerrors"
@@ -15,6 +16,8 @@ import (
xio "github.com/aquasecurity/trivy/pkg/x/io"
)
var licenseMetadataInfoOnce sync.Once
type Parser struct {
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 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))
} else {
license = l