-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcvesearch.go
43 lines (35 loc) · 822 Bytes
/
cvesearch.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
package main
import (
"flag"
"log"
"os"
"regexp"
"github.com/wdahlenburg/CVESearch/utils"
"github.com/wdahlenburg/CVESearch/utils/search"
)
func main() {
var (
cve string
verbose bool
description bool
)
flag.StringVar(&cve, "cve", "", "CVE to query")
flag.BoolVar(&verbose, "v", false, "Enable verbose mode")
flag.BoolVar(&description, "description", false, "List CVE description")
flag.Parse()
validateCVE(cve)
if description {
utils.PrintDescription(cve)
}
apiKeys := utils.ApiKeys{
GitHub: os.Getenv("GITHUB_KEY"),
GitLab: os.Getenv("GITLAB_KEY"),
}
search.New().Start(cve, apiKeys, verbose)
}
func validateCVE(cve string) {
re := regexp.MustCompile(`^CVE-\d{4}-\d+$`)
if !re.Match([]byte(cve)) {
log.Fatal("Error. CVE must be in the format of CVE-20XX-XXXX")
}
}