aws_recon 0.2.24 → 0.2.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +17 -1
- data/lib/aws_recon/collectors/accessanalyzer.rb +5 -0
- data/lib/aws_recon/collectors/acm.rb +5 -0
- data/lib/aws_recon/collectors/apigateway.rb +5 -0
- data/lib/aws_recon/collectors/apigatewayv2.rb +5 -0
- data/lib/aws_recon/collectors/applicationautoscaling.rb +5 -0
- data/lib/aws_recon/collectors/athena.rb +5 -0
- data/lib/aws_recon/collectors/autoscaling.rb +5 -0
- data/lib/aws_recon/collectors/backup.rb +5 -0
- data/lib/aws_recon/collectors/cloudformation.rb +5 -0
- data/lib/aws_recon/collectors/cloudfront.rb +5 -0
- data/lib/aws_recon/collectors/cloudtrail.rb +5 -0
- data/lib/aws_recon/collectors/cloudwatch.rb +5 -0
- data/lib/aws_recon/collectors/cloudwatchlogs.rb +5 -0
- data/lib/aws_recon/collectors/codebuild.rb +5 -0
- data/lib/aws_recon/collectors/codepipeline.rb +29 -9
- data/lib/aws_recon/collectors/configservice.rb +5 -0
- data/lib/aws_recon/collectors/directconnect.rb +5 -0
- data/lib/aws_recon/collectors/{directyservice.rb → directoryservice.rb} +5 -0
- data/lib/aws_recon/collectors/dms.rb +5 -0
- data/lib/aws_recon/collectors/dynamodb.rb +5 -0
- data/lib/aws_recon/collectors/ec2.rb +6 -3
- data/lib/aws_recon/collectors/ecr.rb +8 -1
- data/lib/aws_recon/collectors/ecs.rb +12 -9
- data/lib/aws_recon/collectors/efs.rb +5 -0
- data/lib/aws_recon/collectors/eks.rb +5 -0
- data/lib/aws_recon/collectors/elasticache.rb +5 -0
- data/lib/aws_recon/collectors/elasticloadbalancing.rb +5 -0
- data/lib/aws_recon/collectors/elasticloadbalancingv2.rb +5 -0
- data/lib/aws_recon/collectors/elasticsearch.rb +5 -0
- data/lib/aws_recon/collectors/emr.rb +5 -0
- data/lib/aws_recon/collectors/firehose.rb +5 -0
- data/lib/aws_recon/collectors/guardduty.rb +5 -2
- data/lib/aws_recon/collectors/iam.rb +9 -2
- data/lib/aws_recon/collectors/kafka.rb +5 -0
- data/lib/aws_recon/collectors/kinesis.rb +5 -0
- data/lib/aws_recon/collectors/kms.rb +7 -1
- data/lib/aws_recon/collectors/lambda.rb +5 -0
- data/lib/aws_recon/collectors/lightsail.rb +5 -0
- data/lib/aws_recon/collectors/organizations.rb +7 -1
- data/lib/aws_recon/collectors/rds.rb +7 -0
- data/lib/aws_recon/collectors/redshift.rb +5 -0
- data/lib/aws_recon/collectors/route53.rb +5 -0
- data/lib/aws_recon/collectors/route53domains.rb +5 -0
- data/lib/aws_recon/collectors/s3.rb +8 -1
- data/lib/aws_recon/collectors/sagemaker.rb +25 -1
- data/lib/aws_recon/collectors/secretsmanager.rb +5 -0
- data/lib/aws_recon/collectors/securityhub.rb +7 -1
- data/lib/aws_recon/collectors/servicequotas.rb +7 -1
- data/lib/aws_recon/collectors/ses.rb +5 -0
- data/lib/aws_recon/collectors/shield.rb +8 -2
- data/lib/aws_recon/collectors/sns.rb +5 -0
- data/lib/aws_recon/collectors/sqs.rb +6 -1
- data/lib/aws_recon/collectors/ssm.rb +5 -0
- data/lib/aws_recon/collectors/support.rb +7 -1
- data/lib/aws_recon/collectors/transfer.rb +5 -0
- data/lib/aws_recon/collectors/wafv2.rb +5 -0
- data/lib/aws_recon/collectors/workspaces.rb +5 -0
- data/lib/aws_recon/collectors/xray.rb +5 -0
- data/lib/aws_recon/lib/mapper.rb +8 -6
- data/lib/aws_recon/lib/patch.rb +2 -0
- data/lib/aws_recon/options.rb +12 -6
- data/lib/aws_recon/services.yaml +23 -0
- data/lib/aws_recon/version.rb +1 -1
- data/readme.md +84 -37
- metadata +3 -3
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect IAM resources
|
5
|
+
#
|
1
6
|
class IAM < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -101,7 +106,8 @@ class IAM < Mapper
|
|
101
106
|
end
|
102
107
|
rescue Aws::IAM::Errors::ServiceError => e
|
103
108
|
log_error(e.code)
|
104
|
-
|
109
|
+
|
110
|
+
raise e unless suppressed_errors.include?(e.code) && !@options.quit_on_exception
|
105
111
|
end
|
106
112
|
|
107
113
|
#
|
@@ -183,7 +189,8 @@ class IAM < Mapper
|
|
183
189
|
end
|
184
190
|
rescue Aws::IAM::Errors::ServiceError => e
|
185
191
|
log_error(e.code)
|
186
|
-
|
192
|
+
|
193
|
+
raise e unless suppressed_errors.include?(e.code) && !@options.quit_on_exception
|
187
194
|
end
|
188
195
|
|
189
196
|
resources
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect KMS resources
|
5
|
+
#
|
1
6
|
class KMS < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -29,7 +34,8 @@ class KMS < Mapper
|
|
29
34
|
.key_rotation_enabled
|
30
35
|
rescue Aws::KMS::Errors::ServiceError => e
|
31
36
|
log_error(e.code)
|
32
|
-
|
37
|
+
|
38
|
+
raise e unless suppressed_errors.include?(e.code) && !@options.quit_on_exception
|
33
39
|
end
|
34
40
|
|
35
41
|
# list_grants
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect Org resources
|
5
|
+
#
|
1
6
|
class Organizations < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -48,7 +53,8 @@ class Organizations < Mapper
|
|
48
53
|
end
|
49
54
|
rescue Aws::Organizations::Errors::ServiceError => e
|
50
55
|
log_error(e.code)
|
51
|
-
|
56
|
+
|
57
|
+
raise e unless suppressed_errors.include?(e.code) && !@options.quit_on_exception
|
52
58
|
end
|
53
59
|
|
54
60
|
resources
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect RDS Resources
|
5
|
+
#
|
1
6
|
class RDS < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -38,6 +43,8 @@ class RDS < Mapper
|
|
38
43
|
struct.arn = instance.db_instance_arn
|
39
44
|
struct.parent_id = instance.db_cluster_identifier
|
40
45
|
|
46
|
+
# TODO: describe_db_snapshots here (with public flag)
|
47
|
+
|
41
48
|
resources.push(struct.to_h)
|
42
49
|
end
|
43
50
|
end
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect S3 Resources
|
5
|
+
#
|
1
6
|
class S3 < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -61,7 +66,9 @@ class S3 < Mapper
|
|
61
66
|
end
|
62
67
|
|
63
68
|
rescue Aws::S3::Errors::ServiceError => e
|
64
|
-
|
69
|
+
log_error(e.code)
|
70
|
+
|
71
|
+
raise e unless suppressed_errors.include?(e.code) && !@options.quit_on_exception
|
65
72
|
end
|
66
73
|
|
67
74
|
resources.push(struct.to_h)
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect SageMaker Resources
|
5
|
+
#
|
1
6
|
class SageMaker < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -12,7 +17,9 @@ class SageMaker < Mapper
|
|
12
17
|
log(response.context.operation_name, page)
|
13
18
|
|
14
19
|
response.notebook_instances.each do |instance|
|
15
|
-
struct = OpenStruct.new(
|
20
|
+
struct = OpenStruct.new(@client.describe_notebook_instance({
|
21
|
+
notebook_instance_name: instance.notebook_instance_name
|
22
|
+
}).to_h)
|
16
23
|
struct.type = 'notebook_instance'
|
17
24
|
struct.arn = instance.notebook_instance_arn
|
18
25
|
|
@@ -20,6 +27,23 @@ class SageMaker < Mapper
|
|
20
27
|
end
|
21
28
|
end
|
22
29
|
|
30
|
+
#
|
31
|
+
# list_endpoints
|
32
|
+
#
|
33
|
+
@client.list_endpoints.each_with_index do |response, page|
|
34
|
+
log(response.context.operation_name, page)
|
35
|
+
|
36
|
+
response.endpoints.each do |instance|
|
37
|
+
struct = OpenStruct.new(@client.describe_endpoint({
|
38
|
+
endpoint_name: instance.endpoint_name
|
39
|
+
}).to_h)
|
40
|
+
struct.type = 'endpoint'
|
41
|
+
struct.arn = instance.endpoint_arn
|
42
|
+
|
43
|
+
resources.push(struct.to_h)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
23
47
|
resources
|
24
48
|
end
|
25
49
|
end
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect Security Hub resources
|
5
|
+
#
|
1
6
|
class SecurityHub < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -20,7 +25,8 @@ class SecurityHub < Mapper
|
|
20
25
|
end
|
21
26
|
rescue Aws::SecurityHub::Errors::ServiceError => e
|
22
27
|
log_error(e.code)
|
23
|
-
|
28
|
+
|
29
|
+
raise e unless suppressed_errors.include?(e.code) && !@options.quit_on_exception
|
24
30
|
end
|
25
31
|
|
26
32
|
resources
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect ServiceQuota resources
|
5
|
+
#
|
1
6
|
class ServiceQuotas < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -27,7 +32,8 @@ class ServiceQuotas < Mapper
|
|
27
32
|
end
|
28
33
|
rescue Aws::ServiceQuotas::Errors::ServiceError => e
|
29
34
|
log_error(e.code, service)
|
30
|
-
|
35
|
+
|
36
|
+
raise e unless suppressed_errors.include?(e.code) && !@options.quit_on_exception
|
31
37
|
end
|
32
38
|
|
33
39
|
resources
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect Shield resources
|
5
|
+
#
|
1
6
|
class Shield < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -27,7 +32,7 @@ class Shield < Mapper
|
|
27
32
|
struct = OpenStruct.new
|
28
33
|
struct.type = 'contact_list'
|
29
34
|
struct.arn = "arn:aws:shield:#{@region}:#{@account}:contact_list"
|
30
|
-
struct.contacts = response
|
35
|
+
struct.contacts = response&.emergency_contact_list&.map(&:to_h)
|
31
36
|
|
32
37
|
resources.push(struct.to_h)
|
33
38
|
end
|
@@ -51,7 +56,8 @@ class Shield < Mapper
|
|
51
56
|
resources
|
52
57
|
rescue Aws::Shield::Errors::ServiceError => e
|
53
58
|
log_error(e.code)
|
54
|
-
|
59
|
+
|
60
|
+
raise e unless suppressed_errors.include?(e.code) && !@options.quit_on_exception
|
55
61
|
|
56
62
|
[] # no access or service isn't enabled
|
57
63
|
end
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect SQS resources
|
5
|
+
#
|
1
6
|
class SQS < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -18,7 +23,7 @@ class SQS < Mapper
|
|
18
23
|
struct = OpenStruct.new(@client.get_queue_attributes({ queue_url: queue, attribute_names: ['All'] }).attributes.to_h)
|
19
24
|
struct.type = 'queue'
|
20
25
|
struct.arn = struct.QueueArn
|
21
|
-
struct.policy = struct.delete_field('Policy').parse_policy
|
26
|
+
struct.policy = struct.Policy ? struct.delete_field('Policy').parse_policy : nil
|
22
27
|
|
23
28
|
resources.push(struct.to_h)
|
24
29
|
end
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Collect Support resources
|
5
|
+
#
|
1
6
|
class Support < Mapper
|
2
7
|
#
|
3
8
|
# Returns an array of resources.
|
@@ -27,7 +32,8 @@ class Support < Mapper
|
|
27
32
|
resources
|
28
33
|
rescue Aws::Support::Errors::ServiceError => e
|
29
34
|
log_error(e.code)
|
30
|
-
|
35
|
+
|
36
|
+
raise e unless suppressed_errors.include?(e.code) && !@options.quit_on_exception
|
31
37
|
|
32
38
|
[] # no Support subscription
|
33
39
|
end
|
data/lib/aws_recon/lib/mapper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#
|
2
4
|
# Generic wrapper for service clients.
|
3
5
|
#
|
@@ -64,14 +66,14 @@ class Mapper
|
|
64
66
|
end
|
65
67
|
|
66
68
|
def log(*msg)
|
67
|
-
|
68
|
-
|
69
|
-
|
69
|
+
return unless @options.verbose
|
70
|
+
|
71
|
+
puts _msg(msg).map { |x| "\x1b[32m#{x}\x1b[0m" }.join("\x1b[35m.\x1b[0m")
|
70
72
|
end
|
71
73
|
|
72
74
|
def log_error(*msg)
|
73
|
-
|
74
|
-
|
75
|
-
|
75
|
+
return unless @options.verbose
|
76
|
+
|
77
|
+
puts _msg(msg).map { |x| "\x1b[35m#{x}\x1b[0m" }.join("\x1b[32m.\x1b[0m")
|
76
78
|
end
|
77
79
|
end
|
data/lib/aws_recon/lib/patch.rb
CHANGED
data/lib/aws_recon/options.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
#
|
4
|
+
# Command line options parser
|
5
|
+
#
|
3
6
|
class Parser
|
4
7
|
DEFAULT_CONFIG_FILE = nil
|
5
8
|
DEFAULT_OUTPUT_FILE = File.expand_path(File.join(Dir.pwd, 'output.json')).freeze
|
@@ -20,6 +23,7 @@ class Parser
|
|
20
23
|
:skip_credential_report,
|
21
24
|
:stream_output,
|
22
25
|
:verbose,
|
26
|
+
:quit_on_exception,
|
23
27
|
:debug
|
24
28
|
)
|
25
29
|
|
@@ -47,6 +51,7 @@ class Parser
|
|
47
51
|
false,
|
48
52
|
false,
|
49
53
|
false,
|
54
|
+
false,
|
50
55
|
false
|
51
56
|
)
|
52
57
|
|
@@ -95,16 +100,12 @@ class Parser
|
|
95
100
|
|
96
101
|
# output format
|
97
102
|
opts.on('-f', '--format [FORMAT]', 'Specify output format (default: aws)') do |file|
|
98
|
-
if %w[aws custom].include?(file.downcase)
|
99
|
-
args.output_format = file.downcase
|
100
|
-
end
|
103
|
+
args.output_format = file.downcase if %w[aws custom].include?(file.downcase)
|
101
104
|
end
|
102
105
|
|
103
106
|
# threads
|
104
107
|
opts.on('-t', '--threads [THREADS]', "Specify max threads (default: #{Parser::DEFAULT_THREADS}, max: 128)") do |threads|
|
105
|
-
if (0..Parser::MAX_THREADS).include?(threads.to_i)
|
106
|
-
args.threads = threads.to_i
|
107
|
-
end
|
108
|
+
args.threads = threads.to_i if (0..Parser::MAX_THREADS).include?(threads.to_i)
|
108
109
|
end
|
109
110
|
|
110
111
|
# collect EC2 instance user data
|
@@ -135,6 +136,11 @@ class Parser
|
|
135
136
|
args.verbose = true unless args.stream_output
|
136
137
|
end
|
137
138
|
|
139
|
+
# re-raise exceptions
|
140
|
+
opts.on('-q', '--quit-on-exception', 'Stop collection if an API error is encountered (default: false)') do
|
141
|
+
args.quit_on_exception = true
|
142
|
+
end
|
143
|
+
|
138
144
|
# debug
|
139
145
|
opts.on('-d', '--debug', 'Output debug with wire trace info') do
|
140
146
|
unless args.stream_output
|