Skip to content

Commit

Permalink
support cvemap as library
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuxin committed Jan 24, 2024
1 parent da2fdef commit 35514f8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions examples/example.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
4 changes: 2 additions & 2 deletions runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 35514f8

Please sign in to comment.