79507312

Date: 2025-03-13 18:35:09
Score: 2
Natty:
Report link

Create 2 rules for your WebAcl

For header 1

{
  "Name": "block-not-header-1",
  "Priority": 0,
  "Statement": {
    "AndStatement": {
      "Statements": [
        {
          "ByteMatchStatement": {
            "SearchString": "/some_uri",
            "FieldToMatch": {
              "UriPath": {}
            },
            "TextTransformations": [
              {
                "Priority": 0,
                "Type": "NONE"
              }
            ],
            "PositionalConstraint": "EXACTLY"
          }
        },
        {
          "NotStatement": {
            "Statement": {
              "SizeConstraintStatement": {
                "FieldToMatch": {
                  "SingleHeader": {
                    "Name": "header1"
                  }
                },
                "ComparisonOperator": "GT",
                "Size": 0,
                "TextTransformations": [
                  {
                    "Priority": 0,
                    "Type": "NONE"
                  }
                ]
              }
            }
          }
        }
      ]
    }
  },
  "Action": {
    "Block": {}
  },
  "VisibilityConfig": {
    "SampledRequestsEnabled": true,
    "CloudWatchMetricsEnabled": true,
    "MetricName": "block-not-header-1"
  }
}

For header 2 and so on....

{
  "Name": "block-not-header-2",
  "Priority": 1,
  "Statement": {
    "AndStatement": {
      "Statements": [
        {
          "ByteMatchStatement": {
            "SearchString": "/some_uri",
            "FieldToMatch": {
              "UriPath": {}
            },
            "TextTransformations": [
              {
                "Priority": 0,
                "Type": "NONE"
              }
            ],
            "PositionalConstraint": "EXACTLY"
          }
        },
        {
          "NotStatement": {
            "Statement": {
              "SizeConstraintStatement": {
                "FieldToMatch": {
                  "SingleHeader": {
                    "Name": "header2"
                  }
                },
                "ComparisonOperator": "GT",
                "Size": 0,
                "TextTransformations": [
                  {
                    "Priority": 0,
                    "Type": "NONE"
                  }
                ]
              }
            }
          }
        }
      ]
    }
  },
  "Action": {
    "Block": {}
  },
  "VisibilityConfig": {
    "SampledRequestsEnabled": true,
    "CloudWatchMetricsEnabled": true,
    "MetricName": "block-not-header-2"
  }
}

This is the result that you are looking for, right?

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: Vincent Tjianattan