-
Notifications
You must be signed in to change notification settings - Fork 49
[Project Solar / Phase 1 / Engineering Follow-ups] Add localStorage parsing validation
#3401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds validation for localStorage data to protect against corrupted or malicious input when initializing theming settings. The changes implement type guards to verify that parsed data conforms to expected structures before use, with fallback to default values when validation fails.
Key changes:
- Added
isSafeStoredThemingDatatype guard function to validate theming data structure and values in thehds-themingservice - Added
isSafeStylesheetDatatype guard function to validate stylesheet selection in theshw-themingservice - Refactored
ShwStylesheetstype to derive from a const array for runtime validation
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/components/src/services/hds-theming.ts | Added comprehensive validation for theming data with type guard and fallback to defaults |
| showcase/app/services/shw-theming.ts | Added validation for stylesheet data and refactored type definition to enable runtime checks |
KristinLBradley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic, etc. look good to me.
|
The Percy diff was with the rendering of some |
ab9bd0a to
21aab1f
Compare
21aab1f to
c48a5c5
Compare
02683f7
into
project-solar/phase-1-main-feature-branch
📌 Summary
In a previous review, Copilot suggested to add validation of the
localStorage.getItemresult, to protect against corrupted or malicious data.This PR addresses this issue.
🛠️ Detailed description
In this PR I have:
hdsThemingserviceshwThemingservice🔗 External links
Jira ticket: https://hashicorp.atlassian.net/browse/HDS-5689
👀 Component checklist
💬 Please consider using conventional comments when reviewing this PR.
📋 PCI review checklist
Examples of changes to controls include access controls, encryption, logging, etc.
Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.