...
1
2
3
4
5
6 package github
7
8 import (
9 "context"
10 "fmt"
11 )
12
13 type DependencyGraphService service
14
15
16
17 type SBOM struct {
18 SBOM *SBOMInfo `json:"sbom,omitempty"`
19 }
20
21
22 type CreationInfo struct {
23 Created *Timestamp `json:"created,omitempty"`
24 Creators []string `json:"creators,omitempty"`
25 }
26
27
28 type RepoDependencies struct {
29 SPDXID *string `json:"SPDXID,omitempty"`
30
31 Name *string `json:"name,omitempty"`
32 VersionInfo *string `json:"versionInfo,omitempty"`
33 DownloadLocation *string `json:"downloadLocation,omitempty"`
34 FilesAnalyzed *bool `json:"filesAnalyzed,omitempty"`
35 LicenseConcluded *string `json:"licenseConcluded,omitempty"`
36 LicenseDeclared *string `json:"licenseDeclared,omitempty"`
37 }
38
39
40
41
42
43 type SBOMInfo struct {
44 SPDXID *string `json:"SPDXID,omitempty"`
45 SPDXVersion *string `json:"spdxVersion,omitempty"`
46 CreationInfo *CreationInfo `json:"creationInfo,omitempty"`
47
48
49 Name *string `json:"name,omitempty"`
50 DataLicense *string `json:"dataLicense,omitempty"`
51 DocumentDescribes []string `json:"documentDescribes,omitempty"`
52 DocumentNamespace *string `json:"documentNamespace,omitempty"`
53
54
55 Packages []*RepoDependencies `json:"packages,omitempty"`
56 }
57
58 func (s SBOM) String() string {
59 return Stringify(s)
60 }
61
62
63
64
65 func (s *DependencyGraphService) GetSBOM(ctx context.Context, owner, repo string) (*SBOM, *Response, error) {
66 u := fmt.Sprintf("repos/%v/%v/dependency-graph/sbom", owner, repo)
67
68 req, err := s.client.NewRequest("GET", u, nil)
69 if err != nil {
70 return nil, nil, err
71 }
72
73 var sbom *SBOM
74 resp, err := s.client.Do(ctx, req, &sbom)
75 if err != nil {
76 return nil, resp, err
77 }
78
79 return sbom, resp, nil
80 }
81
View as plain text