如何使用PHP SDK或AWS CLI更新WAFV2中的WebACL,而不会丢失重要配置?

0

【以下的问题经过翻译处理】 使用WAFV2时,调用GetWebACL时会出现CustomResponse配置丢失的情况。如果随后将此配置用于调用UpdateWebACL,则CustomResponse将丢失。

这是一个严重的错误,可能会导致未检测到的配置丢失,因为两个API调用的响应都是成功的。

API文档说明:

要修改Web ACL,请执行以下操作: 1)通过调用GetWebACL检索它 2)根据需要更新其设置 3)将完整的Web ACL规范提供给UpdateWebACL

例如,具有以下配置的WAFV2规则:

{
   "Name":"RateLimit-3000",
   "Priority":8,
   "Statement":{
      "RateBasedStatement":{
         "Limit":3000,
         "AggregateKeyType":"IP"
      }
   },
   "Action":{
      "Block":{
         "CustomResponse":{
            "ResponseCode":429,
            "CustomResponseBodyKey":"TooManyRequests"
         }
      }
   },
   "VisibilityConfig":{
      "SampledRequestsEnabled":true,
      "CloudWatchMetricsEnabled":true,
      "MetricName":"RateLimit-3000"
   }
}

通过调用GetWebACL的API调用返回:

{
   "Name":"RateLimit-3000",
   "Priority":8,
   "VisibilityConfig":{
      "MetricName":"RateLimit-3000",
      "CloudWatchMetricsEnabled":true,
      "SampledRequestsEnabled":true
   },
   "Action":{
      "Block": { }
   },
   "Statement":{
      "RateBasedStatement":{
         "AggregateKeyType":"IP",
         "Limit":3000
      }
   }
}

如果将该配置传递回UpdateWebACL的API调用,则Block Action中的CustomResponse将被删除。

这是一个已知的错误,还是有其他正确更新WebACL而不会丢失配置的方法?

profile picture
EXPERT
asked 5 months ago11 views
1 Answer
0

【以下的回答经过翻译处理】 通过更新PHP SDK和AWS CLI至最新版本,此问题已经得到解决。希望这个答案能帮助其他人,使用旧版的PHP SDK或AWS CLI仍然可以执行命令,但使用它们会导致配置意外丢失并产生破坏性。

profile picture
EXPERT
answered 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions