Regularexpression from JSONPayload

Hi All ,

I have a requirement where I have to apply regular threat protection Policy to protect the proxy from SQL injection, I have to put an ID in the request in array format (a Valid Json Format) but I am getting error from the Policy. I have attached the request, policy configuration and the response below. Please suggest me something.

surbhi123_0-1655190368527.pngsurbhi123_1-1655190373058.png

 

Solved Solved
0 1 75
1 ACCEPTED SOLUTION

It looks like you're using Apigee Edge?  The jsonpath library that is used within Apigee Edge is older, and does not handle arrays of strings well.  (This has been fixed in Apigee X and hybrid) 

I suggest that you don't use a JSONPath at all.  In the policy configuration you showed, you are selecting on "*", that basically means "every field in the JSON". 

So in that case, why not just apply the check against the variable "request.content"? 

remove this: 

<JSONPayload>
  <JSONPath>
    <Expression>*</Expression>
    <Pattern>(your pattern here)</Pattern>
  </JSONPath>
</JSONPayload>

add this: 

<Variable name="request.content">
    <Pattern>(your pattern here)</Pattern>
</Variable>

 

View solution in original post

1 REPLY 1

It looks like you're using Apigee Edge?  The jsonpath library that is used within Apigee Edge is older, and does not handle arrays of strings well.  (This has been fixed in Apigee X and hybrid) 

I suggest that you don't use a JSONPath at all.  In the policy configuration you showed, you are selecting on "*", that basically means "every field in the JSON". 

So in that case, why not just apply the check against the variable "request.content"? 

remove this: 

<JSONPayload>
  <JSONPath>
    <Expression>*</Expression>
    <Pattern>(your pattern here)</Pattern>
  </JSONPath>
</JSONPayload>

add this: 

<Variable name="request.content">
    <Pattern>(your pattern here)</Pattern>
</Variable>