[Avo v2] Add regex pattern validation for Inspector v2#3663
Open
aleks-tpom6oh wants to merge 5 commits intosegmentio:mainfrom
Open
[Avo v2] Add regex pattern validation for Inspector v2#3663aleks-tpom6oh wants to merge 5 commits intosegmentio:mainfrom
aleks-tpom6oh wants to merge 5 commits intosegmentio:mainfrom
Conversation
Add support for regex pattern validation in the Avo Inspector v2 destination's property value validation. This enables validating string property values against regex patterns defined in the Avo Tracking Plan. Changes: - Add regex pattern constraint support (regexPatterns) to property validation - Use RE2 (via re2-wasm) for safe regex evaluation, preventing catastrophic backtracking - Support both legacy string format and new object-map format for regex patterns - Gracefully handle invalid or unsupported regex patterns by skipping them - Simplify encryption to per-value approach (remove session-based encryption) - Add comprehensive tests for regex validation, ReDoS safety, and edge cases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep the pre-computed EncryptionSession approach where EC key generation and ECDH happen once per batch rather than once per property value. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep PR focused on regex validation only: - Remove validatedBranchId field from EventSchemaBody and event payload - Restore MAX_WIRE_DEPTH=2 guard for nested property constraint conversion - Remove related test assertions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cover well-known catastrophic backtracking patterns:
- Overlapping alternation (a|a)*
- Nested repetition with wildcard (.*a){x}
- Quantified group with character classes ([a-zA-Z]+)*
- Email-like pattern with nested quantifiers
All complete in linear time with RE2.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds regex-based property value validation to the Avo Inspector v2 “send schema” flow, extending the existing constraint validator (pinned/allowed/min-max) to support rx constraints from the event spec wire format.
Changes:
- Extends wire/internal constraint types to include regex constraints (
rx→regexPatterns). - Updates wire-to-constraint conversion and constraint merging/validation to evaluate regex patterns using RE2 (via
re2-wasm) with per-invocation caching. - Adds/updates unit and integration tests covering legacy + object-map wire formats, invalid/unsupported patterns, and ReDoS-style patterns.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/destination-actions/src/destinations/avo-v2/sendSchemaToInspector/types.ts | Adds rx to the wire constraint type and regexPatterns to internal constraints. |
| packages/destination-actions/src/destinations/avo-v2/sendSchemaToInspector/functions/functions.ts | Converts rx (legacy string or object-map) into regexPatterns on constraints. |
| packages/destination-actions/src/destinations/avo-v2/sendSchemaToInspector/functions/event-validator-functions.ts | Implements regex validation using RE2 + cache; merges/copies regex constraints across events. |
| packages/destination-actions/src/destinations/avo-v2/sendSchemaToInspector/tests/schema-functions.test.ts | Adds edge-case tests for non-string values and invalid regex patterns. |
| packages/destination-actions/src/destinations/avo-v2/sendSchemaToInspector/tests/avo.test.ts | Adds integration coverage for both rx wire formats. |
| packages/destination-actions/src/destinations/avo-v2/sendSchemaToInspector/tests/EventValidator.test.ts | Updates/adds validator tests for regex behavior, unsupported patterns, and ReDoS cases. |
| packages/destination-actions/src/destinations/avo-v2/index.ts | Updates setting description to mention regex validation support. |
| packages/destination-actions/src/destinations/avo-v2/generated-types.ts | Regenerates settings docstring reflecting regex support. |
| RuntimePropertyValue, | ||
| RuntimeProperties | ||
| } from '../types' | ||
| import { RE2 } from 're2-wasm' |
Contributor
There was a problem hiding this comment.
hi @varadarajan-tw - can you take a look at this package to see if it's something we can allow please?
import { RE2 } from 're2-wasm'
Contributor
Author
There was a problem hiding this comment.
Hello @varadarajan-tw, have you had a chance to look at this?
Contributor
Author
There was a problem hiding this comment.
Hey @joe-ayoub-segment @varadarajan-tw, could you please take a look
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.
Summary
re2-wasm) for safe regex evaluation, preventing catastrophic backtracking (ReDoS)rx: "^pattern$") and new object-map format (rx: { "^pattern$": ["evt_1"] })Test plan
rxwire formats🤖 Generated with Claude Code