RegularExpressionProtection JsonPath Fails to Compile

Hi,
I am following the example given here: https://cloud.google.com/apigee/docs/api-platform/reference/policies/regular-expression-protection#j...

The example is as follows:

 

<RegularExpressionProtection name="JsonPathRegExProtection">
    <Source>request</Source>
    <JSONPayload escapeSlashCharacter="true">
       <JSONPath>
          <Expression>$.</Expression>
          <Pattern><![CDATA[ <\s*script\b[^>]*>[^<]+<\s*\/\s*script\s*> ]]></Pattern>
       </JSONPath>
    </JSONPayload>
 </RegularExpressionProtection>

 

I copy&paste the code to my Apigee policy editor as given here:

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RegularExpressionProtection continueOnError="false" enabled="true" name="RegexTP-XML_reserved_characters">
  <DisplayName>RegexTP-XML_reserved_characters</DisplayName>
  <Source>request</Source>
  <JSONPayload escapeSlashCharacter="true">
    <JSONPath>
      <Expression>$.</Expression>
      <Pattern>
        <![CDATA[ <\s*script\b[^>]*>[^<]+<\s*\/\s*script\s*> ]]>
      </Pattern>
    </JSONPath>
  </JSONPayload>
</RegularExpressionProtection>

 

When I deploy my changes, I get an error on Overview tab:

 

 

Status: instance "xxx-private-gke-dev-001" reported error steps.regexprotection.JSONPathCompilationFailed: "Failed to compile jsonpath ($.)"

Deployed on: 8/10/2023, 4:02:33 PM

 

I see many other examples using `<Expression>$.</Expression>` but in my case it fails. How do I resolve this issue?
Thanks in advance,
Gokcen

0 1 145
1 REPLY 1

Hello,

Any update on this topic, I am facing the same error, I am using Apigee Hybrid.

Br/