Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveYesland authored Jun 14, 2024
2 parents bd96468 + b32a306 commit 60dd4ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pacu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def display_pacu_help():
to solve this problem
console/open_console Generate a URL that will log the current user/role in to
the AWS web console
debug Display the contents of the error log file
""")


Expand Down Expand Up @@ -186,7 +187,7 @@ class Main:
'assume_role', 'aws', 'console', 'data', 'delete_session', 'exec', 'exit', 'export_keys', 'help',
'history', 'import_keys', 'list', 'list_sessions', 'load_commands_file', 'ls', 'open_console', 'quit',
'regions', 'run', 'search', 'services', 'sessions', 'set_keys', 'set_regions', 'set_ua_suffix',
'swap_keys', 'swap_session', 'unset_ua_suffix', 'update_regions', 'use', 'whoami'
'swap_keys', 'swap_session', 'unset_ua_suffix', 'update_regions', 'use', 'whoami', 'debug'
]

def __init__(self):
Expand Down Expand Up @@ -218,8 +219,8 @@ def log_error(self, text, exception_info=None, session=None, local_data=None, gl
log_file_path = '{}/global_error_log.txt'.format(session_dir())

print('\n[{}] Pacu encountered an error while running the previous command. Check {} for technical '
'details. [LOG LEVEL: {}]\n\n {}\n'.format(timestamp, log_file_path,
settings.ERROR_LOG_VERBOSITY.upper(), exception_info))
'details, or use the debug command. [LOG LEVEL: {}]\n\n {}\n'.format(timestamp, log_file_path,
settings.ERROR_LOG_VERBOSITY.upper(), exception_info))

log_file_directory = os.path.dirname(log_file_path)
if log_file_directory and not os.path.exists(log_file_directory):
Expand Down Expand Up @@ -263,6 +264,14 @@ def log_error(self, text, exception_info=None, session=None, local_data=None, gl
'and should most likely be provided to the developers.\n Exception raised: {}'.format(str(error)))
raise

def read_log_file(self):
log_file_path = '{}/error_log.txt'.format(session_dir())
if os.path.exists(log_file_path):
with open(log_file_path, 'r') as log_file:
print(log_file.read())
else:
print('No error log file found.')

# @message: String - message to print and/or write to file
# @output: String - where to output the message: both, file, or screen
# @output_type: String - format for message when written to file: plain or xml
Expand Down Expand Up @@ -633,6 +642,8 @@ def parse_command(self, command):
self.unset_user_agent_suffix()
elif command[0] == 'whoami':
self.print_key_info()
elif command[0] == 'debug':
self.read_log_file()
elif command[0] == 'exit' or command[0] == 'quit':
# write out command history for loading later
readline.write_history_file(settings.history_file)
Expand Down
1 change: 1 addition & 0 deletions pacu/modules/iam__enum_permissions/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ def summary(data, pacu_main):
out += "{:>{count_max_len}} Unconfirmed permissions for {} role(s).\n".format(data["roles_unconfirmed_perm_count"],
data["roles_unconfirmed"],
count_max_len=count_max_len)
out += "Type 'whoami' to see detailed list of permissions.\n"
return out


Expand Down

0 comments on commit 60dd4ff

Please sign in to comment.