Log Obfuscation

This interceptor is used to obfuscate selected data (present in the header or body of the request or response) from Trace logs.

To create Trace logs (accessed by clicking the icon view icon), you must use the Log interceptor . If you wish the data to be encrypted rather than obfuscated, this can be configured in the Log interceptor itself.

Configuring the interceptor

To configure the Log Obfuscation interceptor, you must inform the location of the information to be hidden, a custom regular expression (custom regex) to identify this information, and the symbols to be used in its place (in the field Replace to).

log obfuscation
It is possible to hide multiple pieces of information with a single Log Obfuscation interceptor using a suitable regular expression (as explained here).

Examples of hiding a single piece of information

Imagine that the body of a request contains the following information:

{
  "name": "Jonathan Crane",
  "alias": "Scarecrow",
  "baseOfOperations": [
    "Gotham City",
    "Arkham Asylum"
  ],
  "status": {
    "alignment": "bad",
    "citizenship": "american",
    "maritalStatus": "single",
    "occupation": [
      "anarchist",
      "serial killer",
      "former psychiatrist",
      "university professor"
    ],
    "active": true
  },
  "characteristics": {
    "gender": "male",
    "height": 1.83,
    "weight": 64,
    "eyes": "blue",
    "hair": "brown"
  }
}

You have to create a suitable regular expression to hide a field. For example, if you want to obfuscate the "name" field, you can add the following settings:

log obfuscation ex name

As a result, Trace will show the following log for this request:

{
  "name": **********,
  "alias": "Scarecrow",
  "baseOfOperations": [
    "Gotham City",
    "Arkham Asylum"
  ],
  "status": {
    "alignment": "bad",
    "citizenship": "american",
    "maritalStatus": "single",
    "occupation": [
      "anarchist",
      "serial killer",
      "former psychiatrist",
      "university professor"
    ],
    "active": true
  },
  "characteristics": {
    "gender": "male",
    "height": 1.83,
    "weight": 64,
    "eyes": "blue",
    "hair": "brown"
  }
}

To obfuscate the "occupation" field, you can add the following settings:

log obfuscation ex occupation

As a result, Trace will show the following log for this request:

{
  "name": "Jonathan Crane",
  "alias": "Scarecrow",
  "baseOfOperations": [
    "Gotham City",
    "Arkham Asylum"
  ],
  "status": {
    "alignment": "bad",
    "citizenship": "american",
    "maritalStatus": "single",
    "occupation": ##########,
    "active": true
  },
  "characteristics": {
    "gender": "male",
    "height": 1.83,
    "weight": 64,
    "eyes": "blue",
    "hair": "brown"
  }
}

Finally, to obfuscate the "characteristics" field, you can add the following settings:

log obfuscation ex characteristics

As a result, Trace will show the following log for this request:

{
  "name": "Jonathan Crane",
  "alias": "Scarecrow",
  "baseOfOperations": [
    "Gotham City",
    "Arkham Asylum"
  ],
  "status": {
    "alignment": "bad",
    "citizenship": "american",
    "maritalStatus": "single",
    "occupation": [
      "anarchist",
      "serial killer",
      "former psychiatrist",
      "university professor"
    ],
    "active": true
  },
  "characteristics": {****}
}

Combining those three interceptors sequentially, Trace will show the following Log for this request:

{
  "name": **********,
  "alias": "Scarecrow",
  "baseOfOperations": [
    "Gotham City",
    "Arkham Asylum"
  ],
  "status": {
    "alignment": "bad",
    "citizenship": "american",
    "maritalStatus": "single",
    "occupation": ##########,
    "active": true
  },
  "characteristics": {****}
}

However, a better way to obfuscate multiple fields is to use a single comprehensive regular expression (see examples below).

Regular expression for multiple information fields

When the data set is part of a JSON, a regular expression for multiple information follows the structure:

(?<=(<keys>):)\s*(<regex_types>)
The "\s*" of the regular expression is used to ignore any white spaces between key and value.

Both keys (information) and regex for each type of value must be separated by "|".

The regex for the corresponding value types are:

  • numbers, booleans and null: [\+\-\w.]+

  • strings: "[^"]*"

  • simple arrays: \[[^\]]*\]

  • simple objects: \{[^\}]*\}

Examples of hiding multiple pieces of information

Now, imagine that the body of a request contains the following information:

{
  "name": "Pamela Lillian Isley",
  "alias": "Poison Ivy",
  "baseOfOperations": "Gotham City",
  "status": {
    "alignment": "neutral",
    "citizenship": "american",
    "maritalStatus": "single",
    "occupation": [
      "scientist",
      "eco-terrorist"
    ],
    "active": true
  },
  "characteristics": {
    "gender": "female",
    "height": 1.68,
    "weight": 50,
    "eyes": "green",
    "hair": "red"
  }
}

For example, to simultaneously hide the "name", "occupation" and "characteristics" fields, you can add the following settings:

log obfuscation ex multiple

As a result, Trace will show the following log for this request:

{
  "name":*****,
  "alias": "Poison Ivy",
  "baseOfOperations": "Gotham City",
  "status": {
    "alignment": "neutral",
    "citizenship": "american",
    "maritalStatus": "single",
    "occupation":*****,
    "active": true
  },
  "characteristics":*****
}

On the other hand, to simultaneously hide the "name", "citizenship", "maritalStatus", "active", "height" and "weight" fields, it’s enough to replace the previous regex with:

(?<=("name"|"citizenship"|"maritalStatus"|"active"|"height"|"weight"):)\s*("[^"]*"|[\+\-\w.]+)

As a result, Trace will show the following log for this request:

{
  "name":*****,
  "alias": "Poison Ivy",
  "baseOfOperations": "Gotham City",
  "status": {
    "alignment": "neutral",
    "citizenship":*****,
    "maritalStatus":*****,
    "occupation": [
      "scientist",
      "eco-terrorist"
    ],
    "active":*****
  },
  "characteristics": {
    "gender": "female",
    "height":*****,
    "weight":*****,
    "eyes": "green",
    "hair": "red"
  }
}
Unlike the case where multiple interceptors were used, the symbols applied to obfuscate the information are necessarily the same.
Thanks for your feedback!
EDIT

Share your suggestions with us!
Click here and then [+ Submit idea]