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
|
package cmd
import (
// "encoding/json"
"context"
"github.com/pablotron/cvez/nvdmirror"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
var updateCmd = &cobra.Command{
Use: "update",
Aliases: []string { "up" },
Short: "Update mirror.",
Long: `Update local NVD mirror.`,
Run: func(cmd *cobra.Command, args []string) {
// custom sync config
config := nvdmirror.SyncConfig {
Cve11BaseUrl: "https://pmdn.org/cvez-test/20220318/nvd/cve",
CpeMatch10BaseUrl: "https://pmdn.org/cvez-test/20220318/nvd/cpematch",
Cpe23DictUrl: "https://pmdn.org/cvez-test/20220318/nvd/cpedict/official-cpe-dictionary_v2.3.xml.gz",
CisaKevcUrl: "https://pmdn.org/cvez-test/20220318/cisa/known_exploited_vulnerabilities.json",
CweListUrl: "https://pmdn.org/cvez-test/20220318/cwe/cwec_latest.xml.zip",
}
// get cache and cache dir
cache, cacheDir := getCache()
defer cache.Close()
// sync data, get updates
log.Info().Msg("sync mirror")
updates := nvdmirror.Sync(config, &cache, cacheDir)
if len(updates) > 0 {
ctx := context.Background()
getDb().Update(ctx, cacheDir, updates)
log.Info().Msg("done")
}
},
}
|