Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading