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

WAFv2 AndStatement and OrStatement incorrect validation #2026

Closed
MattJaccino opened this issue Mar 31, 2022 · 6 comments
Closed

WAFv2 AndStatement and OrStatement incorrect validation #2026

MattJaccino opened this issue Mar 31, 2022 · 6 comments

Comments

@MattJaccino
Copy link

Hi guys,

if not isinstance(statements, list) or len(statements) != 2:
raise TypeError("Statements must be a list of 2 Statement elements")

In the validator for WAFv2 statements, there is a check to see if the number of statements if exactly 2 when it should be looking to see if there are at least 2 statements given.

"You provide more than one Statement within the AndStatement."
Source

AWS requires there to be more than one statement, but does not restrict them to only pairs.

A small change in the logic of the if statement and the TypeError message is all that is needed.

Thank you

@markpeek
Copy link
Member

Apology for the regression. As you pointed out it is an easy fix. Can you verify this change fixes it for you?

@markpeek
Copy link
Member

And...really fixed this time with a force push. Teach me to multi-task.

@MattJaccino
Copy link
Author

Yep! That would do it. Thank you!

@markpeek
Copy link
Member

markpeek commented Apr 1, 2022

I'll likely do a quick release this weekend with this, a few other PRs and any latest spec changes over the weekend. BTW, were you ok with the WAFv2 breaking changes done for 4.0.0? I hope it was an improvement.

@MattJaccino
Copy link
Author

Had to rework the pieces on our end around the creation of the resources, but definitely nice to have all of the features available now.

Not specific to WAFv2, but one thing that did strike me as odd was that resource objects can be successfully initialized without all of the required properties being given. I thought I remembered it erroring out in situations like that, or am I missing something. ?

I thought with a property defined as

class SomeProperty(AWSProperty):
    props: PropsDictType = {
        "Prop1": (TYPE, True),
        "Prop2": (TYPE, False),
    }

if you tried to initialize without defining Prop1, it would throw some kind of exception. It seems like you can initialize resource objects without including all of the required properties, or with none at all.

Was this always the case, or did something change? If not, could that potentially be a feature request?

Thank you man

@markpeek
Copy link
Member

markpeek commented Apr 4, 2022

Fixed in Release 4.0.1

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

No branches or pull requests

2 participants