Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add nowrite option to make the tool work with readonly permissions #179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

GENERAL_CONF_PATH = SERVICE_DIR + '/general.reporter.json'

CLI_TRUE_KEYWORD_ARRAY = ['yes', 'y', 'true', '1', 1]
CLI_TRUE_KEYWORD_ARRAY = ['yes', 'y', 'true', 'True', '1', 1]

SESSUID_FILENAME = 'sess-uuid'

Expand Down
11 changes: 8 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ def number_format(num, places=2):
crossAccounts = _cli_options['crossAccounts']
workerCounts = _cli_options['workerCounts']
beta = _cli_options['beta']
nowrite = _cli_options['nowrite']


# print(crossAccounts)
DEBUG = True if debugFlag in _C.CLI_TRUE_KEYWORD_ARRAY or debugFlag is True else False
testmode = True if testmode in _C.CLI_TRUE_KEYWORD_ARRAY or testmode is True else False
crossAccounts = True if crossAccounts in _C.CLI_TRUE_KEYWORD_ARRAY or crossAccounts is True else False
beta = True if beta in _C.CLI_TRUE_KEYWORD_ARRAY or beta is True else False
nowrite = True if nowrite in _C.CLI_TRUE_KEYWORD_ARRAY or nowrite is True else False
_cli_options['crossAccounts'] = crossAccounts


Expand Down Expand Up @@ -97,7 +100,9 @@ def number_format(num, places=2):
shutil.rmtree(_C.ADMINLTE_DIR + '/' + file)

acctLoop = 0
CfnTrailObj = CfnTrail()

if nowrite == False:
CfnTrailObj = CfnTrail()

for acctId, cred in rolesCred.items():
acctLoop = acctLoop + 1
Expand Down Expand Up @@ -193,7 +198,7 @@ def number_format(num, places=2):
print(f"Error decoding JSON: {e}")
exit()

if testmode == False:
if testmode == False and nowrite == False:
cfnAdditionalStr = None
if mpeid is not None:
cfnAdditionalStr = " --mpeid:{}".format(mpeid)
Expand Down Expand Up @@ -233,7 +238,7 @@ def number_format(num, places=2):
pool.starmap(Screener.scanByService, input_ranges)
pool.close()

if testmode == False:
if testmode == False and nowrite == False:
CfnTrailObj.deleteStack()

## <TODO>
Expand Down
6 changes: 6 additions & 0 deletions utils/ArguParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ class ArguParser:
"required": False,
"default": False,
"help": "Enable Beta features"
},
'nowrite': {
"required": False,
"default": False,
"help": "Enable Read-Only mode, no cloudformation required"
}

}

@staticmethod
Expand Down