-
Notifications
You must be signed in to change notification settings - Fork 2
/
aws_flags.go
88 lines (81 loc) · 2.27 KB
/
aws_flags.go
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
package flag
var (
awsRegionFlag = Flag{
Name: "region",
ConfigName: "cloud.aws.region",
Default: "",
Usage: "AWS Region to scan",
}
awsEndpointFlag = Flag{
Name: "endpoint",
ConfigName: "cloud.aws.endpoint",
Default: "",
Usage: "AWS Endpoint override",
}
awsServiceFlag = Flag{
Name: "service",
ConfigName: "cloud.aws.service",
Default: []string{},
Usage: "Only scan AWS Service(s) specified with this flag. Can specify multiple services using --service A --service B etc.",
}
awsSkipServicesFlag = Flag{
Name: "skip-service",
ConfigName: "cloud.aws.skip-service",
Default: []string{},
Usage: "Skip selected AWS Service(s) specified with this flag. Can specify multiple services using --skip-service A --skip-service B etc.",
}
awsAccountFlag = Flag{
Name: "account",
ConfigName: "cloud.aws.account",
Default: "",
Usage: "The AWS account to scan. It's useful to specify this when reviewing cached results for multiple accounts.",
}
awsARNFlag = Flag{
Name: "arn",
ConfigName: "cloud.aws.arn",
Default: "",
Usage: "The AWS ARN to show results for. Useful to filter results once a scan is cached.",
}
)
type AWSFlagGroup struct {
Region *Flag
Endpoint *Flag
Services *Flag
SkipServices *Flag
Account *Flag
ARN *Flag
}
type AWSOptions struct {
Region string
Endpoint string
Services []string
SkipServices []string
Account string
ARN string
}
func NewAWSFlagGroup() *AWSFlagGroup {
return &AWSFlagGroup{
Region: &awsRegionFlag,
Endpoint: &awsEndpointFlag,
Services: &awsServiceFlag,
SkipServices: &awsSkipServicesFlag,
Account: &awsAccountFlag,
ARN: &awsARNFlag,
}
}
func (f *AWSFlagGroup) Name() string {
return "AWS"
}
func (f *AWSFlagGroup) Flags() []*Flag {
return []*Flag{f.Region, f.Endpoint, f.Services, f.SkipServices, f.Account, f.ARN}
}
func (f *AWSFlagGroup) ToOptions() AWSOptions {
return AWSOptions{
Region: getString(f.Region),
Endpoint: getString(f.Endpoint),
Services: getStringSlice(f.Services),
SkipServices: getStringSlice(f.SkipServices),
Account: getString(f.Account),
ARN: getString(f.ARN),
}
}