-
Notifications
You must be signed in to change notification settings - Fork 6
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
No panic on invalid Statement.Resource type #9
Conversation
@@ -383,6 +383,10 @@ func newAWSStringSet(members interface{}) awsStringSet { | |||
} | |||
actions := make([]string, len(multiple)) | |||
for i, action := range multiple { | |||
if _, ok := action.(string); !ok { | |||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return nil
as this routine returns no error
and I didn't want to touch all call sites.
@@ -396,6 +400,10 @@ func newAWSPrincipalStringSet(members interface{}) awsPrincipalStringSet { | |||
} | |||
|
|||
func (actions awsStringSet) equals(other awsStringSet) bool { | |||
if actions == nil || other == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need this or else any two invalid Resource
statements (or NotResource
, Action
, NotAction
etc.) would be equal.
@@ -272,6 +272,32 @@ func TestPolicyEquivalence(t *testing.T) { | |||
policy2: policyTest29b, | |||
equivalent: true, | |||
}, | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also added these tests for missing and incorrect Statement
types.
Thanks @ewbankkit! I've tagged v1.1.0 of this library too include this fix. |
Fixes #8.
Without the
if _, ok := action.(string); !ok
code the test panics: