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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +17 -1
  3. data/lib/aws_recon/collectors/accessanalyzer.rb +5 -0
  4. data/lib/aws_recon/collectors/acm.rb +5 -0
  5. data/lib/aws_recon/collectors/apigateway.rb +5 -0
  6. data/lib/aws_recon/collectors/apigatewayv2.rb +5 -0
  7. data/lib/aws_recon/collectors/applicationautoscaling.rb +5 -0
  8. data/lib/aws_recon/collectors/athena.rb +5 -0
  9. data/lib/aws_recon/collectors/autoscaling.rb +5 -0
  10. data/lib/aws_recon/collectors/backup.rb +5 -0
  11. data/lib/aws_recon/collectors/cloudformation.rb +5 -0
  12. data/lib/aws_recon/collectors/cloudfront.rb +5 -0
  13. data/lib/aws_recon/collectors/cloudtrail.rb +5 -0
  14. data/lib/aws_recon/collectors/cloudwatch.rb +5 -0
  15. data/lib/aws_recon/collectors/cloudwatchlogs.rb +5 -0
  16. data/lib/aws_recon/collectors/codebuild.rb +5 -0
  17. data/lib/aws_recon/collectors/codepipeline.rb +29 -9
  18. data/lib/aws_recon/collectors/configservice.rb +5 -0
  19. data/lib/aws_recon/collectors/directconnect.rb +5 -0
  20. data/lib/aws_recon/collectors/{directyservice.rb → directoryservice.rb} +5 -0
  21. data/lib/aws_recon/collectors/dms.rb +5 -0
  22. data/lib/aws_recon/collectors/dynamodb.rb +5 -0
  23. data/lib/aws_recon/collectors/ec2.rb +6 -3
  24. data/lib/aws_recon/collectors/ecr.rb +8 -1
  25. data/lib/aws_recon/collectors/ecs.rb +12 -9
  26. data/lib/aws_recon/collectors/efs.rb +5 -0
  27. data/lib/aws_recon/collectors/eks.rb +5 -0
  28. data/lib/aws_recon/collectors/elasticache.rb +5 -0
  29. data/lib/aws_recon/collectors/elasticloadbalancing.rb +5 -0
  30. data/lib/aws_recon/collectors/elasticloadbalancingv2.rb +5 -0
  31. data/lib/aws_recon/collectors/elasticsearch.rb +5 -0
  32. data/lib/aws_recon/collectors/emr.rb +5 -0
  33. data/lib/aws_recon/collectors/firehose.rb +5 -0
  34. data/lib/aws_recon/collectors/guardduty.rb +5 -2
  35. data/lib/aws_recon/collectors/iam.rb +9 -2
  36. data/lib/aws_recon/collectors/kafka.rb +5 -0
  37. data/lib/aws_recon/collectors/kinesis.rb +5 -0
  38. data/lib/aws_recon/collectors/kms.rb +7 -1
  39. data/lib/aws_recon/collectors/lambda.rb +5 -0
  40. data/lib/aws_recon/collectors/lightsail.rb +5 -0
  41. data/lib/aws_recon/collectors/organizations.rb +7 -1
  42. data/lib/aws_recon/collectors/rds.rb +7 -0
  43. data/lib/aws_recon/collectors/redshift.rb +5 -0
  44. data/lib/aws_recon/collectors/route53.rb +5 -0
  45. data/lib/aws_recon/collectors/route53domains.rb +5 -0
  46. data/lib/aws_recon/collectors/s3.rb +8 -1
  47. data/lib/aws_recon/collectors/sagemaker.rb +25 -1
  48. data/lib/aws_recon/collectors/secretsmanager.rb +5 -0
  49. data/lib/aws_recon/collectors/securityhub.rb +7 -1
  50. data/lib/aws_recon/collectors/servicequotas.rb +7 -1
  51. data/lib/aws_recon/collectors/ses.rb +5 -0
  52. data/lib/aws_recon/collectors/shield.rb +8 -2
  53. data/lib/aws_recon/collectors/sns.rb +5 -0
  54. data/lib/aws_recon/collectors/sqs.rb +6 -1
  55. data/lib/aws_recon/collectors/ssm.rb +5 -0
  56. data/lib/aws_recon/collectors/support.rb +7 -1
  57. data/lib/aws_recon/collectors/transfer.rb +5 -0
  58. data/lib/aws_recon/collectors/wafv2.rb +5 -0
  59. data/lib/aws_recon/collectors/workspaces.rb +5 -0
  60. data/lib/aws_recon/collectors/xray.rb +5 -0
  61. data/lib/aws_recon/lib/mapper.rb +8 -6
  62. data/lib/aws_recon/lib/patch.rb +2 -0
  63. data/lib/aws_recon/options.rb +12 -6
  64. data/lib/aws_recon/services.yaml +23 -0
  65. data/lib/aws_recon/version.rb +1 -1
  66. data/readme.md +84 -37
  67. metadata +3 -3
@@ -12,8 +12,13 @@
12
12
  alias: config
13
13
  - name: CodeBuild
14
14
  alias: codebuild
15
+ excluded_regions:
16
+ - af-south-1
15
17
  - name: CodePipeline
16
18
  alias: codepipeline
19
+ excluded_regions:
20
+ - af-south-1
21
+ - me-south-1
17
22
  - name: AutoScaling
18
23
  alias: autoscaling
19
24
  - name: CloudTrail
@@ -94,12 +99,17 @@
94
99
  - eu-north-1
95
100
  - eu-west-3
96
101
  - us-west-1
102
+ - ap-east-1
103
+ - af-south-1
104
+ - eu-south-1
97
105
  - name: CloudWatch
98
106
  alias: cloudwatch
99
107
  - name: CloudWatchLogs
100
108
  alias: cloudwatchlogs
101
109
  - name: Kafka
102
110
  alias: kafka
111
+ excluded_regions:
112
+ - af-south-1
103
113
  - name: SecretsManager
104
114
  alias: sm
105
115
  - name: SecurityHub
@@ -125,6 +135,10 @@
125
135
  - eu-north-1
126
136
  - us-west-1
127
137
  - sa-east-1
138
+ - ap-east-1
139
+ - af-south-1
140
+ - eu-south-1
141
+ - me-south-1
128
142
  - name: WorkSpaces
129
143
  alias: workspaces
130
144
  excluded_regions:
@@ -133,12 +147,21 @@
133
147
  - eu-west-3
134
148
  - us-east-2
135
149
  - us-west-1
150
+ - ap-east-1
151
+ - af-south-1
152
+ - eu-south-1
153
+ - me-south-1
136
154
  - name: SageMaker
137
155
  alias: sagemaker
138
156
  - name: ServiceQuotas
139
157
  alias: servicequotas
140
158
  - name: Transfer
141
159
  alias: transfer
160
+ excluded_regions:
161
+ - ap-east-1
162
+ - af-south-1
163
+ - eu-south-1
164
+ - me-south-1
142
165
  - name: DirectConnect
143
166
  alias: dc
144
167
  - name: DirectoryService
@@ -1,3 +1,3 @@
1
1
  module AwsRecon
2
- VERSION = "0.2.24"
2
+ VERSION = "0.2.29"
3
3
  end
data/readme.md CHANGED
@@ -7,9 +7,9 @@ A multi-threaded AWS inventory collection tool.
7
7
 
8
8
  The [creators](https://darkbit.io) of this tool have a recurring need to be able to efficiently collect a large amount of AWS resource attributes and metadata to help clients understand their cloud security posture.
9
9
 
10
- There are a handful of tools (e.g. [AWS Config](https://aws.amazon.com/config), [CloudMapper](https://github.com/duo-labs/cloudmapper), [CloudSploit](https://github.com/cloudsploit/scans), [Prowler](https://github.com/toniblyx/prowler)) that do some form of resource collection to support other functions. But we found we needed broader coverage and more details at a per-service level. We also needed a consistent and structured format that allowed for integration with our other systems and tooling.
10
+ Existing tools (e.g. [AWS Config](https://aws.amazon.com/config)) that do some form of resource collection lack the coverage and specificity we needed. We also needed a tool that produced consistent output that was easily consumed by other tools/systems.
11
11
 
12
- Enter AWS Recon, multi-threaded AWS inventory collection tool written in plain Ruby. Though most AWS tooling tends to be dominated by Python, the [Ruby SDK](https://aws.amazon.com/sdk-for-ruby/) is quite mature and capable. The maintainers of the Ruby SDK have done a fantastic job making it easy to handle automatic retries, paging of large responses, and threading huge numbers of requests.
12
+ Enter AWS Recon, multi-threaded AWS inventory collection tool written in plain Ruby. Though Python tends to dominate the AWS tooling landscape, the [Ruby SDK](https://aws.amazon.com/sdk-for-ruby/) has a few convenient advantages over the [other](https://aws.amazon.com/sdk-for-node-js/) [AWS](https://aws.amazon.com/sdk-for-python/) [SDKs](https://aws.amazon.com/sdk-for-go/) we tested. Specifically, easy handling of automatic retries, paging of large responses, and - with some help - threading huge numbers of requests.
13
13
 
14
14
  ## Project Goals
15
15
 
@@ -23,24 +23,44 @@ Enter AWS Recon, multi-threaded AWS inventory collection tool written in plain R
23
23
 
24
24
  ### Requirements
25
25
 
26
- Ruby 2.5.x or 2.6.x (developed and tested with 2.6.5)
26
+ AWS Recon needs an AWS account role or credentials with `ReadOnlyAccess`. Full `AdministratorAccess` is over-privileged, but will work as well. The `SecurityAudit` policy is **not** sufficient as it omits access to many services.
27
+
28
+ #### Running via Docker
29
+
30
+ Use Docker version 19.x or above to run the pre-built image without having to install anything.
31
+
32
+ #### Running locally via Ruby
33
+
34
+ If you already have Ruby installed (2.5.x or 2.6.x), you may want to install the Ruby gem.
27
35
 
28
36
  ### Installation
29
37
 
30
- AWS Recon can be run locally by installing the Ruby gem, or via a Docker container.
38
+ AWS Recon can be run locally via a Docker container or by installing the Ruby gem.
39
+
40
+ To run via a Docker a container, pass the necessary AWS credentials into the Docker `run` command. For example:
41
+
42
+ ```
43
+ $ docker run -t --rm \
44
+ -e AWS_REGION \
45
+ -e AWS_ACCESS_KEY_ID \
46
+ -e AWS_SECRET_ACCESS_KEY \
47
+ -e AWS_SESSION_TOKEN \
48
+ -v $(pwd)/output.json:/recon/output.json \
49
+ darkbitio/aws_recon:latest \
50
+ aws_recon -v -s EC2 -r global,us-east-1,us-east-2
51
+ ```
31
52
 
32
53
  To run locally, first install the gem:
33
54
 
34
55
  ```
35
56
  $ gem install aws_recon
36
- Fetching aws_recon-0.2.8.gem
37
- Fetching aws-sdk-resources-3.76.0.gem
57
+ Fetching aws_recon-0.2.28.gem
38
58
  Fetching aws-sdk-3.0.1.gem
39
- Fetching parallel-1.19.2.gem
59
+ Fetching parallel-1.20.1.gem
40
60
  ...
41
61
  Successfully installed aws-sdk-3.0.1
42
- Successfully installed parallel-1.19.2
43
- Successfully installed aws_recon-0.2.8
62
+ Successfully installed parallel-1.20.1
63
+ Successfully installed aws_recon-0.2.28
44
64
  ```
45
65
 
46
66
  Or add it to your Gemfile using `bundle`:
@@ -51,27 +71,13 @@ Fetching gem metadata from https://rubygems.org/
51
71
  Resolving dependencies...
52
72
  ...
53
73
  Using aws-sdk 3.0.1
54
- Using parallel 1.19.2
55
- Using aws_recon 0.2.8
56
- ```
57
-
58
- To run via a Docker a container, pass the necessary AWS credentials into the Docker `run` command. For example:
59
-
60
- ```
61
- $ docker run -t --rm \
62
- -e AWS_REGION \
63
- -e AWS_ACCESS_KEY_ID \
64
- -e AWS_SECRET_ACCESS_KEY \
65
- -e AWS_SESSION_TOKEN \
66
- -v $(pwd)/output.json:/recon/output.json \
67
- darkbitio/aws_recon:latest \
68
- aws_recon -v -s EC2 -r global,us-east-1,us-east-2
74
+ Using parallel-1.20.1
75
+ Using aws_recon 0.2.28
69
76
  ```
70
77
 
71
-
72
78
  ## Usage
73
79
 
74
- AWS Recon will leverage any AWS credentials currently available to the environment it runs in. If you are collecting from multiple accounts, you may want to leverage something like [aws-vault](https://github.com/99designs/aws-vault) to manage different credentials.
80
+ AWS Recon will leverage any AWS credentials (see [requirements](#requirements)) currently available to the environment it runs in. If you are collecting from multiple accounts, you may want to leverage something like [aws-vault](https://github.com/99designs/aws-vault) to manage different credentials.
75
81
 
76
82
  ```
77
83
  $ aws-vault exec profile -- aws_recon
@@ -95,7 +101,7 @@ $ aws-vault exec <vault_profile> -- docker run -t --rm \
95
101
  aws_recon -j -s EC2 -r global,us-east-1,us-east-2
96
102
  ```
97
103
 
98
- To run from a Docker container using `aws-vault` managed credentials and output to a file, you will need to satisfy a couple of requirements. First, Docker needs access to bind mount the path you specify (or a parent path above). Second, you need to create an empty file to save the output into (e.g. `output.json`). This is because we are only mounting that one file into the Docker container at run time. For example:
104
+ To run from a Docker container using `aws-vault` managed credentials and output to a file, you will need to satisfy a couple of requirements. First, Docker needs access to bind mount the path you specify (or a parent path above). Second, you need to create an empty file to save the output into (e.g. `output.json`). This is because only that one file is mounted into the Docker container at run time. For example:
99
105
 
100
106
  Create an empty file.
101
107
 
@@ -159,22 +165,44 @@ $ AWS_PROFILE=<profile> aws_recon -s S3,EC2 -r global,us-east-1,us-east-2
159
165
  $ AWS_PROFILE=<profile> aws_recon --services S3,EC2 --regions global,us-east-1,us-east-2
160
166
  ```
161
167
 
162
- Example [OpenCSPM](https://github.com/OpenCSPM/opencspm) formatted output.
168
+ Example [OpenCSPM](https://github.com/OpenCSPM/opencspm) formatted (NDJSON) output.
163
169
 
164
170
  ```
165
- $ AWS_PROFILE=<profile> aws_recon -s S3,EC2 -r global,us-east-1,us-east-2 -f custom > output.json
171
+ $ AWS_PROFILE=<profile> aws_recon -j \
172
+ -s S3,EC2 \
173
+ -r global,us-east-1,us-east-2 \
174
+ -f custom > output.json
166
175
  ```
167
176
 
168
177
  #### Errors
169
178
 
170
- An exception will be raised on `AccessDeniedException` errors. This typically means your user/role doesn't have the necessary permissions to get/list/describe for that service. These exceptions are raised so troubleshooting access issues is easier.
179
+ API exceptions related to permissions are silently ignored in most cases. These errors are usually due to one of these cases:
180
+
181
+ - using a role without sufficient permissions
182
+ - querying an account with SCPs in place that prevent usage of certain services
183
+ - trying to query a service that isn't enabled/available in your region/account
184
+
185
+ In `verbose` mode, you will see exception logs in the output:
186
+
187
+ ```
188
+ t2.us-east-1.EC2.describe_subnets.0
189
+ t4.us-east-1.SSM.describe_instance_information.0
190
+ t6.us-east-1.SecurityHub.InvalidAccessException <-----
191
+ t2.us-east-1.EC2.describe_addresses.0
192
+ t4.us-east-1.SSM.describe_parameters.0
193
+ t1.us-east-1.GuardDuty.list_detectors.0
194
+ ```
195
+
196
+ Use the `-q` command line option to re-raise these exceptions so troubleshooting access issues is easier.
171
197
 
172
198
  ```
173
199
  Traceback (most recent call last):
174
- arn:aws:sts::1234567890:assumed-role/role/9876543210 is not authorized to perform: codepipeline:GetPipeline on resource: arn:aws:codepipeline:us-west-2:876543210123:pipeline (Aws::CodePipeline::Errors::AccessDeniedException)
200
+ arn:aws:sts::1234567890:assumed-role/role/my-audit-role is not authorized to perform:
201
+ codepipeline:GetPipeline on resource: arn:aws:codepipeline:us-west-2:1234567890:pipeline
202
+ (Aws::CodePipeline::Errors::AccessDeniedException)
175
203
  ```
176
204
 
177
- The exact API operation that triggered the exception is indicated on the last line of the stack trace. If you can't resolve the necessary access, you should exclude those services with `-x` or `--not-services` so the collection can continue.
205
+ The exact API operation that triggered the exception is indicated on the last line of the stack trace. If you can't resolve the necessary access, you should exclude those services with `-x` or `--not-services`, or leave off the `-q` option so the collection can continue.
178
206
 
179
207
  ### Threads
180
208
 
@@ -184,14 +212,20 @@ For global services like IAM, Shield, and Support, requests are not multi-thread
184
212
 
185
213
  For regional services, a thread (up to the thread limit) is spawned for each service in a region. By default, up to 8 threads will be used. If your account has resources spread across many regions, you may see a speed improvement by increasing threads with `-t X`, where `X` is the number of threads.
186
214
 
215
+ ### Performance
216
+
217
+ AWS Recon will make a minimum of ~2,000 API calls in a new/empty account, just to query the supported services in all 20 standard (non-GovCloud, non-China) regions. It is very likely to encounter API rate-limiting (throttling) on large accounts if you enable more threads than the default (8).
218
+
219
+ Recon will automatically backoff and respect the retry limits in the API response. If you observe long pauses during collection, this is likely what is happening. Retry collection with the `-d` or `--debug` option to observe the wire trace and see if you're being throttled. Consider using fewer threads or requesting higher rate limits from AWS if you are regularly getting rate-limited.
220
+
187
221
  ### Options
188
222
 
189
- Most users will want to limit collection to relevant services and regions. Running without any options will attempt to collect all resources from all 16 regular regions.
223
+ Most users will want to limit collection to relevant services and regions. Running without any exclusions will attempt to collect all resources from all regions enabled for the account.
190
224
 
191
225
  ```
192
226
  $ aws_recon -h
193
227
 
194
- AWS Recon - AWS Inventory Collector (0.2.8)
228
+ AWS Recon - AWS Inventory Collector (0.2.28)
195
229
 
196
230
  Usage: aws_recon [options]
197
231
  -r, --regions [REGIONS] Regions to scan, separated by comma (default: all)
@@ -204,8 +238,10 @@ Usage: aws_recon [options]
204
238
  -t, --threads [THREADS] Specify max threads (default: 8, max: 128)
205
239
  -u, --user-data Collect EC2 instance user data (default: false)
206
240
  -z, --skip-slow Skip slow operations (default: false)
241
+ -g, --skip-credential-report Skip generating IAM credential report (default: false)
207
242
  -j, --stream-output Stream JSON lines to stdout (default: false)
208
243
  -v, --verbose Output client progress and current operation
244
+ -q, --quit-on-exception Stop collection if an API error is encountered (default: false)
209
245
  -d, --debug Output debug with wire trace info
210
246
  -h, --help Print this help information
211
247
 
@@ -215,6 +251,20 @@ Usage: aws_recon [options]
215
251
 
216
252
  Output is always some form of JSON - either JSON lines or plain JSON. The output is either written to a file (the default), or written to stdout (with `-j`).
217
253
 
254
+ ## Support for Manually Enabled Regions
255
+
256
+ If you have enabled **manually enabled regions**:
257
+
258
+ - me-south-1 - Middle East (Bahrain)
259
+ - af-south-1 - Africa (Cape Town)
260
+ - ap-east-1 - Asia Pacific (Hong Kong)
261
+ - eu-south-1 - Europe (Milan)
262
+
263
+ and you are using STS to assume a role into an account, you will need to [enable v2 STS tokens](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html) in the account you are assuming the role **from** to be able to run AWS Recon against those regions.
264
+
265
+ > Version 1 tokens are valid only in AWS Regions that are available by default. These tokens do not work in manually enabled Regions, such as Asia Pacific (Hong Kong). Version 2 tokens are valid in all Regions. However, version 2 tokens are longer and might affect systems where you temporarily store tokens.
266
+
267
+ If you are using a static access key/secret, you can collect from these regions regardless of STS token version.
218
268
 
219
269
  ## Supported Services & Resources
220
270
 
@@ -310,11 +360,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
310
360
 
311
361
  ### TODO
312
362
 
313
- - [ ] Optionally suppress AWS API errors instead of re-raising them
314
- - [x] Package as a gem
315
363
  - [ ] Test coverage with AWS SDK stubbed resources
316
364
 
317
-
318
365
  ## Kudos
319
366
 
320
367
  AWS Recon was inspired by the excellent work of the people and teams behind these tools:
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.24
4
+ version: 0.2.29
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-12-05 00:00:00.000000000 Z
12
+ date: 2021-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -197,7 +197,7 @@ files:
197
197
  - lib/aws_recon/collectors/codepipeline.rb
198
198
  - lib/aws_recon/collectors/configservice.rb
199
199
  - lib/aws_recon/collectors/directconnect.rb
200
- - lib/aws_recon/collectors/directyservice.rb
200
+ - lib/aws_recon/collectors/directoryservice.rb
201
201
  - lib/aws_recon/collectors/dms.rb
202
202
  - lib/aws_recon/collectors/dynamodb.rb
203
203
  - lib/aws_recon/collectors/ec2.rb