Selecting Data Elements to Redact or Reveal

What are operations?

Operations are different ways to navigate structured data and transform a piece of it by either redacting or replacing the value with a surrogate value.

Operations Examples

Most Common:

  • JSONPath (JSON)

  • XPath (XML)

  • Form

  • HTML / CSS

  • Regex

JSONPath

{
    "customers": {
        "first_customer": {
            "first_name": "John",
            "last_name": "Doe",
            "credit_card": "4111111111111111",
            "card_exp": "9/23",
            "card_cvv": "123"
            },
        "second_customer": {
            "first_name": "Jane",
            "last_name": "Smith",
            "credit_card": "4222222222222222",
            "card_exp": "9/23",
            "card_cvv": "123"
        }
    }
}

To redact the PCI data in this, we would simply need to create two JSONPath Operations.

Nesting with JSONPath is fairly straightforward. Every level down you go in standard JSON is just $.toplevelkey.midlevelkey.finallevelkey like if there are lists in between; you select the item using the index (or you can use wildcards).

To redact the credit_card number. All we have to do is select the key. With JSONPath selected as the operation, enter this snippet on the line next to it:

$.customers..credit_card

To redact credit_card number only for the first_customer, we would need to select the next snippet:

$.[0].credit_card

If you want to experiment with JSONPath, check out this tool.arrow-up-right

In advanced options, you can select FPE_6_T_4 to keep the credit card format for mod 10/ Luhn validation.

To redact the CVV, we need to store that in memory, not persistently. So, we add an "Add Entry".

Do exactly the same thing, but change JSONPath to:

$.[0].card_cvv

In the advanced options, we need to select Storage Volatile

Xpath

An example of how to correctly specify the path to get Number data:

//Number

or

/Envelope/Body/AddCardResponse/NewCardNumber/Number

Invalid path:

/soapenv:Envelope/soapenv:Body/AddCardResponse/NewCardNumber/Number

You do not need to specify Namespace in your path

To check XPath navigation, use this toolarrow-up-right.

Form

The last type of transformer in this guide is the Form operation. We just use the form field input names as the selector.

HTML form example:

For forms, the "name" of the input field is all that's required to replace with a surrogate value. If the Form is URL encoded, make sure you enter the filters as they look decoded.

Select the "Form" transformer and just enter:

cardNumber

and under a new entry, volatile storage for CVV

cvv

HTML

You can select this transformer option to select data in HTML forms by using CSS selectorsarrow-up-right.

If you have used a JS library like Sizzle or jQuery, you will already be familiar with these.

The simplest selectors allow you to match on

  • class names through a . e.g. .myClassName

  • an identifier via a # e.g. #myId

  • an attribute using a series of brackets, with an attribute name and optionally a value inside, e.g. [attr=value]

  • an element type by simply typing the name of the element, e.g. input

You can nest these selectors in order to achieve precise selection of data on the page, e.g. #myId .myClassName will match the input element in the following section

Regex

If the above examples do not cover the type of selection you need, then you can always fall back to a regex. VGS provides a series of named prefixes to assist with complex matching. These are

  • prefix - Anything to match before

  • token - The data to match

  • suffix - Anything matched after

If these are omitted, then anything matched by the regex in its entirety will be operated on.

Here are two examples

  • (\d{16}) - would operate on any 16-digit sequence

  • (?<prefix>foo)(?<token>\d{16})(?<suffix>\d{3}) - would operate on a 16 digit sequence prefixed with foo and suffixed with three digits e.g. foo1234567890123456123 would become footok_sandbox_asd123123 where the prefix is foo, the suffix is 123 and the 16 digit value 1234567890123456 is replaced with the value tok_sandbox_asd123

These examples cover the most common operation use cases.

Replace the value with any text and aliased value.

Replacement parameter: any text <alias placeholder>

Route config:

Input:

Output:

Replace the value with Aliased value and preserved group

Replacement parameter: <regexp group placeholder> any text <alias placeholder>

Route config:

Input:

Output:

If you have any questions or trouble, please contact us at [email protected]envelope

Last updated