From a6213ecde2bf9cd6f351ed8701afc460492139b2 Mon Sep 17 00:00:00 2001 From: Colm O hEigeartaigh Date: Wed, 8 Nov 2023 10:02:41 +0000 Subject: [PATCH] Check maven central as well for licenses in parents poms for nested jars Signed-off-by: Colm O hEigeartaigh --- syft/pkg/cataloger/java/archive_parser.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/syft/pkg/cataloger/java/archive_parser.go b/syft/pkg/cataloger/java/archive_parser.go index 109ea5bbcd7d..27525512ace3 100644 --- a/syft/pkg/cataloger/java/archive_parser.go +++ b/syft/pkg/cataloger/java/archive_parser.go @@ -444,7 +444,7 @@ func (j *archiveParser) discoverPkgsFromAllMavenFiles(parentPkg *pkg.Package) ([ pomProject = proj } - pkgFromPom := newPackageFromMavenData(propertiesObj, pomProject, parentPkg, j.location) + pkgFromPom := newPackageFromMavenData(propertiesObj, pomProject, parentPkg, j.location, j.cfg) if pkgFromPom != nil { pkgs = append(pkgs, *pkgFromPom) } @@ -635,7 +635,7 @@ func pomProjectByParentPath(archivePath string, location file.Location, extractP // newPackageFromMavenData processes a single Maven POM properties for a given parent package, returning all listed Java packages found and // associating each discovered package to the given parent package. Note the pom.xml is optional, the pom.properties is not. -func newPackageFromMavenData(pomProperties pkg.JavaPomProperties, parsedPomProject *parsedPomProject, parentPkg *pkg.Package, location file.Location) *pkg.Package { +func newPackageFromMavenData(pomProperties pkg.JavaPomProperties, parsedPomProject *parsedPomProject, parentPkg *pkg.Package, location file.Location, cfg Config) *pkg.Package { // keep the artifact name within the virtual path if this package does not match the parent package vPathSuffix := "" groupID := "" @@ -660,6 +660,9 @@ func newPackageFromMavenData(pomProperties pkg.JavaPomProperties, parsedPomProje var pkgPomProject *pkg.JavaPomProject licenses := make([]pkg.License, 0) if parsedPomProject != nil { + if cfg.UseNetwork { + findPomLicenses(parsedPomProject, cfg) + } pkgPomProject = parsedPomProject.JavaPomProject licenses = append(licenses, parsedPomProject.Licenses...) }