Regular Expresion Protection Policy and Flow Variables

Not applicable

Hi all,

I'm using a Regex policy within a shared flow. So I cannot hardcode the Regex inside the policy's XML. I actually have it in a flow variable but i cannot make policy takes Regex from there:

<Variable name="queryParamsInfo">

<Pattern>regexConfRegex</Pattern>

</Variable>

queryParamsInfo and regexConfRegex are context variables the first is being read correctly in the policy execution, but the regexConfRegex which contains the pattern is not getting load.

How does the regex policy support reading the regular expression from a flow variable? or is not supported?

0 1 960
1 REPLY 1

What you describe is not supported with the RegEx Protection policy.

You could do something like that with a JavaScript step and a property.

configure the JavaScript step like this:

<Javascript name='JS-CheckRegex'>
  <Properties>
    <Property name='regexVar'>a_context_variable</Property>
  </Properties>
  <ResourceURL>jsc://checkRegex.js</ResourceURL>
</Javascript>

And then your JS would look something like this:

var regexString = context.getVariable(properties.regexVar);
var re = new RegExp(regexString); 
var content = context.getVariable('request.content');
var match = re.exec(content); 
if (match) { 
  // set variables or throw a suitable exception here
}