Add support for searching for jars within archives (#734)

* add support for searching jars within archives

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add package cataloger config options

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* address review comments + factor out safeCopy helper

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* update config docs regarding package archive search options

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* show that unindexed archive cataloging defaults to false

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* remove lies about -s

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* address review comments

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* update search archive note about java

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2022-01-06 21:40:51 +00:00
committed by GitHub
parent 01dc78ccc3
commit 38c4b17847
35 changed files with 530 additions and 109 deletions
+17 -1
View File
@@ -8,11 +8,27 @@ import (
)
// NewJavaCataloger returns a new Java archive cataloger object.
func NewJavaCataloger() *common.GenericCataloger {
func NewJavaCataloger(cfg Config) *common.GenericCataloger {
globParsers := make(map[string]common.ParserFn)
// java archive formats
for _, pattern := range archiveFormatGlobs {
globParsers[pattern] = parseJavaArchive
}
if cfg.SearchIndexedArchives {
// java archives wrapped within zip files
for _, pattern := range genericZipGlobs {
globParsers[pattern] = parseZipWrappedJavaArchive
}
}
if cfg.SearchUnindexedArchives {
// java archives wrapped within tar files
for _, pattern := range genericTarGlobs {
globParsers[pattern] = parseTarWrappedJavaArchive
}
}
return common.NewGenericCataloger(nil, globParsers, "java-cataloger")
}