JSONPath-based anonymization rules
JSONPath-based rules anonymize JSON data using JSONPath.
Required and Optional Fields
-
name
-
description (optional)
-
rule_id (should be set to JSONPATH)
-
paths
-
include_files
-
exclude_files (optional)
-
action (optional, default value is ANONYMIZE)
-
replace_value (optional, applicable only when action=REPLACE)
-
shared (optional, default value is true)
-
enabled (optional, default value is true)
Rule Definition Example
{
"name": "JSONPATH_RULE",
"rule_id": "JSONPATH",
"paths": ["$.users[0].password"],
"include_files": ["*test_config.json"],
"shared": true
}
Sample Input JSON Data
{
"users": [
{
"name": "Logsearch Admin",
"username": "admin",
"password": "testdata"
},
{
"name": "Admin",
"username": "admin",
"password": "test data"
}
]
}
Sample Output JSON Data (After Anonymization)
{
"users": [
{
"name": "Logsearch Admin",
"username": "admin",
"password": "¶smfvvcz9¶"
},
{
"name": "Admin",
"username": "admin",
"password": "test data"
}
]
}
More Examples
Example 1: Rule with nested JSON elements
Rule definition example:
{
"name": "NESTED_JSONPATH_RULE_1",
"rule_id": "JSONPATH",
"paths": ["$.configs.properties.passwd"],
"include_files": ["*config.json"],
"shared": true
}
Input data:
{
"configs": {
"properties":
{
"user": "abc",
"passwd": "12!@"
}
}
}
Output data (after anonymizarion):
{
"configs": {
"properties": {
"user": "abc",
"passwd": "¶91!@¶"
}
}
}
Example 2: Rule with indexed JSON array objects
Rule definition example:
{
"name": "ARRAY_JSONPATH_RULE",
"rule_id": "JSONPATH",
"paths": ["$.configs.properties[1].passwd"],
"include_files": ["config.json"],
"shared": true
}
Input data:
{
"configs": {
"properties": [
{
"database": "mysql",
"url": "user@host:port"
},
{
"user": "abc",
"passwd": "12!@"
}
]
}
}
Output data (after anonymization):
{
"configs": {
"properties": [
{
"database": "mysql",
"url": "user@host:port"
},
{
"user": "abc",
"passwd": "¶91!@¶"
}
]
}
}
Example 3: Rule with JSON map
Rule definition example:
{
"name": "MAP_JSONPATH_RULE",
"rule_id": "JSONPATH",
"paths": ["$.properties.passwd"],
"include_files": ["*config.json"],
"shared": true
}
Input data:
{
"db":"mysql",
"properties":{
"user_name":"sa",
"passwd":"sa_pass"
},
"pooli_size":32,
"timeout":10
}
Output data (after anonymization):
{
"db": "mysql",
"properties": {
"user_name": "sa",
"passwd": "¶vm_wtto¶"
},
"pooli_size": 32,
"timeout": 10
}
Example 4: Rule to mask all JSON objects from list
Rule definition example:
{
"name": "ALL_FROM_ARRAY_JSONPATH_RULE",
"rule_id": "JSONPATH",
"paths": ["$.configs.properties[*].passwd"],
"include_files": ["*config.json"],
"shared": true
}
Input data:
{
"configs": {
"properties": [
{
"user": "abc1",
"passwd": "pass1"
},
{
"user": "abc2",
"passwd": "pass2"
}
]
}
}
Output data (after anonymization):
{
"configs": {
"properties": [
{
"user": "abc1",
"passwd": "¶smfz7¶"
},
{
"user": "abc2",
"passwd": "¶smfz8¶"
}
]
}
}