-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathtable_github_repository_sbom.go
More file actions
98 lines (89 loc) · 2.83 KB
/
Copy pathtable_github_repository_sbom.go
File metadata and controls
98 lines (89 loc) · 2.83 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package github
import (
"context"
"github.com/turbot/steampipe-plugin-sdk/v6/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v6/plugin"
"github.com/turbot/steampipe-plugin-sdk/v6/plugin/transform"
)
func tableGitHubRepositorySbom() *plugin.Table {
return &plugin.Table{
Name: "github_repository_sbom",
Description: "Get the software bill of materials (SBOM) for a repository.",
List: &plugin.ListConfig{
KeyColumns: []*plugin.KeyColumn{
{
Name: "repository_full_name",
Require: plugin.Required,
},
},
ShouldIgnoreError: isNotFoundError([]string{"404"}),
Hydrate: listRepositorySboms,
},
Columns: commonColumns([]*plugin.Column{
{
Name: "repository_full_name",
Type: proto.ColumnType_STRING,
Transform: transform.FromQual("repository_full_name"),
Description: "The full name of the repository (login/repo-name).",
},
{
Name: "spdx_id",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("SPDXID"),
Description: "The SPDX identifier for the SPDX document.",
},
{
Name: "spdx_version",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("SPDXVersion"),
Description: "The version of the SPDX specification that this document conforms to.",
},
{
Name: "creation_info",
Type: proto.ColumnType_JSON,
Description: "It represents when the SBOM was created and who created it.",
},
{
Name: "name",
Type: proto.ColumnType_STRING,
Description: "The name of the SPDX document.",
},
{
Name: "data_license",
Type: proto.ColumnType_STRING,
Description: "The license under which the SPDX document is licensed.",
},
{
Name: "document_describes",
Type: proto.ColumnType_JSON,
Description: "The name of the repository that the SPDX document describes.",
},
{
Name: "document_namespace",
Type: proto.ColumnType_STRING,
Description: "The namespace for the SPDX document.",
},
{
Name: "packages",
Type: proto.ColumnType_JSON,
Description: "Array of packages in SPDX format.",
},
}),
}
}
//// LIST FUNCTION
func listRepositorySboms(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
var owner, repo string
logger := plugin.Logger(ctx)
fullName := d.EqualsQualString("repository_full_name")
owner, repo = parseRepoFullName(fullName)
logger.Trace("tableGitHubRepositorySbomList", "owner", owner, "repo", repo)
client := connect(ctx, d)
sbom, _, err := client.DependencyGraph.GetSBOM(ctx, owner, repo)
if err != nil {
logger.Error("github_repository_sbom.listRepositorySboms", "api_error", err)
return nil, err
}
d.StreamListItem(ctx, sbom.SBOM)
return sbom, nil
}