Skip to content

refactor(frontend): sanitize to support tool-specific profile types#548

Open
DarianM wants to merge 3 commits intomainfrom
profile_sanitize_server
Open

refactor(frontend): sanitize to support tool-specific profile types#548
DarianM wants to merge 3 commits intomainfrom
profile_sanitize_server

Conversation

@DarianM
Copy link
Member

@DarianM DarianM commented Feb 5, 2026

Part of #511

Context

Part of the ongoing effort to deprecate ElementConfigType in favor of typed tool profiles

Base automatically changed from remove-banner-two to main February 5, 2026 10:00
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

Deployment results

Worker Alias URL Outcome
API - staging success
CDN - staging success
App - 6b74f1e4 success

Logs #21729990104

@DarianM DarianM force-pushed the profile_sanitize_server branch from 622fa85 to 00738aa Compare February 5, 2026 10:16
@DarianM DarianM requested a review from sidvishnoi February 5, 2026 10:18
Comment on lines 48 to 60
return {
...convertToConfigLegacy('', widget),
versionName: sanitizeText(widget.$name, 'versionName'),
widgetTitleText: sanitizeText(widget.widgetTitleText, 'widgetTitleText'),
widgetDescriptionText: sanitizeHtmlField(
widget.widgetDescriptionText,
'widgetDescriptionText',
),
widgetButtonText: sanitizeText(
widget.widgetButtonText,
'widgetButtonText',
),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not sanitize all fields? A malicious user can inject HTML to any other field as well, and in future, if we use it with incorrect assumption that it's clean, it can bite us.

Copy link
Member Author

@DarianM DarianM Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because zod validations should fail before reaching this point if malicious input is sent. we sanitize fields that pass the simple z.string() check with zod. so, in this PR strengthened zod validation for hex colors, $version, versionName and added some unit tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if too much, i can extract the extra zod validations in different PR, and unit tests definitely can be improved, but don't want to switch focus too much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants