chore: go-rpmdb update (#1757)

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Christopher Angelo Phillips
2023-04-24 10:34:13 -04:00
committed by GitHub
co-authored by Alex Goodman
parent 8102ad4edc
commit c038f13d44
5 changed files with 61 additions and 54 deletions
+13
View File
@@ -4,12 +4,20 @@ Package rpm provides a concrete DBCataloger implementation for RPM "Package" DB
package rpm
import (
"database/sql"
"github.com/anchore/syft/internal/log"
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/pkg/cataloger/generic"
)
// NewRpmDBCataloger returns a new RPM DB cataloger object.
func NewRpmDBCataloger() *generic.Cataloger {
// check if a sqlite driver is available
if !isSqliteDriverAvailable() {
log.Warnf("sqlite driver is not available, newer RPM databases might not be cataloged")
}
return generic.NewCataloger("rpm-db-cataloger").
WithParserByGlobs(parseRpmDB, pkg.RpmDBGlob).
WithParserByGlobs(parseRpmManifest, pkg.RpmManifestGlob)
@@ -20,3 +28,8 @@ func NewFileCataloger() *generic.Cataloger {
return generic.NewCataloger("rpm-file-cataloger").
WithParserByGlobs(parseRpm, "**/*.rpm")
}
func isSqliteDriverAvailable() bool {
_, err := sql.Open("sqlite", ":memory:")
return err == nil
}