Repository navigation
Twilio Event Streams: mask helpseeker data in every event type before sending to Datadog - #4881
Open
janorivera wants to merge 5 commits into
Open
janorivera wants to merge 5 commits into
janorivera wants to merge 5 commits into
Conversation
… sending to Datadog The forwarder only masked a fixed list of TaskRouter task attributes. Phone numbers, IPs and emails were reaching Datadog through other attributes (name_old, outbound_to, conversations.external_contact), Studio executions (contact_channel_address), Messaging events, and error-log events (Functions and Studio console output, error messages). filterSensitiveData now masks, for every event: - task attributes by name at any depth, then IPs, emails and phone numbers in any attribute - contact addresses and message text by field name - phone numbers, IPs and emails in every field of error-log events - phone numbers and channel IDs anywhere in the event Masking runs only after the Twilio signature is validated. Adds unit tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fore sending to Datadog - Mask Body/ProfileName at any depth and in free text (URL-encoded and logged JSON) - Parse JSON inside strings (error log payloads) and mask field by field, keeping it valid - Mask names entirely; numbers and addresses keep their last 4 characters - Mask numeric helpseeker attributes, more contact keys, LINE IDs and long numbers - Full masking (emails, IPs) for every event type, keeping worker_name readable - Mask inside the Datadog try block so a failure never sends unmasked data or fails the request - Rename attributeFilterer to sensitiveDataFilter; typed test helpers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fore sending to Datadog The previous commit only carried the attributeFilterer -> sensitiveDataFilter rename. - Mask Body/ProfileName at any depth and in free text (URL-encoded and logged JSON) - Parse JSON inside strings (error log payloads) and mask field by field, keeping it valid - Mask names entirely; numbers and addresses keep their last 4 characters - Mask numeric helpseeker attributes, more contact keys, LINE IDs and long numbers - Full masking (emails, IPs) for every event type, keeping worker_name readable - Mask inside the Datadog try block so a failure never sends unmasked data or fails the request - Typed test helpers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Body/ProfileName/CallerName in logged JSON: handle escaped quotes, line breaks and accents; mask to the end when cut short (also keeps it linear) - Mask lowercase body everywhere except a webhook response body - Mask WaId, ForwardedFrom, CallerName, location and city/state/zip parameters; match field names case-insensitively - Mask numbers under phone-like keys (phone, number, caller, msisdn, waid) when they have 7+ digits - Names always fully masked; values keep their last 4 characters only when those have no letters - Only rewrite JSON strings when something was masked (keeps number precision and formatting) - from/to numbers in free text only after a key separator, so timestamps in sentences are kept - Log the account and say masking or posting when the Datadog step fails Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Bug fix (privacy). The
twilioEventStreamsLambda forwards Twilio Event Streams events to Datadog (service:twilio-event-stream). It only masked a fixed list of keys in TaskRoutertask_attributes, so helpseeker phone numbers, IPs, emails, names and message text were reaching Datadog through:name_old(caller SIP address with carrier IP),outbound_to,conversations.external_contact, which weren't on the list (~21k events/day, 11 helplines)com.twilio.error-logs.error.logged): Functions INFO console output (Task attribute: from +1…, full TaskRouter event dumps), Studio INFO "Send interaction to Flex via TaskRouter" logs, logged webhook requests (messageBody, WhatsAppProfileName/WaId), and error messages such as 81014, 32021, 13227 (~36k/day)contact_channel_address(~9k/day)from,to,Author, participant addresses and attributes, and the message textattributeFilterer.tsis renamed tosensitiveDataFilter.ts. ItsfilterSensitiveData(event)now walks every field of every event type:Body/body,ProfileName,CallerName,Latitude/Longitude, city/state/zip parameters)from,to,Author,Address,contact_channel_address,WaId,ForwardedFrom, …)phone,number,caller,msisdn,waid)Attributes)customers(keepingexternal_id),memoryandpreEngagementDataare removed as beforename_old,outbound_to,external_contact,contactIdentifier,phone,address, and fixes thefriendyNametypo.customerName,firstName,friendlyName) are always fully masked+/%2B,sip:and long numbersmodica:,messenger:,line:U…Numbers and addresses keep the existing
XXXXX+ last 4 characters format (XXXXX1234,XXXXX0.40) so events can still be told apart. A value whose last 4 characters contain letters (a name, street address or email) becomesXXXXX.What stays readable:
worker_name, for routing debuggingOther changes in
index.ts:Regexes stay linear: 200 KB adversarial inputs take ≤ 10 ms.
Not changed:
body[0]is sent to Datadog. This is intended, because sending every event caused duplicates.Checklist
Other Related Issues
None
Verification steps
cd lambdas/twilioEventStreams && npm run test:unit: 54 tests built from real event shapes (with made-up numbers)customerName: XXXXX,from: XXXXX4372). Before that they showed the old partial masking (XXXXXmous,XXXXX-sim).Body,ProfileNameorWaId.service:twilio-event-stream @account_env:STG @type:com.twilio.taskrouter.task.created. Expanddata.payload.task_attributes.service:twilio-event-stream @data.payload:*Task\ attribute\:\ from\ *\+??????????*service:twilio-event-stream @type:com.twilio.studio.flow.execution.started @data.contact_channel_address:\+*service:twilio-event-stream @data.product_name:TaskRouter @data.payload.task_attributes:(*name_old???sip\:\+??????????* OR *external_contact???\+??????????* OR *outbound_to???\+??????????*)service:twilio-event-stream @data.payload:*Send\ interaction\ to\ Flex* @data.payload:*\"name?????\+??????????*step.endedevents ever carry widget results.AFTER YOU MERGE
You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P
🤖 Generated with Claude Code