Skip to content

Commit 4a88abb

Browse files
Added retrieve vulnerability specification by source and id
1 parent 2570042 commit 4a88abb

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

vulnerability.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ type CWE struct {
6161
Name string `json:"name"`
6262
}
6363

64+
const (
65+
SourceTypeNvd = "NVD"
66+
SourceTypeNpm = "NPM"
67+
SourceTypeGithub = "GITHUB"
68+
SourceTypeVulndb = "VULNDB"
69+
SourceTypeOssindex = "OSSINDEX"
70+
SourceTypeRetirejs = "RETIREJS"
71+
SourceTypeInternal = "INTERNAL"
72+
SourceTypeOsv = "OSV"
73+
SourceTypeSnyk = "SNYK"
74+
)
75+
76+
type SourceType string
77+
6478
type VulnerabilityService struct {
6579
client *Client
6680
}
@@ -75,6 +89,16 @@ func (vs VulnerabilityService) Get(ctx context.Context, vulnUUID uuid.UUID) (v V
7589
return
7690
}
7791

92+
func (vs VulnerabilityService) GetBySource(ctx context.Context, source SourceType, vulnID string) (v Vulnerability, err error) {
93+
req, err := vs.client.newRequest(ctx, http.MethodGet, fmt.Sprintf("/api/v1/vulnerability/source/%s/vuln/%s", source, vulnID))
94+
if err != nil {
95+
return
96+
}
97+
98+
_, err = vs.client.doRequest(req, &v)
99+
return
100+
}
101+
78102
func (vs VulnerabilityService) GetAllForComponent(ctx context.Context, componentUUID uuid.UUID, suppressed bool, po PageOptions) (p Page[Vulnerability], err error) {
79103
params := map[string]string{
80104
"suppressed": strconv.FormatBool(suppressed),

0 commit comments

Comments
 (0)