Skip to content

Commit

Permalink
Add option to list cve-ids (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanaReddy0M authored Nov 20, 2023
1 parent 6445122 commit cae3eec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func main() {
flagset.CreateGroup("OUTPUT", "output",
flagset.EnumSliceVarP(&options.includeColumns, "field", "f", []goflags.EnumVariable{goflags.EnumVariable(-1)}, strings.Replace(fmt.Sprintf("fields to display in cli output. supported: %s", allowedHeaderString), " ,", "", -1), allowedHeader),
flagset.EnumSliceVarP(&options.excludeColumns, "exclude", "fe", []goflags.EnumVariable{goflags.EnumVariable(-1)}, strings.Replace(fmt.Sprintf("fields to exclude from cli output. supported: %s", allowedHeaderString), " ,", "", -1), allowedHeader),
flagset.BoolVarP(&options.listId, "list-id", "lid", false, "list only the cve ids in the output"),
flagset.IntVarP(&options.limit, "limit", "l", 50, "limit the number of results to display"),
flagset.BoolVarP(&options.json, "json", "j", false, "return output in json format"),
)
Expand Down Expand Up @@ -200,10 +201,18 @@ func main() {
return
}

if options.json {
if options.limit > len(cvesResp.Cves) {
options.limit = len(cvesResp.Cves)
if options.limit > len(cvesResp.Cves) {
options.limit = len(cvesResp.Cves)
}

if options.listId {
for _, cve := range cvesResp.Cves[:options.limit] {
fmt.Println(cve.CveID)
}
return
}

if options.json {
outputJson(cvesResp.Cves[:options.limit])
return
}
Expand Down
1 change: 1 addition & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Options struct {
//vulnType goflags.StringSlice
includeColumns []string
excludeColumns []string
listId bool
epssScore string
cpe string
vulnStatus string
Expand Down

0 comments on commit cae3eec

Please sign in to comment.