-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathconfig.go
More file actions
422 lines (411 loc) · 11.4 KB
/
config.go
File metadata and controls
422 lines (411 loc) · 11.4 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
// Copyright Mondoo, Inc. 2024, 2026
// 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/os/connection/shared"
"go.mondoo.com/mql/v13/providers/os/resources/discovery/docker_engine"
)
var Config = plugin.Provider{
Name: "os",
ID: "go.mondoo.com/cnquery/v9/providers/os",
Version: "13.6.2",
ConnectionTypes: []string{
shared.Type_Local.String(),
shared.Type_SSH.String(),
shared.Type_Tar.String(),
shared.Type_DockerSnapshot.String(),
shared.Type_Vagrant.String(),
shared.Type_DockerContainer.String(),
shared.Type_DockerImage.String(),
shared.Type_DockerFile.String(),
shared.Type_DockerRegistry.String(),
shared.Type_ContainerRegistry.String(),
shared.Type_RegistryImage.String(),
shared.Type_FileSystem.String(),
shared.Type_Winrm.String(),
shared.Type_Device.String(),
},
Connectors: []plugin.Connector{
{
Name: "local",
Use: "local",
Short: "your local system",
Long: `Use the local provider to query your local system. This is the default provider. There's no need to specify local in a command.
Examples:
cnspec shell
cnspec scan
cnspec scan -o json > FILENAME.json
`,
MinArgs: 0,
MaxArgs: 0,
Discovery: []string{
docker_engine.DiscoveryContainerRunning,
docker_engine.DiscoveryContainerImages,
},
Flags: []plugin.Flag{
{
Long: "sudo",
Type: plugin.FlagType_Bool,
Default: "false",
Desc: "Elevate privileges with sudo",
ConfigEntry: "sudo.active",
},
{
Long: "id-detector",
Type: plugin.FlagType_String,
Default: "",
Desc: "User override for platform ID detection mechanism",
Option: plugin.FlagOption_Hidden,
},
},
},
{
Name: "ssh",
Use: "ssh user@host",
Short: "a remote system via SSH",
Long: `Use the ssh provider to query remote systems using SSH.
Examples:
cnspec scan ssh USER@IP-ADDRESS --ask-pass
cnspec shell ssh USER@IP-ADDRESS --ask-pass
`,
MinArgs: 1,
MaxArgs: 1,
Flags: []plugin.Flag{
{
Long: "sudo",
Type: plugin.FlagType_Bool,
Default: "false",
Desc: "Elevate privileges with sudo",
},
{
Long: "insecure",
Type: plugin.FlagType_Bool,
Default: "false",
Desc: "Disable SSH hostkey verification",
},
{
Long: "ask-pass",
Type: plugin.FlagType_Bool,
Default: "false",
Desc: "Prompt for connection password",
ConfigEntry: "-",
},
{
Long: "password",
Short: "p",
Type: plugin.FlagType_String,
Default: "",
Desc: "Set the connection password for SSH",
Option: plugin.FlagOption_Password,
ConfigEntry: "-",
},
{
Long: "identity-file",
Short: "i",
Type: plugin.FlagType_String,
Default: "",
Desc: "Select a file from which to read the identity (private key) for public key authentication",
},
{
Long: "id-detector",
Type: plugin.FlagType_String,
Default: "",
Desc: "User override for platform ID detection mechanism",
Option: plugin.FlagOption_Hidden,
},
},
},
{
Name: "winrm",
Use: "winrm user@host",
Short: "a remote system via WinRM",
Long: `Use the winrm provider to query remote systems using WinRM.
Examples:
cnspec scan winrm USER@HOST --ask-pass
cnspec shell winrm USER@HOST --ask-pass
`,
MinArgs: 1,
MaxArgs: 1,
Flags: []plugin.Flag{
{
Long: "insecure",
Default: "false",
Desc: "Disable TLS/SSL checks",
Type: plugin.FlagType_Bool,
},
{
Long: "ask-pass",
Default: "false",
Desc: "Prompt for connection password",
Type: plugin.FlagType_Bool,
},
{
Long: "password",
Short: "p",
Default: "false",
Desc: "Set the connection password for SSH",
Type: plugin.FlagType_String,
Option: plugin.FlagOption_Password,
ConfigEntry: "-",
},
{
Long: "id-detector",
Type: plugin.FlagType_String,
Default: "",
Desc: "User override for platform ID detection mechanism",
Option: plugin.FlagOption_Hidden,
},
},
},
{
Name: "vagrant",
Use: "vagrant host",
Short: "a Vagrant host",
Long: `Use the vagrant provider to query Vagrant virtual machines.
Examples:
cnspec scan vagrant HOST
cnspec shell vagrant HOST
`,
MinArgs: 1,
MaxArgs: 1,
Flags: []plugin.Flag{
{
Long: "sudo",
Type: plugin.FlagType_Bool,
Default: "false",
Desc: "Elevate privileges with sudo",
},
{
Long: "id-detector",
Type: plugin.FlagType_String,
Default: "",
Desc: "User override for platform ID detection mechanism",
Option: plugin.FlagOption_Hidden,
},
},
},
{
Name: "container",
Use: "container",
Short: "a running container or container image",
Long: `Use the container provider to query running containers or container images.
Examples:
cnspec scan container ubuntu:latest
cnspec shell container ubuntu:latest
`,
MinArgs: 1,
MaxArgs: 2,
Discovery: []string{
docker_engine.DiscoveryContainerRunning,
docker_engine.DiscoveryContainerImages,
},
Flags: []plugin.Flag{
{
Long: "sudo",
Type: plugin.FlagType_Bool,
Default: "false",
Desc: "Elevate privileges with sudo",
ConfigEntry: "sudo.active",
},
{
Long: "id-detector",
Type: plugin.FlagType_String,
Default: "",
Desc: "User override for platform ID detection mechanism",
Option: plugin.FlagOption_Hidden,
},
{
Long: "disable-cache",
Type: plugin.FlagType_Bool,
Default: "false",
Desc: "Disable the in-memory cache for images. WARNING: This significantly slows scans.",
},
{
Long: "container-proxy",
Type: plugin.FlagType_String,
Default: "",
Desc: "HTTP proxy to use for container pulls",
},
},
},
{
Name: "docker",
Use: "docker",
Short: "a running Docker container, Docker image, or Dockerfile",
Long: `Use the docker provider to query running Docker containers or container images in public or private container registries using their registry name. Or scan a Dockerfile by specifying its path.
Examples:
cnspec scan docker <DOCKER-CONTAINER-ID>
cnspec scan docker file <FILEPATH>
cnspec scan docker ubuntu:latest
cnspec scan docker elastic/elasticsearch:7.2.0
cnspec scan docker gcr.io/google-containers/ubuntu:22.04
cnspec scan docker registry.access.redhat.com/ubi8/ubi
`,
MinArgs: 1,
MaxArgs: 2,
Discovery: []string{
docker_engine.DiscoveryContainerRunning,
docker_engine.DiscoveryContainerImages,
},
Flags: []plugin.Flag{
{
Long: "sudo",
Type: plugin.FlagType_Bool,
Default: "false",
Desc: "Elevate privileges with sudo.",
ConfigEntry: "sudo.active",
},
{
Long: "id-detector",
Type: plugin.FlagType_String,
Default: "",
Desc: "User override for platform ID detection mechanism",
Option: plugin.FlagOption_Hidden,
},
{
Long: "disable-cache",
Type: plugin.FlagType_Bool,
Default: "false",
Desc: "Disable the in-memory cache for images. WARNING: This significantly slows scans.",
},
{
Long: "container-proxy",
Type: plugin.FlagType_String,
Default: "",
Desc: "HTTP proxy to use for container pulls",
},
},
},
{
Name: "filesystem",
Aliases: []string{"fs"},
Use: "filesystem PATH [flags]",
Short: "a mounted file system target",
Long: `Use the filesystem provider to query mounted file systems.
Examples:
cnspec scan filesystem <MOUNT-PATH-TO-FILE-SYSTEM>
cnspec shell fs <MOUNT-PATH-TO-FILE-SYSTEM>
`,
MinArgs: 0,
MaxArgs: 1,
Flags: []plugin.Flag{
{
Long: "path",
Type: plugin.FlagType_String,
Default: "",
Desc: "Path to a local file or directory for the connection to use",
Option: plugin.FlagOption_Deprecated,
},
},
},
{
Name: "device",
Use: "device",
Short: "a block device target",
Long: `Use the device provider to query block devices.
Examples:
cnspec scan device --lun <LOGICAL-UNIT-NUMBER>
cnspec shell device --device-name <NAME-OF-LINUX-DEVICE>
`,
MinArgs: 0,
MaxArgs: 0,
Flags: []plugin.Flag{
{
Long: "lun",
Type: plugin.FlagType_String,
Desc: "The logical unit number of the block device. Do not use with --device-name or --serial-number",
Option: plugin.FlagOption_Hidden,
},
{
Long: "device-name",
Type: plugin.FlagType_String,
Desc: "The target device, e.g., /dev/sda. Supported only for Linux scanning. Do not use together with --lun or --serial-number",
Option: plugin.FlagOption_Hidden | plugin.FlagOption_Deprecated,
},
{
Long: "device-names",
Type: plugin.FlagType_List,
Desc: "The target devices, e.g., /dev/sda. Supported only for Linux scanning. Do not use together with --lun or --serial-number",
Option: plugin.FlagOption_Hidden,
},
{
Long: "serial-number",
Type: plugin.FlagType_String,
Desc: "The serial number of the block device. Supported only for Windows scanning. Do not use together with --device-name or --lun",
Option: plugin.FlagOption_Hidden,
},
{
Long: "mount-all-partitions",
Type: plugin.FlagType_Bool,
Desc: "Mount all partitions of the block device",
Option: plugin.FlagOption_Hidden,
},
{
Long: "skip-attempt-expand-partitions",
Type: plugin.FlagType_Bool,
Desc: "Skip attempt on trying to discover the fstab file on the device",
Option: plugin.FlagOption_Hidden,
},
{
Long: "include-mounted",
Type: plugin.FlagType_Bool,
Desc: "Include mounted block devices in the scan",
Option: plugin.FlagOption_Hidden,
},
{
Long: "keep-mounted",
Type: plugin.FlagType_Bool,
Desc: "Keep mounted block devices mounted after the scan",
Option: plugin.FlagOption_Hidden,
},
{
Long: "platform-ids",
Type: plugin.FlagType_List,
Desc: "List of platform IDs to inject to the asset",
Option: plugin.FlagOption_Hidden,
},
},
},
},
AssetUrlTrees: []*inventory.AssetUrlBranch{
{
PathSegments: []string{"technology=os"},
Key: "family",
Title: "OS Family",
Values: map[string]*inventory.AssetUrlBranch{
// linux, windows, darwin, unix, ...
"*": {
Key: "platform",
Title: "Platform",
Values: map[string]*inventory.AssetUrlBranch{
// redhat, arch, ...
"*": {
Key: "version",
Title: "Version",
Values: map[string]*inventory.AssetUrlBranch{
// any valid version for the OS
"*": nil,
},
},
},
},
},
},
{
PathSegments: []string{"technology=container"},
Key: "kind",
Title: "Container Kind",
Values: map[string]*inventory.AssetUrlBranch{
// container-image, container, ...
"*": {
References: []string{"technology=os"},
},
},
},
{
PathSegments: []string{"technology=iac", "category=dockerfile"},
},
},
}