WAF rule that matches URI AND does NOT contain a string in a header

0

I want to create a WAFv2 rule that matches part of the URI AND does NOT contain a string in one of the headers. I see a match type of "Contains string" but do not see how to negate this. Is this possible?

TreverW
질문됨 4년 전1421회 조회
1개 답변
0

Hi Trever,

This is definitely possible in WAFv2, however you will need to use the JSON editor as nesting statement is not supported through visual rule builder at the moment. Please see sample JSON code below (copy and paste to the JSON editor):

{
  "Name": "RuleContainingURIMatchAndNotHeader",
  "Priority": 0,
  "Action": {
    "Block": {}
  },
  "VisibilityConfig": {
    "SampledRequestsEnabled": true,
    "CloudWatchMetricsEnabled": true,
    "MetricName": "RuleContainingURIMatchAndNotHeader"
  },
  "Statement": {
    "AndStatement": {
      "Statements": [
        {
          "ByteMatchStatement": {
            "FieldToMatch": {
              "UriPath": {}
            },
            "PositionalConstraint": "CONTAINS",
            "SearchString": "my-uri-string",
            "TextTransformations": [
              {
                "Type": "NONE",
                "Priority": 0
              }
            ]
          }
        },
        {
          "NotStatement": {
            "Statement": {
              "ByteMatchStatement": {
                "FieldToMatch": {
                  "SingleHeader": {
                    "Name": "MyHeader"
                  }
                },
                "PositionalConstraint": "CONTAINS",
                "SearchString": "header-s",
                "TextTransformations": [
                  {
                    "Type": "NONE",
                    "Priority": 0
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

Note that once you go into JSON editor and write rule, you cannot return to the visual rule builder.

If you wish to learn more, I also recommend signing up for future webinar where we will do deep dive into rule writing: https://pages.awscloud.com/AWS-Online-Tech-Talks_2020_0317-SID.html

Thanks,

AWS
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠