2017-04-25 158 views
0

我想编写一个规则,它只允许指定URL。我只有两个网址的 1:abc.com/configuration/ 2: “@beginsWith /配置” abc.com/update/用于URL白名单的ModSecurity

SecRule REQUEST_URI \ “ID:700003,阶段:1,日志,否认味精: '不同的URL来访问'”

SecRule REQUEST_URI “@beginsWith /更新” \ “ID:700004,阶段:1,登录,传递,味精: '更新URI访问'”

哪有我合并这两条规则,以便可以覆盖其他?

谢谢

+0

我不明白你的问题。 –

+0

我想允许上面的URL唯一的休息我希望该modsecurity将阻止。 – user2670674

回答

1

你可以在这里做很多事情。

By default a regex is used to match in ModSecurity,所以你可以写一个规则来涵盖URI和块,如果不匹配:

SecRule REQUEST_URI "!\/(configuration|update)\/" "phase:1,id:700003,block 

你可以使用@pm做同样的:

SecRule REQUEST_URI "[email protected] \/configuration\/ \/update\/" "phase:1,id:700003,block 

另外,您可以使用skipAfter,这将允许您按不同的规则列出URL,然后有一个阻止规则,如果上述任何规则匹配,则会跳过该规则:

SecMarker BEGIN_VALID_URL_CHECK 
SecRule REQUEST_URI "[email protected] /configuration" \ "id:700003, phase:1,log,skipAfter:END_VALID_URL_CHECK,msg:'Different URL Accessed'" 
SecRule REQUEST_URI "@beginsWith /update" \ "id:700004, phase:1,log,skipAfter:END_VALID_URL_CHECK,msg:'Update URI accessed'" 
SecRule REQUEST_URI "." \ "id:700005, phase:1,log,block,msg:'Another URI accessed - blocking'" 
SecMarker END_VALID_URL_CHECK 

或者你可以allow匹配那些在ModSecurity中停止处理这个请求的模式的规则(这可能是一个不好的选择,因为它会跳过配置稍后在你的配置中定义的任何其他ModSecurity规则,但为了完整性清酒):

SecRule REQUEST_URI "[email protected] /configuration" \ "id:700003, phase:1,log,allow,msg:'Different URL Accessed'" 
SecRule REQUEST_URI "@beginsWith /update" \ "id:700004, phase:1,log,allow, msg:'Update URI accessed'" 
SecRule REQUEST_URI "." \ "id:700005, phase:1,log,block, msg:'Another URI accessed - blocking'"