Technique 1: Deletion
The simplest and most effective way to protect sensitive data is to delete it. This is the best pattern for high-risk data that has little to no analytics value, such as a full credit card number.
The Goal
You will use the .without() function to remove the full_number and expiry fields from the payment_method object, as required for PCI-DSS compliance.
Implementation
-
Start with the Foundation: Copy the
remove-pii-foundation.yamlto a new file nameddelete-payment.yaml.cp examples/data-security/remove-pii-foundation.yaml delete-payment.yaml -
Add the Deletion Logic: Open
delete-payment.yamland add amappingprocessor to thepipelinesection.Add this to the 'processors' array in delete-payment.yaml- mapping: |
root = this
# The .without() function removes fields from an object.
# Here, we replace the existing payment_method object with a new one
# that doesn't have the sensitive fields.
root.payment_method = this.payment_method.without(
"full_number",
"expiry"
) -
Deploy and Test:
# Send the sample event data from the setup step
curl -X POST http://localhost:8080/events/ingest \
-H "Content-Type: application/json" \
-d @~/expanso-remove-pii/sample-event.json -
Verify: Check your logs. The
payment_methodobject in the output will no longer contain thefull_numberorexpiryfields.
You have successfully applied the deletion pattern. In the next steps, you will learn other PII removal techniques for data that has more analytics value.