I have create a proxy with no endpoint .Attached regular expression protection policy(Regular Expression Protection-XML) to request flow.I am trying to extract a variable from xml payload using XPATH and evaluates based on expression .If expression matches it has to throw exception by using Raise fault policy ,but here it is not happening.
<RegularExpressionProtection name="Regular-Expression-Protection-XML">
<DisplayName>Regular Expression Protection-XML</DisplayName>
<Properties/>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<Source>request</Source>
<XMLPayload>
<Namespaces/>
<XPath>
<Pattern ignoreCase="false">[\s]*(?i)((delete)|(exec)|(drop\s*table)|(insert)|(shutdown)|(update)|(\bor\b))</Pattern>
<Expression>//VehicleDetails/VIN</Expression>
<Type>string</Type>
</XPath>
</XMLPayload>
</RegularExpressionProtection>
If pattern matches it has to raise exception. This is the RaiseFault:
<RaiseFault name="RegExpressionErrorXML">
<DisplayName>RegExpressionErrorXML</DisplayName>
<Properties/>
<FaultResponse>
<Set>
<Payload contentType="application/json">{
"error" : {
"code" : 500,
"message" : "that was a bad request; try different one."
}
}
</Payload>
<StatusCode>500</StatusCode>
<ReasonPhrase>Server Error</ReasonPhrase>
</Set>
</FaultResponse>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
proxy.xml:
<ProxyEndpoint name="default">
<Description/>
<FaultRules>
<FaultRule name="regex-threat">
<Step><Name>RegExpressionErrorXML</Name></Step>
<Condition>(fault.name = "ThreatDetected")</Condition>
</FaultRule>
</FaultRules>
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>RE-Regular-Expression-Protection-XML</Name>
</Step>
</Request>
<Response/>
</PreFlow>
...
Request:I have sent below request as āPOSTā method
<VehicleDetails>
<VIN>/delete</VIN>
<Model>Auston Martin</Model>
<heading>Reminder</heading>
</VehicleDetails>
please suggest me ,if anything wrong with code