@@ -57,21 +57,30 @@ def all_allowed_actions(self):
5757 if statement .effect_allow : # if Effect is "Deny" - it is not an allowed action
5858 if statement .expanded_actions :
5959 allowed_actions .extend (statement .expanded_actions )
60+ allowed_actions = self .filter_deny_statements (allowed_actions )
61+ allowed_actions = list (dict .fromkeys (allowed_actions ))
62+ return allowed_actions
63+
64+ def filter_deny_statements (self , allowed_actions ):
65+ """
66+ filter all denied statements from actions
67+ """
6068 for statement in self .statements :
6169 if statement .effect_deny :
6270 if statement .expanded_actions :
71+ # pylint: disable=W0640
6372 allowed_actions = filter (lambda x : x not in statement .expanded_actions , allowed_actions )
64- allowed_actions = list (dict .fromkeys (allowed_actions ))
6573 return allowed_actions
6674
6775 @property
6876 def all_allowed_unrestricted_actions (self ):
6977 """Output all IAM actions that do not practice resource constraints"""
7078 allowed_actions = []
7179 for statement in self .statements :
72- if not statement .has_resource_constraints and not statement .has_condition :
80+ if not statement .has_resource_constraints and not statement .has_condition and statement . effect_allow :
7381 if statement .expanded_actions :
7482 allowed_actions .extend (statement .expanded_actions )
83+ allowed_actions = self .filter_deny_statements (allowed_actions )
7584 allowed_actions = list (dict .fromkeys (allowed_actions ))
7685 return allowed_actions
7786
0 commit comments