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 NoneType object is not iterable error #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

0xz00n
Copy link

@0xz00n 0xz00n commented Nov 12, 2020

No description provided.

@engn33r
Copy link

engn33r commented Oct 6, 2021

Thanks! This fixed the error I got

Comment on lines +46 to +49
try:
iterator = iter(entity['rules'])
except TypeError:
continue
Copy link

@elreydetoda elreydetoda Jan 14, 2022

Choose a reason for hiding this comment

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

Something that's a bit more pythonic (IMO) would be to do something like this:

Suggested change
try:
iterator = iter(entity['rules'])
except TypeError:
continue
if entity['rules']:

Then you'd have to move the following lines under the if:

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)

That way you're just checking to see if there are any results (since None is falsy), and it'll skip over the iterating if there are none.

Thanks for finding this though @0xz00n, seeing this PR made it easy for me to fix on my side 😁

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

Successfully merging this pull request may close these issues.

3 participants