carnal0wnage / weirdAAL

WeirdAAL (AWS Attack Library)
772 stars 92 forks source link

import sys for sys.exit() #46

Closed cclauss closed 6 years ago

cclauss commented 6 years ago

Each of these files calls sys.exit() but does not import sys which may result in NameError being raised instead of sys.exit() being called.

This PR should resolve most but not all of the undefined names issues found in flake8 testing of https://github.com/carnal0wnage/weirdAAL on Python 3.6.3

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./libs/aws_lambda.py:135:86: F821 undefined name 'region'
            print("[-] GetAccountSettings allowed for {} but no results [-]" .format(region))
                                                                                     ^
./libs/opsworks.py:49:13: F821 undefined name 'sys'
            sys.exit("{} : The AWS KEY IS INVALID. Exiting" .format(AWS_ACCESS_KEY_ID))
            ^
./libs/opsworks.py:86:13: F821 undefined name 'sys'
            sys.exit("{} : The AWS KEY IS INVALID. Exiting" .format(AWS_ACCESS_KEY_ID))
            ^
./libs/rds.py:49:13: F821 undefined name 'sys'
            sys.exit("{} : The AWS KEY IS INVALID. Exiting" .format(AWS_ACCESS_KEY_ID))
            ^
./libs/s3.py:102:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/s3.py:160:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/s3.py:184:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/s3.py:211:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/s3.py:240:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/s3.py:264:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/s3.py:288:54: F821 undefined name 'file'
            print("{} object does not exist.".format(file))
                                                     ^
./libs/s3.py:290:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/s3.py:316:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/ses.py:48:13: F821 undefined name 'sys'
            sys.exit("{} : The AWS KEY IS INVALID. Exiting" .format(AWS_ACCESS_KEY_ID))
            ^
./libs/ses.py:85:13: F821 undefined name 'sys'
            sys.exit("{} : The AWS KEY IS INVALID. Exiting" .format(AWS_ACCESS_KEY_ID))
            ^
./libs/ses.py:122:13: F821 undefined name 'sys'
            sys.exit("{} : The AWS KEY IS INVALID. Exiting" .format(AWS_ACCESS_KEY_ID))
            ^
./libs/sns.py:29:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/sns.py:50:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/sns.py:69:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/sns.py:87:13: F821 undefined name 'sys'
            sys.exit("The AWS KEY IS INVALID. Exiting")
            ^
./libs/sqs.py:42:13: F821 undefined name 'sys'
            sys.exit("{} : The AWS KEY IS INVALID. Exiting" .format(AWS_ACCESS_KEY_ID))
            ^
./libs/sts.py:36:69: F821 undefined name 'region'
            print("[-] Cant connect to the {} endpoint [-]" .format(region))
                                                                    ^
./libs/sts.py:63:69: F821 undefined name 'region'
            print("[-] Cant connect to the {} endpoint [-]" .format(region))
                                                                    ^
23    F821 undefined name 'region'
23
carnal0wnage commented 6 years ago

thanks @cclauss this was a result of all the module files running individually when i first built this. Now that weirdAAL.py does the credential check and that code should never get hit. I put in another issue to create a better way/ single function to handle the client error blocks of code. thanks for the PR!