如果请求包含 get url 或 post 正文中的单词,我该如何阻止使用 urlrewrite for tomcat

How can I block if a request contains a word in get url or post body using urlrewrite for tomcat

我有一个安全漏洞需要通过阻止请求中的关键字来修复。如果 get 或 post 请求包含关键字 "ENTITY" 我想 url 重写以阻止请求并发送 403.

谁能帮我写下urlrewrite.xml中的规则? 这是我试过的方法,但不起作用。

 <rule>
    <note>
     Restrict keyword ENTITY in get or post request.   
    </note>
    <name>Restrict URI Access</name>
    <condition type="request-uri" operator="equal">ENTITY</condition>
    <from>(/.*)</from>
    <set type="status">403</set>
    <to last="true">null</to>
</rule>

谢谢 ...玛纳斯

以下规则应该可以解决问题。 这里filter是request的参数,可能包含关键字"ENTITY".

PS:因为是URL可能有多种大小写组合所以参数"filter"可以写。 (例如 FILTER、过滤器、过滤器等。)

<rule>
    <note>
        Stop ENTITY keyword
    </note>
    <name>StopENTITYKEYWORD</name>
    <condition type="parameter" name="filter" next="or">ENTITY</condition>
    <from>(/.*)</from>
    <set type="status">403</set>
    <to last="true">null</to>
</rule>