aws_recon 0.2.17 → 0.2.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 159d7d490c5b41da69cb442673e9f7786d1c357fa2468f5c921b25c9d4288601
4
- data.tar.gz: cf0dd0209b158f601ed1c03238d6c5f3316ff53d140653ada4977dcbad6214b1
3
+ metadata.gz: eda49a53171d4ca65cdead1238f92429a594e80a644a199eb5bbcccc13514671
4
+ data.tar.gz: 1fa1d7b45fe39c8ef90f49e31bebbf7a5c5569b524fc9a5aa0bfe08262d760fa
5
5
  SHA512:
6
- metadata.gz: e512e73eadfb67572ba726c652b174a2c819341afb29417b44d35faca7cf47def127df9f1dd01456e0f47cc5567f919f68940e72633f19051cdef544dbde83f6
7
- data.tar.gz: bb31739580f8b14244a96319e8e952cf8ed51ee2bd1408a6942245ac4204ed5dae9dc1caa2a44ab83a36fdee9e21605a3c405b6b7f8c72884cb475577606e7c9
6
+ metadata.gz: b68650f9efd7f4a522b5aa6240ddaba6d31837634b5d897361838fb17abab065fb756f8d5e9cd94480980fefdfd89317fabbcf1245add3e8fda83a2e5ccf259c
7
+ data.tar.gz: 85a2604470ec75b83cb82ad2829411fa6927183cba241a6fb72ed409c0ee277443101f999cf883620d056ee90d13edbb3e84787e1e37dde415670a9ff196bdb0
@@ -3,6 +3,9 @@
3
3
  module AwsRecon
4
4
  end
5
5
 
6
+ require 'aws_recon/lib/patch.rb'
7
+ String.include PolicyStringParser
8
+
6
9
  require 'parallel'
7
10
  require 'ostruct'
8
11
  require 'optparse'
@@ -175,6 +175,21 @@ class EC2 < Mapper
175
175
  end
176
176
  end
177
177
 
178
+ #
179
+ # describe_internet_gateways
180
+ #
181
+ @client.describe_internet_gateways.each_with_index do |response, page|
182
+ log(response.context.operation_name, page)
183
+
184
+ response.internet_gateways.each do |gateway|
185
+ struct = OpenStruct.new(gateway.to_h)
186
+ struct.type = 'internet_gateway'
187
+ struct.arn = gateway.internet_gateway_id # no true ARN
188
+
189
+ resources.push(struct.to_h)
190
+ end
191
+ end
192
+
178
193
  #
179
194
  # describe_route_tables
180
195
  #
@@ -12,7 +12,11 @@ class Lambda < Mapper
12
12
  struct = OpenStruct.new(function)
13
13
  struct.type = 'function'
14
14
  struct.arn = function.function_arn
15
+ struct.policy = @client.get_policy({ function_name: function.function_name }).policy.parse_policy
15
16
 
17
+ rescue Aws::Lambda::Errors::ResourceNotFoundException => e
18
+ log_error(e.code)
19
+ ensure
16
20
  resources.push(struct.to_h)
17
21
  end
18
22
  end
@@ -29,16 +29,20 @@ class S3 < Mapper
29
29
  # to create a bucket, you must set the location_constraint
30
30
  # bucket parameter to the same region. (https://docs.aws.amazon.com/general/latest/gr/s3.html)
31
31
  client = if location.empty?
32
+ struct.location = 'us-east-1'
32
33
  @client
33
34
  else
35
+ struct.location = location
34
36
  Aws::S3::Client.new({ region: location })
35
37
  end
36
38
 
37
39
  operations = [
38
40
  { func: 'get_bucket_acl', key: 'acl', field: nil },
39
41
  { func: 'get_bucket_encryption', key: 'encryption', field: 'server_side_encryption_configuration' },
42
+ { func: 'get_bucket_replication', key: 'replication', field: 'replication_configuration' },
40
43
  { func: 'get_bucket_policy', key: 'policy', field: 'policy' },
41
44
  { func: 'get_bucket_policy_status', key: 'public', field: 'policy_status' },
45
+ { func: 'get_public_access_block', key: 'public_access_block', field: 'public_access_block_configuration' },
42
46
  { func: 'get_bucket_tagging', key: 'tagging', field: nil },
43
47
  { func: 'get_bucket_logging', key: 'logging', field: 'logging_enabled' },
44
48
  { func: 'get_bucket_versioning', key: 'versioning', field: nil },
@@ -51,7 +55,7 @@ class S3 < Mapper
51
55
  resp = client.send(op.func, { bucket: bucket.name })
52
56
 
53
57
  struct[op.key] = if op.key == 'policy'
54
- resp.policy.string
58
+ JSON.parse(CGI.unescape(resp.policy.string))
55
59
  else
56
60
  op.field ? resp.send(op.field).to_h : resp.to_h
57
61
  end
@@ -77,6 +81,8 @@ class S3 < Mapper
77
81
  NoSuchBucketPolicy
78
82
  NoSuchTagSet
79
83
  NoSuchWebsiteConfiguration
84
+ ReplicationConfigurationNotFoundError
85
+ NoSuchPublicAccessBlockConfiguration
80
86
  ]
81
87
  end
82
88
  end
@@ -18,6 +18,8 @@ class SNS < Mapper
18
18
  struct = OpenStruct.new(@client.get_topic_attributes({ topic_arn: topic.topic_arn }).attributes.to_h)
19
19
  struct.type = 'topic'
20
20
  struct.arn = topic.topic_arn
21
+ struct.policy = JSON.parse(CGI.unescape(struct.Policy))
22
+ struct.effective_delivery_policy = JSON.parse(CGI.unescape(struct.EffectiveDeliveryPolicy))
21
23
  struct.subscriptions = []
22
24
 
23
25
  # list_subscriptions_by_topic
@@ -18,7 +18,7 @@ class SQS < Mapper
18
18
  struct = OpenStruct.new(@client.get_queue_attributes({ queue_url: queue, attribute_names: ['All'] }).attributes.to_h)
19
19
  struct.type = 'queue'
20
20
  struct.arn = struct.QueueArn
21
- struct.Policy = JSON.parse(CGI.unescape(struct.Policy))
21
+ struct.policy = JSON.parse(CGI.unescape(struct.Policy))
22
22
 
23
23
  resources.push(struct.to_h)
24
24
  end
@@ -30,7 +30,7 @@ class SSM < Mapper
30
30
  struct = OpenStruct.new(parameter.to_h)
31
31
  struct.string_type = parameter.type
32
32
  struct.type = 'parameter'
33
- struct.arn = "arn:aws:#{@service}:#{@region}::parameter/#{parameter.name}"
33
+ struct.arn = "arn:aws:#{@service}:#{@region}::parameter:#{parameter.name}"
34
34
 
35
35
  resources.push(struct.to_h)
36
36
  end
@@ -0,0 +1,10 @@
1
+ #
2
+ # Parse and unescape AWS policy document string
3
+ #
4
+ module PolicyStringParser
5
+ def parse_policy
6
+ JSON.parse(CGI.unescape(self))
7
+ rescue StandardError
8
+ nil
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module AwsRecon
2
- VERSION = "0.2.17"
2
+ VERSION = "0.2.18"
3
3
  end
data/readme.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/darkbitio/aws-recon/smoke-test/main)](https://github.com/darkbitio/aws-recon/actions?query=branch%3Amain)
2
- [![Gem Version](https://badge.fury.io/rb/aws_recon.svg)](https://badge.fury.io/rb/aws_recon)
2
+ [![Gem Version](https://badge.fury.io/rb/aws_recon.svg)](https://rubygems.org/gems/aws_recon)
3
3
 
4
4
  # AWS Recon
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_recon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.17
4
+ version: 0.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Larsen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-11-24 00:00:00.000000000 Z
12
+ date: 2020-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -235,6 +235,7 @@ files:
235
235
  - lib/aws_recon/collectors/xray.rb
236
236
  - lib/aws_recon/lib/formatter.rb
237
237
  - lib/aws_recon/lib/mapper.rb
238
+ - lib/aws_recon/lib/patch.rb
238
239
  - lib/aws_recon/options.rb
239
240
  - lib/aws_recon/services.yaml
240
241
  - lib/aws_recon/version.rb