Fix oval-db existence check on reporting

This commit is contained in:
kota kanbe
2017-08-09 10:32:31 +09:00
parent b14406e329
commit 774c78add0
2 changed files with 11 additions and 6 deletions

View File

@@ -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(