fix: constrain analytics app field characters on event type writes#28895
fix: constrain analytics app field characters on event type writes#28895pedroccastro wants to merge 3 commits intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis pull request introduces a new utility function 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active. |
|
Hi, sanitizeAnalyticsApps only sanitizes app metadata for slugs in ANALYTICS_APPS; the "booking-pages-tag" analytics app is rendered by BookingPageTagManager with template interpolation and dangerouslySetInnerHTML but is not included, so its template fields can still be stored unsanitized and injected into inline scripts. Severity: action required | Category: security How to fix: Include booking-pages-tag in allowlist Agent prompt to fix - you can give this to your LLM of choice:
We noticed a couple of other issues in this PR as well - happy to share if helpful. Found by Qodo code review. FYI, Qodo is free for open-source. |
|
Hi, sanitizeAnalyticsApps removes common URL query/fragment characters (e.g., '?', '&', '=', '#') from URL-type fields, silently corrupting valid script URLs when metadata is saved. This will break analytics integrations that rely on query parameters or fragments. Severity: action required | Category: correctness How to fix: Use URL-aware sanitization Agent prompt to fix - you can give this to your LLM of choice:
Found by Qodo code review. FYI, Qodo is free for open-source. |
|
This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active. |
|
Hi, sanitizeAnalyticsApps only sanitizes template fields when the stored value is a string, but BookingPageTagManager interpolates any truthy value via String(...). This allows arrays/objects to bypass sanitization and still inject unsafe characters into inline script templates. Severity: action required | Category: security How to fix: Sanitize via string coercion Agent prompt to fix - you can give this to your LLM of choice:
Qodo code review - free for open-source. |
What does this PR do?
Adds a character allowlist for analytics app fields (
trackingId,trackingEvent,SITE_ID, etc.) that are interpolated into inline script templates rendered byBookingPageTagManager. Applied on event type create, update, and duplicate so that stored values consistently match the expected format.Changes
New
packages/app-store/_utils/sanitize-analytics-value.tshelper withsanitizeAnalyticsApps(metadata)— strips any character outside[a-zA-Z0-9\-._/:]from template fields of known analytics apps (ga4,gtm,metapixel,fathom,plausible,posthog,umami,matomo,databuddy,insihts,twipla)Wraps
metadatawithsanitizeAnalyticsAppsin:create.handler.ts,update.handler.ts,duplicate.handler.tsUnit test coverage for valid values, empty strings, null metadata, non-analytics apps, and odd inputs
Context
Analytics app fields are substituted into script templates via
parseValue. This normalizes stored values to the character set the templates expect, avoiding mismatched or ambiguous substitutions across integrations. The allowlist was derived from the shapes of each provider'sscript.contentandzod.ts.How should this be tested?
Manual
Mandatory Tasks