【问题标题】:AWS WAF not blocking requests using aws_wafregional_regex_pattern_setAWS WAF 不使用 aws_wafregional_regex_pattern_set 阻止请求
【发布时间】:2020-12-08 12:50:07
【问题描述】:

我有点惊讶我遇到了这个问题。我创建了一个 aws_wafregional_regex_pattern_set 来阻止在其 URI 中包含 php 的传入请求。我希望所有带有 php 的请求都会被阻止。但是,请求仍在通过。也许,我误解了这个资源的实际作用?我在下面附上了一些示例代码。

resource "aws_wafregional_rule" "block_uris_containining_php" {
  name = "BlockUrisContainingPhp"
  metric_name = "BlockUrisContainingPhp"

  predicate {
    data_id = "${aws_wafregional_regex_match_set.block_uris_containing_php.id}"
    negated = false
    type = "RegexMatch"
  }

}

resource "aws_wafregional_regex_match_set" "block_uris_containing_php" {
  name = "BlockUrisContainingPhp"

  regex_match_tuple {
    field_to_match {
      type = "URI"
    }

    regex_pattern_set_id = "${aws_wafregional_regex_pattern_set.block_uris_containing_php.id}"
    text_transformation = "NONE"
  }
}

resource "aws_wafregional_regex_pattern_set" "block_uris_containing_php" {
  name = "BlockUrisContainingPhp"
  regex_pattern_strings = [ "php$" ]
}

此代码在 AWS WAF 中创建一个 String and regex matching condition。所以,我知道它至少正在被创建。当我向负载均衡器发送包含 php 的请求时,我使用 cloudwatch 检查被阻止的请求,但每个请求都成功通过。对此的任何帮助将不胜感激。

【问题讨论】:

    标签: terraform


    【解决方案1】:

    我无法通过 sn-p 判断,但您是否将规则添加到 Web ACL 并将规则操作设置为阻止?

    此外,您应该尝试使用wafv2 而不是wafregional,因为wafv2 具有新功能并且更易于表达规则。

    【讨论】:

    • 我正在使用aws_wafregional_web_acl_associationaws_alb 关联到网络acl。
    • 我假设你这样做了,但你还必须将规则添加到 Web ACL。
    猜你喜欢
    • 2020-04-04
    • 1970-01-01
    • 2021-01-13
    • 2021-06-25
    • 1970-01-01
    • 2016-08-24
    • 2022-10-24
    • 2021-05-07
    • 2020-10-10
    相关资源
    最近更新 更多