Fix performance and bug (#867)

* Fix performance

* Update goval-dictionary

* Go mod tidy
This commit is contained in:
Masahiro Fujimura
2019-07-15 21:20:01 +09:00
committed by Teppei Fukuda
parent c5e13dd5e4
commit a977533c78
6 changed files with 27 additions and 26 deletions

View File

@@ -35,6 +35,7 @@ import (
// VulsHandler is used for vuls server mode
type VulsHandler struct {
DBclient report.DBClient
}
func (h VulsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@@ -69,26 +70,7 @@ func (h VulsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
dbclient, locked, err := report.NewDBClient(report.DBClientConf{
CveDictCnf: c.Conf.CveDict,
OvalDictCnf: c.Conf.OvalDict,
GostCnf: c.Conf.Gost,
ExploitCnf: c.Conf.Exploit,
DebugSQL: c.Conf.DebugSQL,
})
if locked {
util.Log.Errorf("SQLite3 is locked. Close other DB connections and try again: %+v", err)
return
}
if err != nil {
util.Log.Errorf("Failed to init DB Clients. err: %+v", err)
return
}
defer dbclient.CloseDB()
if err := report.FillCveInfo(*dbclient, &result, []string{}, true); err != nil {
if err := report.FillCveInfo(h.DBclient, &result, []string{}, true); err != nil {
util.Log.Error(err)
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return