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

The program will throw an error when entity['rules'] is empty. #13

Open
Gingsguard opened this issue Jun 9, 2023 · 2 comments
Open
Labels

Comments

@Gingsguard
Copy link

Hi, I found a bug in the script. When analyzing the incoming JSON, entity['rules'] may be empty, which causes the program to crash and exit.
I found a solution to fix the issue. Please refer to the image below.
image

@cicode225
Copy link

Hello,
I encountered this issue.... How did you solve it ?

image

@ryankenney-dev
Copy link

My workaround...

Updated ExtensiveRoleCheck.py, adding a condition:

def _generate(self):
    for entity in self._json_file['items']:
        role_name = entity['metadata']['name']

        # Add check for empty rules
        if not entity['rules']:
            continue

        for rule in entity['rules']:
            if not rule.get('resources', None):
                continue
            self.get_read_secrets(rule, role_name)
            self.clusteradmin_role(rule, role_name)
            self.any_resources(rule, role_name)
            self.any_verb(rule, role_name)
            self.high_risk_roles(rule, role_name)
            self.role_and_roleBindings(rule, role_name)
            self.create_pods(rule, role_name)
            self.pods_exec(rule, role_name)
            self.pods_attach(rule, role_name)

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

No branches or pull requests

3 participants