-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package purl | ||
|
||
import ( | ||
"fmt" | ||
"github.com/octoper/go-ray" | ||
"github.com/spf13/cobra" | ||
"github.com/vulncheck-oss/cli/pkg/config" | ||
"github.com/vulncheck-oss/cli/pkg/session" | ||
"github.com/vulncheck-oss/cli/pkg/ui" | ||
) | ||
|
||
func Command() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "purl <scheme>", | ||
Short: "Look up a specified PURL for any CVES or vulnerabilities", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) != 1 { | ||
return ui.Error("purl scheme is required") | ||
} | ||
response, err := session.Connect(config.Token()).GetPurl(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
cves := response.GetCves() | ||
ray.Ray(response.GetPurlMeta()) | ||
if err := ui.PurlMeta(response.GetPurlMeta()); err != nil { | ||
return err | ||
} | ||
if len(cves) == 0 { | ||
ui.Info(fmt.Sprintf("No CVEs were found for purl %s", args[0])) | ||
return nil | ||
} | ||
ui.Info(fmt.Sprintf("%d CVEs were found for purl %s", len(cves), args[0])) | ||
ui.Json(cves) | ||
return nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters