Data masking fails to mask json field

Not applicable

Hi ,

I tried to use datamasking for POST requests .I used Content-Type as 'text\xml' and Content-Type as 'applicaiton\json' but data is not yet masked. We are using Apigee on-premise version Version 4.18.05.00

Requests:

XMLRequests:

curl -X POST -d ' <MaskDataConfiguration name="defalt"> <JSONPathsRequest> <JSONPathRequest>$.password</JSONPathRequest> </JSONPathsRequest> </MaskDataConfiguration>' http://lviapim001:8080/v1/organizations/sunsuper/apis/CustomerRoles-v1/maskconfigs -H "Content-Type:text/xml" -u email

JSON requests:

curl -X POST -d '{ "MaskDataConfiguration": { "-name": "default", "JSONPathsRequest": { "JSONPathRequest": "$.password" } } }' http://lviapim001:8080/v1/organizations/sunsuper/apis/CustomerRoles-v1/maskconfigs -H "Content-Type:application/json" -u email

Sample request json:

{ "password": "computer1", "targetURL": "www.google.com" }

Solved Solved
0 6 832
1 ACCEPTED SOLUTION

Looks like your JSON representation is incorrect, its case sensitive.

Given an XML based request with a JSON response:

curl -X PUT \
  https://api.enterprise.apigee.com/v1/o/{{ORG}}/maskconfigs/default \
  -H 'Authorization: Basic *************' \
  -H 'Content-Type: application/xml' \
  -H 'Accept: application/json' \
  -d '<MaskDataConfiguration name="default">
  <JSONPathsRequest>
    <JSONPathRequest>$.sellerId</JSONPathRequest>
    <JSONPathRequest>$.personal.SSN</JSONPathRequest>
  </JSONPathsRequest>
  
  <JSONPathsResponse>
	<JSONPathResponse>$.personal.SSN</JSONPathResponse>
  </JSONPathsResponse>
  
  <JSONPathsFault>
	<JSONPathFault>$.personal.SSN</JSONPathFault>
  </JSONPathsFault>
  
  <Variables>
	<Variable>request.header.X-APIKey</Variable>
  </Variables>
</MaskDataConfiguration>'

You can then see and use the JSON representation ferom the response:

{
    "jSONPathsFault": [
        "$.personal.SSN"
    ],
    "jSONPathsRequest": [
        "$.sellerId",
        "$.personal.SSN"
    ],
    "jSONPathsResponse": [
        "$.personal.SSN"
    ],
    "name": "default",
    "variables": [
        "request.header.X-APIKey"
    ]
}

Hope that clears it up.

View solution in original post

6 REPLIES 6

Not applicable

@rdoda, @asagar

Could you please help

I am not sure if these are typos in your question or actually in your API requests but:

In the XML version, you got the name wrong = should be default, you got "defalt".

In the JSON version, you get the "name" property wrong. You got "-name".

Hi @ozanseymen,

Thank you for the response . Sorry for the typing error.

Im attaching my requests still data is not masked.Please let me know if something is wrong in my requests.

capture.jpg

Can you try with an XML body as documented here: https://apidocs.apigee.com/management/apis/post/organizations/%7Borg_name%7D/apis/%7Bapi_name%7D/mas...

I am not sure if your JSON body structure is correct. I can't see it documented in Apigee docs - where did you get that structure from?

I will provide docs feedback for JSON content structure to be documented.

You can get the JSON representation by using headers:

Content-Type: application/xml
Accept: application/json

and vice versa.

Looks like your JSON representation is incorrect, its case sensitive.

Given an XML based request with a JSON response:

curl -X PUT \
  https://api.enterprise.apigee.com/v1/o/{{ORG}}/maskconfigs/default \
  -H 'Authorization: Basic *************' \
  -H 'Content-Type: application/xml' \
  -H 'Accept: application/json' \
  -d '<MaskDataConfiguration name="default">
  <JSONPathsRequest>
    <JSONPathRequest>$.sellerId</JSONPathRequest>
    <JSONPathRequest>$.personal.SSN</JSONPathRequest>
  </JSONPathsRequest>
  
  <JSONPathsResponse>
	<JSONPathResponse>$.personal.SSN</JSONPathResponse>
  </JSONPathsResponse>
  
  <JSONPathsFault>
	<JSONPathFault>$.personal.SSN</JSONPathFault>
  </JSONPathsFault>
  
  <Variables>
	<Variable>request.header.X-APIKey</Variable>
  </Variables>
</MaskDataConfiguration>'

You can then see and use the JSON representation ferom the response:

{
    "jSONPathsFault": [
        "$.personal.SSN"
    ],
    "jSONPathsRequest": [
        "$.sellerId",
        "$.personal.SSN"
    ],
    "jSONPathsResponse": [
        "$.personal.SSN"
    ],
    "name": "default",
    "variables": [
        "request.header.X-APIKey"
    ]
}

Hope that clears it up.