Switch to ANDing Conditions keys instead of OR#188
Draft
tweedge wants to merge 2 commits intoNetflix-Skunkworks:masterfrom
Draft
Switch to ANDing Conditions keys instead of OR#188tweedge wants to merge 2 commits intoNetflix-Skunkworks:masterfrom
tweedge wants to merge 2 commits intoNetflix-Skunkworks:masterfrom
Conversation
Get up to date with main
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Howdy! Noticed a false positive with policies that have multiple conditions, such as:
This is because
is_condition_internet_accessibleinstatement.pychecked each individual statement for public accessibility, and if any is public, it marks the statement public. The grammar for Conditions differs, and all keys are ANDed within a particular Condition, so this is not publicly accessible as both the PrincipalOrgID and PrincipalArn requirements need to be fulfilled: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-logic-multiple-context-keys-or-values.htmlTo address this, I've modified
statement.pyto check all Conditions for public accessibility, and then only return that the resource is publicly accessible if all Conditions are public. I've added a test case for this particular policy and all existing tests pass. However, most test cases do not focus on multiple Conditions, so I'm going to deep dive some more cases and ensure the change is appropriate before unmarking this as draft. I could envision cases where ex. an unmonitored action (tags?) could then cause policies to be marked as non-public simply because it has no*in it, which needs to be stamped out first.