feat: [ENG-36536] tokens ts and new architecture#75
feat: [ENG-36536] tokens ts and new architecture#75cesaroeduardo wants to merge 3 commits intomainfrom
Conversation
| deepMerge(target[key], value); | ||
| return; | ||
| } | ||
| target[key] = value; |
Check warning
Code scanning / CodeQL
Prototype-polluting function Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 8 days ago
In general, to fix prototype pollution in deep-merge / deep-assignment helpers, you must prevent writes to dangerous keys (__proto__, constructor, prototype) and/or ensure that you only recurse into properties that are own properties of the destination object, not arbitrary prototype chains. The simplest and least intrusive fix here is to filter out dangerous keys before assigning them to target.
For this specific deepMerge in scripts/figma-sync.js, the best fix without changing existing functionality is to add an early-continue guard inside the Object.entries(source).forEach loop that skips any key that could lead to prototype pollution. That means checking key and ignoring "__proto__", "constructor", and "prototype" before we touch target[key]. This preserves all existing behavior for normal keys, avoids changing call sites, and doesn’t require new imports or external libraries. The changes are localized to the deepMerge function (lines 52–65).
Concretely:
-
Inside the
forEach(([key, value]) => { ... })callback, right after we obtainkeyandvalue, add:if (key === '__proto__' || key === 'constructor' || key === 'prototype') { return; }
-
Leave the rest of the logic intact so that merging semantics for safe keys are unchanged.
No new methods or imports are required.
| @@ -52,6 +52,10 @@ | ||
| const deepMerge = (target, source) => { | ||
| if (!source || typeof source !== 'object') return target; | ||
| Object.entries(source).forEach(([key, value]) => { | ||
| // Guard against prototype pollution by blocking dangerous keys. | ||
| if (key === '__proto__' || key === 'constructor' || key === 'prototype') { | ||
| return; | ||
| } | ||
| if (value && typeof value === 'object' && !Array.isArray(value)) { | ||
| if (!target[key] || typeof target[key] !== 'object') { | ||
| target[key] = {}; |
There was a problem hiding this comment.
@cesaroeduardo faz sentido o que o github apontou?
Jira: https://aziontech.atlassian.net/browse/ENG-36536
Summary
Problems & Solutions
Solution: Created new tokens following a market standard proposal, introducing brand (white-label) tokens and a clearer primitives/semantic separation.
Solution: Shifted semantics to be fully oriented for Tailwind usage, providing a predictable, standardized way to consume tokens.
Solution: Added consumption fixes to keep consumers stable while migrating to the new structure.
Changes Made
Testing Checklist