hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.74k stars 9.1k forks source link

Support for JsonBody in fields to match on WAF ByteMatch rule #18515

Closed chrisportela closed 2 years ago

chrisportela commented 3 years ago

Community Note

Description

Was trying to implement some WAF rules and noticed that the Console lets you make ones which target the parsed JsonBody instead of the raw Body.

This feature was released Feb 2021 and would be very helpful in blocking invalid requests.

New or Affected Resource(s)

Potential Terraform Configuration

Just the statement portion for hypothetically ensuring a graphql query has "viewer" somewhere in the query field.

statement {
    byte_match_statement {
    field_to_match {
      json_body = {
        match_scope = "ALL"
        invalid_fallback_behavior = "NO_MATCH"
        match_pattern = {
          included_paths = ["/query"]
        }
      }
    }
    positional_constraint = "CONTAINS_WORD"
    search_string = "viewer"
    text_transformation = {
      priority = 0
      type = "NONE"
    }
  }
}

References

nevelis commented 2 years ago

It's been over a year since this feature came out, and nearly as long since this was reported. One of our rules requires json_body and we cannot describe our WAF infrastructure without this.

Given that there is no activity on this, I'm hoping someone has had some luck with a workaround. Any ideas short of using a null_resource with the CLI to do this properly? :(

steveorourke commented 2 years ago

Blocked on this as well. I'll put together a PR, if no one else has made a start.

tiborhercz commented 2 years ago

I see that this PR is stale for a long time. Which is a shame because of the work that is done by @steveorourke. I will review and test the code and make sure it will get merged.

tiborhercz commented 2 years ago

Code has been reviewed and tested. LGMT! 👍🏼 @steveorourke I have suggested some small changes to the code and documentation. Let me know what you think

steveorourke commented 2 years ago

Thanks @tiborhercz. I've accepted all suggestions.

tiborhercz commented 2 years ago

Thanks @steveorourke Code has been reviewed and tested. LGMT! 👍🏼

@bschaatsbergen Could you please also take a look?

github-actions[bot] commented 2 years ago

This functionality has been released in v4.29.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.