forked from nscuro/dtrack-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinding.go
More file actions
57 lines (47 loc) · 1.38 KB
/
Copy pathfinding.go
File metadata and controls
57 lines (47 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package dtrack
import (
"context"
"fmt"
"net/http"
"strconv"
"github.com/google/uuid"
)
type Finding struct {
Attribution FindingAttribution `json:"attribution"`
Analysis Analysis `json:"analysis"`
Component Component `json:"component"`
Matrix string `json:"matrix"`
Vulnerability Vulnerability `json:"vulnerability"`
}
type FindingAttribution struct {
AlternateIdentifier string `json:"alternateIdentifier"`
AnalyzerIdentity string `json:"analyzerIdentity"`
AttributedOn int `json:"attributedOn"`
ReferenceURL string `json:"referenceUrl"`
UUID uuid.UUID `json:"uuid"`
}
type FindingsPage struct {
Findings []Finding
TotalCount int
}
type FindingService struct {
client *Client
}
func (f FindingService) GetAll(ctx context.Context, projectUUID uuid.UUID, suppressed bool, po PageOptions) (*FindingsPage, error) {
params := map[string]string{
"suppressed": strconv.FormatBool(suppressed),
}
req, err := f.client.newRequest(ctx, http.MethodGet, fmt.Sprintf("/api/v1/finding/project/%s", projectUUID), withParams(params), withPageOptions(po))
if err != nil {
return nil, err
}
var findings []Finding
res, err := f.client.doRequest(req, &findings)
if err != nil {
return nil, err
}
return &FindingsPage{
Findings: findings,
TotalCount: res.TotalCount,
}, nil
}