Fix oval-db existence check on reporting
This commit is contained in:
@@ -197,6 +197,11 @@ func (c Config) ValidateOnReport() bool {
|
||||
if err := validateDB("cvedb", c.CveDBType, c.CveDBPath, c.CveDBURL); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if c.CveDBType == "sqlite3" {
|
||||
if _, err := os.Stat(c.CveDBPath); os.IsNotExist(err) {
|
||||
errs = append(errs, fmt.Errorf("SQLite3 DB path (%s) is not exist: %s", "cvedb", c.CveDBPath))
|
||||
}
|
||||
}
|
||||
|
||||
if err := validateDB("ovaldb", c.OvalDBType, c.OvalDBPath, c.OvalDBURL); err != nil {
|
||||
errs = append(errs, err)
|
||||
@@ -236,6 +241,11 @@ func (c Config) ValidateOnTui() bool {
|
||||
if err := validateDB("cvedb", c.CveDBType, c.CveDBPath, c.CveDBURL); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if c.CveDBType == "sqlite3" {
|
||||
if _, err := os.Stat(c.CveDBPath); os.IsNotExist(err) {
|
||||
errs = append(errs, fmt.Errorf("SQLite3 DB path (%s) is not exist: %s", "cvedb", c.CveDBPath))
|
||||
}
|
||||
}
|
||||
|
||||
for _, err := range errs {
|
||||
log.Error(err)
|
||||
@@ -256,11 +266,6 @@ func validateDB(dictionaryDBName, dbType, dbPath, dbURL string) error {
|
||||
dictionaryDBName,
|
||||
dbPath)
|
||||
}
|
||||
if _, err := os.Stat(dbPath); os.IsNotExist(err) {
|
||||
return fmt.Errorf("SQLite3 DB path (%s) is not exist: %s",
|
||||
dictionaryDBName,
|
||||
dbPath)
|
||||
}
|
||||
case "mysql":
|
||||
if dbURL == "" {
|
||||
return fmt.Errorf(
|
||||
|
||||
@@ -178,7 +178,7 @@ func fillWithOval(r *models.ScanResult) (err error) {
|
||||
}
|
||||
if !ok {
|
||||
major := strings.Split(r.Release, ".")[0]
|
||||
util.Log.Warnf("OVAL entries of %s %s are not found. It's recommended to use OVAL to improve scanning accuracy. To fetch OVAL, see https://github.com/kotakanbe/goval-dictionary#usage , Then report with --ovaldb-path or --ovaldb-url flag", ovalFamily, major)
|
||||
util.Log.Warnf("OVAL entries of %s %s are not found. It's recommended to use OVAL to improve scanning accuracy. For details, see https://github.com/kotakanbe/goval-dictionary#usage , Then report with --ovaldb-path or --ovaldb-url flag", ovalFamily, major)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user