Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions vulnerability.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ type CWE struct {
Name string `json:"name"`
}

const (
SourceTypeNvd = "NVD"
SourceTypeNpm = "NPM"
SourceTypeGithub = "GITHUB"
SourceTypeVulndb = "VULNDB"
SourceTypeOssindex = "OSSINDEX"
SourceTypeRetirejs = "RETIREJS"
SourceTypeInternal = "INTERNAL"
SourceTypeOsv = "OSV"
SourceTypeSnyk = "SNYK"
)

type SourceType string

type VulnerabilityService struct {
client *Client
}
Expand All @@ -75,6 +89,16 @@ func (vs VulnerabilityService) Get(ctx context.Context, vulnUUID uuid.UUID) (v V
return
}

func (vs VulnerabilityService) GetBySource(ctx context.Context, source SourceType, vulnID string) (v Vulnerability, err error) {
req, err := vs.client.newRequest(ctx, http.MethodGet, fmt.Sprintf("/api/v1/vulnerability/source/%s/vuln/%s", source, vulnID))
if err != nil {
return
}

_, err = vs.client.doRequest(req, &v)
return
}

func (vs VulnerabilityService) GetAllForComponent(ctx context.Context, componentUUID uuid.UUID, suppressed bool, po PageOptions) (p Page[Vulnerability], err error) {
params := map[string]string{
"suppressed": strconv.FormatBool(suppressed),
Expand Down