diff --git a/examples/example.go b/examples/example.go new file mode 100644 index 0000000..d1a2b32 --- /dev/null +++ b/examples/example.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "github.com/projectdiscovery/cvemap/runner" + "github.com/projectdiscovery/gologger" + "github.com/projectdiscovery/gologger/levels" +) + +func main() { + gologger.DefaultLogger.SetMaxLevel(levels.LevelVerbose) // increase the verbosity (optional) + + options := &runner.Options{ + CveIds: []string{"CVE-2019-0708"}, + } + + cvesResp, err := runner.GetCves(*options) + if err != nil { + gologger.Fatal().Msgf("Error getting CVEs: %s\n", err) + } + + for _, cve := range cvesResp.Cves { + fmt.Println(cve) + } +} diff --git a/runner/runner.go b/runner/runner.go index 1b4aff0..af02fe7 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -225,7 +225,7 @@ func Run(options Options) { func process(options Options) *CVEBulkData { var cvesResp *CVEBulkData var err error - cvesResp, err = getCves(options) + cvesResp, err = GetCves(options) if err != nil { gologger.Fatal().Msgf("Error getting CVEs: %s\n", err) return nil @@ -457,7 +457,7 @@ func getCellValueByLimit(cell interface{}) string { return cellValue } -func getCves(options Options) (*CVEBulkData, error) { +func GetCves(options Options) (*CVEBulkData, error) { if len(options.CveIds) > 0 { return getCvesByIds(options.CveIds) }