mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 00:43:20 +01:00
Add lpkg as java package format (#694)
* add lpkg support to java cataloger linter clean up Signed-off-by: Jonas Galvão Xavier <jonas.agx@gmail.com> * fix comment formatting Signed-off-by: Jonas Galvão Xavier <jonas.agx@gmail.com> * add filename test for lpkg Signed-off-by: Jonas Galvão Xavier <jonas.agx@gmail.com> * commment on lpkg file extension tests Signed-off-by: Jonas Galvão Xavier <jonas.agx@gmail.com> * fix comment typo Signed-off-by: Jonas Galvão Xavier <jonas.agx@gmail.com> * fix import format Signed-off-by: Jonas Galvão Xavier <jonas.agx@gmail.com> * simpler test validation Signed-off-by: Jonas Galvão Xavier <jonas.agx@gmail.com>
This commit is contained in:
parent
7f8cb0bd80
commit
211b188120
@ -105,9 +105,7 @@ func TestApkMetadata_FileOwner(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(strings.Join(test.expected, ","), func(t *testing.T) {
|
t.Run(strings.Join(test.expected, ","), func(t *testing.T) {
|
||||||
var i interface{}
|
actual := test.metadata.OwnedFiles()
|
||||||
i = test.metadata
|
|
||||||
actual := i.(FileOwner).OwnedFiles()
|
|
||||||
for _, d := range deep.Equal(test.expected, actual) {
|
for _, d := range deep.Equal(test.expected, actual) {
|
||||||
t.Errorf("diff: %+v", d)
|
t.Errorf("diff: %+v", d)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,12 +4,10 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/anchore/syft/internal"
|
||||||
|
"github.com/anchore/syft/internal/log"
|
||||||
"github.com/anchore/syft/syft/artifact"
|
"github.com/anchore/syft/syft/artifact"
|
||||||
"github.com/jinzhu/copier"
|
"github.com/jinzhu/copier"
|
||||||
|
|
||||||
"github.com/anchore/syft/internal"
|
|
||||||
|
|
||||||
"github.com/anchore/syft/internal/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Catalog represents a collection of Packages.
|
// Catalog represents a collection of Packages.
|
||||||
|
|||||||
@ -113,7 +113,7 @@ func (a archiveFilename) extension() string {
|
|||||||
|
|
||||||
func (a archiveFilename) pkgType() pkg.Type {
|
func (a archiveFilename) pkgType() pkg.Type {
|
||||||
switch strings.ToLower(a.extension()) {
|
switch strings.ToLower(a.extension()) {
|
||||||
case "jar", "war", "ear":
|
case "jar", "war", "ear", "lpkg":
|
||||||
return pkg.JavaPkg
|
return pkg.JavaPkg
|
||||||
case "jpi", "hpi":
|
case "jpi", "hpi":
|
||||||
return pkg.JenkinsPluginPkg
|
return pkg.JenkinsPluginPkg
|
||||||
|
|||||||
@ -36,6 +36,13 @@ func TestExtractInfoFromJavaArchiveFilename(t *testing.T) {
|
|||||||
name: "pkg-extra-field-maven",
|
name: "pkg-extra-field-maven",
|
||||||
ty: pkg.JavaPkg,
|
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",
|
filename: "pkg-extra-field-maven-4.3.2-rc1.ear",
|
||||||
version: "4.3.2-rc1",
|
version: "4.3.2-rc1",
|
||||||
|
|||||||
@ -6,9 +6,8 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/anchore/syft/internal/log"
|
|
||||||
|
|
||||||
"github.com/anchore/syft/internal/file"
|
"github.com/anchore/syft/internal/file"
|
||||||
|
"github.com/anchore/syft/internal/log"
|
||||||
"github.com/anchore/syft/syft/artifact"
|
"github.com/anchore/syft/syft/artifact"
|
||||||
"github.com/anchore/syft/syft/pkg"
|
"github.com/anchore/syft/syft/pkg"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger/common"
|
"github.com/anchore/syft/syft/pkg/cataloger/common"
|
||||||
@ -23,6 +22,14 @@ var archiveFormatGlobs = []string{
|
|||||||
"**/*.ear",
|
"**/*.ear",
|
||||||
"**/*.jpi",
|
"**/*.jpi",
|
||||||
"**/*.hpi",
|
"**/*.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 {
|
type archiveParser struct {
|
||||||
|
|||||||
@ -283,9 +283,7 @@ func TestParseJar(t *testing.T) {
|
|||||||
// ignore select fields (only works for the main section)
|
// ignore select fields (only works for the main section)
|
||||||
for _, field := range test.ignoreExtras {
|
for _, field := range test.ignoreExtras {
|
||||||
if metadata.Manifest != nil && metadata.Manifest.Main != nil {
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,9 +86,7 @@ func TestDpkgMetadata_FileOwner(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(strings.Join(test.expected, ","), func(t *testing.T) {
|
t.Run(strings.Join(test.expected, ","), func(t *testing.T) {
|
||||||
var i interface{}
|
actual := test.metadata.OwnedFiles()
|
||||||
i = test.metadata
|
|
||||||
actual := i.(FileOwner).OwnedFiles()
|
|
||||||
for _, d := range deep.Equal(test.expected, actual) {
|
for _, d := range deep.Equal(test.expected, actual) {
|
||||||
t.Errorf("diff: %+v", d)
|
t.Errorf("diff: %+v", d)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,9 +39,7 @@ func TestPythonMetadata_FileOwner(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(strings.Join(test.expected, ","), func(t *testing.T) {
|
t.Run(strings.Join(test.expected, ","), func(t *testing.T) {
|
||||||
var i interface{}
|
actual := test.metadata.OwnedFiles()
|
||||||
i = test.metadata
|
|
||||||
actual := i.(FileOwner).OwnedFiles()
|
|
||||||
for _, d := range deep.Equal(test.expected, actual) {
|
for _, d := range deep.Equal(test.expected, actual) {
|
||||||
t.Errorf("diff: %+v", d)
|
t.Errorf("diff: %+v", d)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,9 +88,7 @@ func TestRpmMetadata_FileOwner(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(strings.Join(test.expected, ","), func(t *testing.T) {
|
t.Run(strings.Join(test.expected, ","), func(t *testing.T) {
|
||||||
var i interface{}
|
actual := test.metadata.OwnedFiles()
|
||||||
i = test.metadata
|
|
||||||
actual := i.(FileOwner).OwnedFiles()
|
|
||||||
for _, d := range deep.Equal(test.expected, actual) {
|
for _, d := range deep.Equal(test.expected, actual) {
|
||||||
t.Errorf("diff: %+v", d)
|
t.Errorf("diff: %+v", d)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user