func (api cvedictClient) FetchCveDetailsFromCveDB(cveIDs []string) (cveDetails cve.CveDetails, err error) { log.Debugf("open cve-dictionary db (%s)", config.Conf.CveDBType) cveconfig.Conf.DBType = config.Conf.CveDBType if config.Conf.CveDBType == "sqlite3" { cveconfig.Conf.DBPath = config.Conf.CveDBPath } else { cveconfig.Conf.DBPath = config.Conf.CveDictionaryURL } cveconfig.Conf.DebugSQL = config.Conf.DebugSQL if err := cvedb.OpenDB(); err != nil { return []cve.CveDetail{}, fmt.Errorf("Failed to open DB. err: %s", err) } for _, cveID := range cveIDs { cveDetail := cvedb.Get(cveID) if len(cveDetail.CveID) == 0 { cveDetails = append(cveDetails, cve.CveDetail{ CveID: cveID, }) } else { cveDetails = append(cveDetails, cveDetail) } } // order by CVE ID desc sort.Sort(cveDetails) return }
func (api cvedictClient) FetchCveDetailsByCpeNameFromDB(cpeName string) ([]cve.CveDetail, error) { log.Debugf("open cve-dictionary db") cveconfig.Conf.DBPath = config.Conf.CveDBPath if err := cvedb.OpenDB(); err != nil { return []cve.CveDetail{}, fmt.Errorf("Failed to open DB. err: %s", err) } return cvedb.GetByCpeName(cpeName), nil }