Merge pull request #225 from oswell/feature/mysql.support

Add support for reading CVE data from MySQL.
This commit is contained in:
Kota Kanbe
2016-10-31 17:07:06 +09:00
committed by GitHub
3 changed files with 39 additions and 9 deletions

View File

@@ -49,6 +49,7 @@ type Config struct {
HTTPProxy string `valid:"url"`
ResultsDir string
CveDBType string
CveDBPath string
CacheDBPath string
@@ -75,10 +76,23 @@ func (c Config) Validate() bool {
}
}
if len(c.CveDBPath) != 0 {
if ok, _ := valid.IsFilePath(c.CveDBPath); !ok {
errs = append(errs, fmt.Errorf(
"SQLite3 DB(Cve Dictionary) path must be a *Absolute* file path. -cve-dictionary-dbpath: %s", c.CveDBPath))
// If no valid DB type is set, default to sqlite3
if c.CveDBType == "" {
c.CveDBType = "sqlite3"
}
if c.CveDBType != "sqlite3" && c.CveDBType != "mysql" {
errs = append(errs, fmt.Errorf(
"CVE DB type must be either 'sqlite3' or 'mysql'. -cve-dictionary-dbtype: %s", c.CveDBType))
}
if c.CveDBType == "sqlite3" {
if len(c.CveDBPath) != 0 {
if ok, _ := valid.IsFilePath(c.CveDBPath); !ok {
errs = append(errs, fmt.Errorf(
"SQLite3 DB(Cve Dictionary) path must be a *Absolute* file path. -cve-dictionary-dbpath: %s", c.CveDBPath))
}
}
}