enumerate-iam icon indicating copy to clipboard operation
enumerate-iam copied to clipboard

Added support for AWS Credentials profiles and enhanced Ctrl-C handling

Open mgeeky opened this issue 5 years ago • 2 comments

This commit introduced support for --profile argument for those who has multiple AWS credentials stored creds file with dedicated profile name labels. Also, since Pool.map is a blocking operation, found Ctrl-C not working anytime I hit it. Therefore a minor work was done to switch parallel execution to map_async approach, while introducing general timeout of 600 seconds and reinforcing SIGINT handler accoriding to the following recipe:

https://stackoverflow.com/questions/11312525/catch-ctrlc-sigint-and-exit-multiprocesses-gracefully-in-python

Best regards, M.

mgeeky avatar Nov 19 '19 10:11 mgeeky

Also, since Pool.map is a blocking operation, found Ctrl-C not working anytime I hit it.

Maybe it is not working because the process is running one of the threads and there is a broad try/except clause like the one we see here:

https://github.com/andresriancho/enumerate-iam/blob/master/enumerate_iam/main.py#L144

Instead of implementing the map_async / SIGINT approach please let's try to change the way Ctrl+C is handled inside threads. In other words, search for all broad try / except clauses and make them raise KeyboardInterrupt.

The original code has KeyboardInterrupt handling and I remember testing it at some point. Does it work on some scenarios for you? Never?

andresriancho avatar Nov 19 '19 16:11 andresriancho

getting this with the fork (I was looking for a solution to the CTRL-C issue):

Traceback (most recent call last): File "enumerate-iam.py", line 60, in main() File "enumerate-iam.py", line 53, in main level) File "/root/Downloads/enumerate-iam/enumerate_iam/main.py", line 236, in enumerate_iam configure_logging(level) File "/root/Downloads/enumerate-iam/enumerate_iam/main.py", line 226, in configure_logging urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) AttributeError: module 'botocore.vendored.requests.packages.urllib3' has no attribute 'disable_warnings'

got rid of import botocore.vendored.requests.packages.urllib3 as urllib3 and the following line in main.py.

Not sure if it will have side effects...

halfluke avatar Jan 20 '20 21:01 halfluke