mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 23:16:30 +01:00
Update java generic cataloger (#1329)
* remove centralize pURL generation Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * port java cataloger to new generic cataloger pattern Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * remove common.GenericCataloger Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * update format test fixtures to reflect ID updates Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * fix package sort instability for encode-decode-encode cycles Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
@@ -4,31 +4,30 @@ Package java provides a concrete Cataloger implementation for Java archives (jar
|
||||
package java
|
||||
|
||||
import (
|
||||
"github.com/anchore/syft/syft/pkg/cataloger/common"
|
||||
"github.com/anchore/syft/syft/pkg/cataloger/generic"
|
||||
)
|
||||
|
||||
// NewJavaCataloger returns a new Java archive cataloger object.
|
||||
func NewJavaCataloger(cfg Config) *common.GenericCataloger {
|
||||
globParsers := make(map[string]common.ParserFn)
|
||||
|
||||
// java archive formats
|
||||
for _, pattern := range archiveFormatGlobs {
|
||||
globParsers[pattern] = parseJavaArchive
|
||||
}
|
||||
func NewJavaCataloger(cfg Config) *generic.Cataloger {
|
||||
c := generic.NewCataloger("java-cataloger").
|
||||
WithParserByGlobs(parseJavaArchive, archiveFormatGlobs...)
|
||||
|
||||
if cfg.SearchIndexedArchives {
|
||||
// java archives wrapped within zip files
|
||||
for _, pattern := range genericZipGlobs {
|
||||
globParsers[pattern] = parseZipWrappedJavaArchive
|
||||
}
|
||||
c.WithParserByGlobs(parseZipWrappedJavaArchive, genericZipGlobs...)
|
||||
}
|
||||
|
||||
if cfg.SearchUnindexedArchives {
|
||||
// java archives wrapped within tar files
|
||||
for _, pattern := range genericTarGlobs {
|
||||
globParsers[pattern] = parseTarWrappedJavaArchive
|
||||
}
|
||||
c.WithParserByGlobs(parseTarWrappedJavaArchive, genericTarGlobs...)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
return common.NewGenericCataloger(nil, globParsers, "java-cataloger")
|
||||
// NewJavaPomCataloger returns a cataloger capable of parsing
|
||||
// dependencies from a pom.xml file.
|
||||
// Pom files list dependencies that maybe not be locally installed yet.
|
||||
func NewJavaPomCataloger() *generic.Cataloger {
|
||||
return generic.NewCataloger("java-pom-cataloger").
|
||||
WithParserByGlobs(parserPomXML, pomXMLDirGlob)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user