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

fix ecs__enum crash on permission denied #451

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

h00die
Copy link
Contributor

@h00die h00die commented Sep 12, 2024

Problem

When using ecs__enum without cluster list permissions, we get the following output:

Pacu (blackbox2:imported-arte) > run ecs__enum --region us-east-1
  Running module ecs__enum...
[ecs__enum] Starting region us-east-1...
[ecs__enum] FAILURE: 
[ecs__enum]   AccessDeniedException
[ecs__enum]     Skipping cluster enumeration...

[2024-09-12 16:28:04] Pacu encountered an error while running the previous command. Check /root/.local/share/pacu/blackbox2/error_log.txt for technical details, or use the debug command. [LOG LEVEL: MINIMAL]

    <class 'TypeError'>: 'NoneType' object is not subscriptable

Checking the error message we see:

[2024-09-12 16:18:03] (blackbox2): 
Traceback (most recent call last):
  File "/root/pacu/pacu/main.py", line 1855, in run_gui
    self.idle()
  File "/root/pacu/pacu/main.py", line 1711, in idle
    self.idle()
  File "/root/pacu/pacu/main.py", line 1711, in idle
    self.idle()
  File "/root/pacu/pacu/main.py", line 1711, in idle
    self.idle()
  [Previous line repeated 4 more times]
  File "/root/pacu/pacu/main.py", line 1709, in idle
    self.parse_command(command)
  File "/root/pacu/pacu/main.py", line 623, in parse_command
    self.parse_exec_module_command(command)
  File "/root/pacu/pacu/main.py", line 815, in parse_exec_module_command
    self.exec_module(command)
  File "/root/pacu/pacu/main.py", line 1032, in exec_module
    summary_data = module.main(command[2:], self)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/pacu/pacu/modules/ecs__enum/main.py", line 116, in main
    for arn in response['clusterArns']:
               ~~~~~~~~^^^^^^^^^^^^^^^
<class 'TypeError'>: 'NoneType' object is not subscriptable

Solution

Generate the object which is expected, then gracefully handle accessing items that aren't there.

New output:

Pacu (blackbox2:imported-arte) > run ecs__enum --region us-east-1
  Running module ecs__enum...
[ecs__enum] Starting region us-east-1...
[ecs__enum] FAILURE: 
[ecs__enum]   AccessDeniedException
[ecs__enum]     Skipping cluster enumeration...
[ecs__enum]   0 cluster arn(s) found.
[ecs__enum]   0 container(s) found.
[ecs__enum]   0 service(s) found.
[ecs__enum] FAILURE: 
[ecs__enum]   AccessDeniedException
[ecs__enum]   Skipping instance enumeration...
[ecs__enum]   0 task definition(s) found.
[ecs__enum] ecs__enum completed.

[ecs__enum] MODULE SUMMARY:

  Regions:
     us-east-1

    0 total cluster(s) found.
    0 total container(s) found.
    0 total service(s) found.

Copy link
Contributor

@j0eblow j0eblow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested and approved. lgtm, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants