-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathconfig.go
More file actions
174 lines (168 loc) · 5.13 KB
/
config.go
File metadata and controls
174 lines (168 loc) · 5.13 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Copyright (c) Mondoo, Inc.
// SPDX-License-Identifier: BUSL-1.1
package config
import (
"go.mondoo.com/mql/v13/providers-sdk/v1/inventory"
"go.mondoo.com/mql/v13/providers-sdk/v1/plugin"
"go.mondoo.com/mql/v13/providers/gcp/connection/gcpinstancesnapshot"
"go.mondoo.com/mql/v13/providers/gcp/provider"
"go.mondoo.com/mql/v13/providers/gcp/resources"
)
var Config = plugin.Provider{
Name: "gcp",
ID: "go.mondoo.com/cnquery/v9/providers/gcp",
Version: "11.6.0",
ConnectionTypes: []string{
provider.ConnectionType,
string(gcpinstancesnapshot.SnapshotConnectionType),
},
Connectors: []plugin.Connector{
{
Name: "gcp",
Use: "gcp",
Short: "a Google Cloud project or folder",
Long: `Use the gcp provider to query resources within Google Cloud Platform (GCP), including databases, services, instances, containers, and more.
Examples without logging into and configuring GCP:
cnquery shell gcp org <ORGANIZATION-ID> --credentials-path <PATH-TO-YOUR-SERVICE-ACCT>
cnspec scan gcp project <PROJECT-ID> --credentials-path <PATH-TO-YOUR-SERVICE-ACCT>
Note:
If you log into GCP and configure the project you want to query or scan, you can omit credentials. To learn how, read https://mondoo.com/docs/cnspec/cloud/gcp/.
Examples with the GCP project configured:
cnspec scan gcp folder <FOLDER-ID>
cnquery shell gcp project
`,
MaxArgs: 2,
Discovery: []string{
resources.DiscoveryOrganization,
resources.DiscoveryFolders,
resources.DiscoveryComputeInstances,
resources.DiscoveryProjects,
resources.DiscoveryComputeImages,
resources.DiscoveryComputeNetworks,
resources.DiscoveryComputeSubnetworks,
resources.DiscoveryComputeFirewalls,
resources.DiscoveryGkeClusters,
resources.DiscoveryStorageBuckets,
resources.DiscoveryBigQueryDatasets,
resources.DiscoverCloudSQLMySQL,
resources.DiscoverCloudSQLPostgreSQL,
resources.DiscoverCloudSQLSQLServer,
resources.DiscoverCloudDNSZones,
resources.DiscoverCloudKMSKeyrings,
resources.DiscoverMemorystoreRedis,
resources.DiscoverMemorystoreRedisCluster,
resources.DiscoverSecretManager,
resources.DiscoverPubSubTopics,
resources.DiscoverPubSubSubscriptions,
resources.DiscoverPubSubSnapshots,
resources.DiscoverCloudRunServices,
resources.DiscoverCloudRunJobs,
resources.DiscoverCloudFunctions,
resources.DiscoverDataprocClusters,
resources.DiscoverLoggingBuckets,
resources.DiscoverApiKeys,
resources.DiscoverIamServiceAccounts,
},
Flags: []plugin.Flag{
{
Long: "credentials-path",
Type: plugin.FlagType_String,
Default: "",
Desc: "The path to the service account credentials to access the APIs with",
},
{
Long: "repository",
Type: plugin.FlagType_String,
Default: "",
Desc: "[gcp gcr] specify the GCR repository to scan",
},
{
Long: "project-id",
Type: plugin.FlagType_String,
Default: "",
Desc: "[gcp snapshot, gcp instance] specify the GCP project ID where the target instance is located",
},
{
Long: "zone",
Type: plugin.FlagType_String,
Default: "",
Desc: "[gcp snapshot, gcp instance] specify the GCP zone where the target instance is located",
},
{
Long: "create-snapshot",
Type: plugin.FlagType_Bool,
Default: "false",
Desc: "[gcp snapshot, gcp instance] create a new snapshot instead of using the latest available snapshot (only used for instance)",
},
},
},
},
AssetUrlTrees: []*inventory.AssetUrlBranch{
{
PathSegments: []string{"technology=gcp"},
Key: "project",
Title: "Project",
Values: map[string]*inventory.AssetUrlBranch{
"*": {
Key: "service",
Title: "Service",
Values: map[string]*inventory.AssetUrlBranch{
"project": nil,
"compute": {
Key: "region",
Title: "Region",
Values: map[string]*inventory.AssetUrlBranch{
"*": {
Key: "object",
Title: "Compute Object",
Values: map[string]*inventory.AssetUrlBranch{
"instance": {
Key: "type",
Values: map[string]*inventory.AssetUrlBranch{
"resource": nil,
// os ... references the os asset tree
},
},
"image": nil,
"network": nil,
"subnetwork": nil,
"other": nil,
},
},
},
},
"storage": {
Key: "region",
Title: "Region",
Values: map[string]*inventory.AssetUrlBranch{
"*": {
Key: "object",
Title: "Storage Object",
Values: map[string]*inventory.AssetUrlBranch{
"bucket": nil,
"other": nil,
},
},
},
},
"gke": {
Key: "region",
Title: "Region",
Values: map[string]*inventory.AssetUrlBranch{
"*": {
Key: "object",
Title: "GKE Object",
Values: map[string]*inventory.AssetUrlBranch{
"cluster": nil,
"other": nil,
},
},
},
},
"other": nil,
},
},
},
},
},
}