Skip to content

Commit

Permalink
refactor(python): use once + debug for `License acquired from METADAT…
Browse files Browse the repository at this point in the history
…A...` logs (#8175)
  • Loading branch information
DmitriyLewen authored Dec 25, 2024
1 parent 03db7fc commit 4f111b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/dependency/parser/python/packaging/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"net/textproto"
"strings"
"sync"

"golang.org/x/xerrors"

Expand All @@ -15,6 +16,8 @@ import (
xio "github.com/aquasecurity/trivy/pkg/x/io"
)

var licenseMetadataInfoOnce sync.Once

type Parser struct {
logger *log.Logger
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4f111b9

Please sign in to comment.