diff --git a/syft/pkg/apk_metadata_test.go b/syft/pkg/apk_metadata_test.go index cb5a42322..da22b30a3 100644 --- a/syft/pkg/apk_metadata_test.go +++ b/syft/pkg/apk_metadata_test.go @@ -105,9 +105,7 @@ func TestApkMetadata_FileOwner(t *testing.T) { for _, test := range tests { t.Run(strings.Join(test.expected, ","), func(t *testing.T) { - var i interface{} - i = test.metadata - actual := i.(FileOwner).OwnedFiles() + actual := test.metadata.OwnedFiles() for _, d := range deep.Equal(test.expected, actual) { t.Errorf("diff: %+v", d) } diff --git a/syft/pkg/catalog.go b/syft/pkg/catalog.go index f2f267eb8..1c8e8db56 100644 --- a/syft/pkg/catalog.go +++ b/syft/pkg/catalog.go @@ -4,12 +4,10 @@ import ( "sort" "sync" + "github.com/anchore/syft/internal" + "github.com/anchore/syft/internal/log" "github.com/anchore/syft/syft/artifact" "github.com/jinzhu/copier" - - "github.com/anchore/syft/internal" - - "github.com/anchore/syft/internal/log" ) // Catalog represents a collection of Packages. diff --git a/syft/pkg/cataloger/java/archive_filename.go b/syft/pkg/cataloger/java/archive_filename.go index 377bf6eb7..d52409dac 100644 --- a/syft/pkg/cataloger/java/archive_filename.go +++ b/syft/pkg/cataloger/java/archive_filename.go @@ -113,7 +113,7 @@ func (a archiveFilename) extension() string { func (a archiveFilename) pkgType() pkg.Type { switch strings.ToLower(a.extension()) { - case "jar", "war", "ear": + case "jar", "war", "ear", "lpkg": return pkg.JavaPkg case "jpi", "hpi": return pkg.JenkinsPluginPkg diff --git a/syft/pkg/cataloger/java/archive_filename_test.go b/syft/pkg/cataloger/java/archive_filename_test.go index 6f7f429c7..dd92b6c64 100644 --- a/syft/pkg/cataloger/java/archive_filename_test.go +++ b/syft/pkg/cataloger/java/archive_filename_test.go @@ -36,6 +36,13 @@ func TestExtractInfoFromJavaArchiveFilename(t *testing.T) { name: "pkg-extra-field-maven", ty: pkg.JavaPkg, }, + { + filename: "liferay-package.lpkg", + version: "", + extension: "lpkg", + name: "liferay-package", + ty: pkg.JavaPkg, + }, { filename: "pkg-extra-field-maven-4.3.2-rc1.ear", version: "4.3.2-rc1", diff --git a/syft/pkg/cataloger/java/archive_parser.go b/syft/pkg/cataloger/java/archive_parser.go index 14067b593..57ae0836a 100644 --- a/syft/pkg/cataloger/java/archive_parser.go +++ b/syft/pkg/cataloger/java/archive_parser.go @@ -6,9 +6,8 @@ import ( "path" "strings" - "github.com/anchore/syft/internal/log" - "github.com/anchore/syft/internal/file" + "github.com/anchore/syft/internal/log" "github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/pkg" "github.com/anchore/syft/syft/pkg/cataloger/common" @@ -23,6 +22,14 @@ var archiveFormatGlobs = []string{ "**/*.ear", "**/*.jpi", "**/*.hpi", + "**/*.lpkg", // Zip-compressed package used to deploy applications + // (aka plugins) to Liferay Portal server. Those files contains .JAR(s) and a .PROPERTIES file, the latter + // has information about the application and installation requirements. + // NOTE(jonasagx): If you would like to test it with lpkg file, + // use: https://web.liferay.com/marketplace/-/mp/download/25019275/7403 + // LifeRay makes it pretty cumbersome to make a such plugins; their docs are + // out of date, and they charge for their IDE. If you find an example + // project that we can build in CI feel free to include it } type archiveParser struct { diff --git a/syft/pkg/cataloger/java/archive_parser_test.go b/syft/pkg/cataloger/java/archive_parser_test.go index 68296ec28..fa9275db5 100644 --- a/syft/pkg/cataloger/java/archive_parser_test.go +++ b/syft/pkg/cataloger/java/archive_parser_test.go @@ -283,9 +283,7 @@ func TestParseJar(t *testing.T) { // ignore select fields (only works for the main section) for _, field := range test.ignoreExtras { if metadata.Manifest != nil && metadata.Manifest.Main != nil { - if _, ok := metadata.Manifest.Main[field]; ok { - delete(metadata.Manifest.Main, field) - } + delete(metadata.Manifest.Main, field) } } diff --git a/syft/pkg/dpkg_metadata_test.go b/syft/pkg/dpkg_metadata_test.go index 36fa1a256..397c464b5 100644 --- a/syft/pkg/dpkg_metadata_test.go +++ b/syft/pkg/dpkg_metadata_test.go @@ -86,9 +86,7 @@ func TestDpkgMetadata_FileOwner(t *testing.T) { for _, test := range tests { t.Run(strings.Join(test.expected, ","), func(t *testing.T) { - var i interface{} - i = test.metadata - actual := i.(FileOwner).OwnedFiles() + actual := test.metadata.OwnedFiles() for _, d := range deep.Equal(test.expected, actual) { t.Errorf("diff: %+v", d) } diff --git a/syft/pkg/python_package_metadata_test.go b/syft/pkg/python_package_metadata_test.go index 5364d3329..686980305 100644 --- a/syft/pkg/python_package_metadata_test.go +++ b/syft/pkg/python_package_metadata_test.go @@ -39,9 +39,7 @@ func TestPythonMetadata_FileOwner(t *testing.T) { for _, test := range tests { t.Run(strings.Join(test.expected, ","), func(t *testing.T) { - var i interface{} - i = test.metadata - actual := i.(FileOwner).OwnedFiles() + actual := test.metadata.OwnedFiles() for _, d := range deep.Equal(test.expected, actual) { t.Errorf("diff: %+v", d) } diff --git a/syft/pkg/rpmdb_metadata_test.go b/syft/pkg/rpmdb_metadata_test.go index 6e4fa7cce..b56f8ded2 100644 --- a/syft/pkg/rpmdb_metadata_test.go +++ b/syft/pkg/rpmdb_metadata_test.go @@ -88,9 +88,7 @@ func TestRpmMetadata_FileOwner(t *testing.T) { for _, test := range tests { t.Run(strings.Join(test.expected, ","), func(t *testing.T) { - var i interface{} - i = test.metadata - actual := i.(FileOwner).OwnedFiles() + actual := test.metadata.OwnedFiles() for _, d := range deep.Equal(test.expected, actual) { t.Errorf("diff: %+v", d) }