-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
49 lines (43 loc) · 796 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"flag"
"cve-db/server"
"cve-db/config"
"cve-db/db"
"fmt"
"cve-db/cmd"
"cve-db/fetcher/nvd"
"strconv"
)
func main() {
flag.Parse()
if *cmd.Help || flag.NFlag() < 1 {
flag.Usage()
return
}
DebugSQL := false
if config.Conf.DebugSQL == "true" {
DebugSQL = true
}
driver, err := db.NewDB(config.Conf.DBEngine, config.Conf.DBDsn, DebugSQL)
if err != nil {
fmt.Println(err.Error())
return
}
// 使用-s开启httpserver
if *cmd.Server {
server.Start(driver, config.Conf.Bind, config.Conf.Port)
}
// 使用-u插入和更新CVE数据
if *cmd.Upsert{
year := 2002
if config.Conf.Year != "" {
year, err = strconv.Atoi(config.Conf.Year)
if err !=nil {
fmt.Println(err.Error())
return
}
}
nvd.Fetchernvd(driver, year)
}
}