2020-06-24 14:38:42 -05:00
|
|
|
package cveinfo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/anuvu/zot/pkg/log"
|
|
|
|
integration "github.com/aquasecurity/trivy/integration"
|
|
|
|
config "github.com/aquasecurity/trivy/integration/config"
|
2020-06-26 14:09:10 -05:00
|
|
|
"github.com/aquasecurity/trivy/pkg/report"
|
2020-06-24 14:38:42 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// UpdateCVEDb ...
|
|
|
|
func UpdateCVEDb(dbDir string, log log.Logger) error {
|
|
|
|
config, err := config.NewConfig(dbDir)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().Err(err).Msg("Unable to get config")
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = integration.RunTrivyDb(config.TrivyConfig)
|
|
|
|
if err != nil {
|
|
|
|
log.Error().Err(err).Msg("Unable to update DB ")
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2020-06-26 14:09:10 -05:00
|
|
|
|
|
|
|
func NewTrivyConfig(dir string) (*config.Config, error) {
|
|
|
|
return config.NewConfig(dir)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ScanImage(config *config.Config) (report.Results, error) {
|
|
|
|
return integration.ScanTrivyImage(config.TrivyConfig)
|
|
|
|
}
|