mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
4194c44131
#14888 @getvictor This is ready for review, but keeping as draft as there are probably many tests that need amending. I used the new version of the `./tools/nvd/nvdvuln/nvdvuln.go` to compare the current vulnerabilities found in our dogfood environment with the vulnerabilities found by the code in this PR and both results match: ``` go run -race -tags fts5 ./tools/nvd/nvdvuln/nvdvuln.go --debug --db_dir ./local --software_from_url <dogfood URL> --software_from_api_token <API_TOKEN> --sync 2>&1 | tee out.txt [...] CVEs found and expected matched! ``` - [X] Changes file added for user-visible changes in `changes/` or `orbit/changes/`. See [Changes files](https://fleetdm.com/docs/contributing/committing-changes#changes-files) for more information. - [ ] Added/updated tests - [X] Manual QA for all new/changed functionality --------- Co-authored-by: Victor Lyuboslavsky <victor@fleetdm.com> Co-authored-by: Victor Lyuboslavsky <victor.lyuboslavsky@gmail.com>
109 lines
2.5 KiB
Go
109 lines
2.5 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"os"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/vulnerabilities/macoffice"
|
|
"github.com/fleetdm/fleet/v4/server/vulnerabilities/msrc"
|
|
"github.com/fleetdm/fleet/v4/server/vulnerabilities/nvd"
|
|
"github.com/fleetdm/fleet/v4/server/vulnerabilities/oval"
|
|
klog "github.com/go-kit/log"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func vulnerabilityDataStreamCommand() *cli.Command {
|
|
var dir string
|
|
return &cli.Command{
|
|
Name: "vulnerability-data-stream",
|
|
Usage: "Download the vulnerability data stream",
|
|
UsageText: `
|
|
fleetctl vulnerability-data-stream [options]
|
|
|
|
Downloads (if needed) the data streams that can be used by the Fleet server to process software for vulnerabilities.
|
|
`,
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "dir",
|
|
EnvVars: []string{"DIR"},
|
|
Value: "",
|
|
Destination: &dir,
|
|
Usage: "Directory to place the data streams in",
|
|
},
|
|
configFlag(),
|
|
contextFlag(),
|
|
debugFlag(),
|
|
},
|
|
Action: func(c *cli.Context) error {
|
|
if dir == "" {
|
|
return errors.New("No directory provided")
|
|
}
|
|
err := os.MkdirAll(dir, 0o700)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
log(c, "[-] Downloading CPE database...")
|
|
err = nvd.DownloadCPEDBFromGithub(dir, "")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log(c, " Done\n")
|
|
|
|
log(c, "[-] Downloading CPE translations...")
|
|
err = nvd.DownloadCPETranslationsFromGithub(dir, "")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log(c, " Done\n")
|
|
|
|
log(c, "[-] Downloading NVD CVE feed...")
|
|
err = nvd.DownloadNVDCVEFeed(dir, "", false, klog.NewNopLogger())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log(c, " Done\n")
|
|
|
|
log(c, "[-] Downloading EPSS feed...")
|
|
err = nvd.DownloadEPSSFeed(dir)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log(c, " Done\n")
|
|
|
|
log(c, "[-] Downloading CISA known exploits feed...")
|
|
err = nvd.DownloadCISAKnownExploitsFeed(dir)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log(c, " Done\n")
|
|
|
|
log(c, "[-] Downloading Oval definitions...")
|
|
err = oval.Sync(dir, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log(c, " Done\n")
|
|
|
|
log(c, "[-] Downloading MSRC artifacts...")
|
|
ctx := context.Background()
|
|
err = msrc.SyncFromGithub(ctx, dir, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log(c, " Done\n")
|
|
|
|
log(c, "[-] Downloading MacOffice release notes...")
|
|
err = macoffice.SyncFromGithub(ctx, dir)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
log(c, " Done\n")
|
|
|
|
log(c, "[+] Data streams successfully downloaded!\n")
|
|
return nil
|
|
},
|
|
}
|
|
}
|