-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Traceability matrix preparation #10286
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
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
|
Connected to Huly®: UBERF-14401 |
| part = part.slice(0, -1) | ||
| } | ||
| if (curr[part] === undefined) { | ||
| curr[part] = {} |
Check warning
Code scanning / CodeQL
Prototype-polluting assignment Medium
library input
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
The best way to fix this issue is to prevent malicious keys such as "__proto__", "constructor", and "prototype" from ever being used as object property names in the intermediate data structure. This can be achieved by adding a check before assignment for each property name, skipping or rejecting any that could be used for prototype pollution. A robust implementation should use a helper function to perform this check and only allow safe keys.
Specifically:
- Edit the method
buildaAssociationinplugins/view-resources/src/utils.tsto prevent property assignment ifpartequals"__proto__","constructor", or"prototype"(or other dangerous keys). - The check should be applied on every iteration in the
for ... of partsloop, wherecurr[part]is being accessed and assigned. - Optionally, you can define a small utility function or a set in the file to keep this logic clean.
- You do not need to change the data structure to a Map—the risk is managed as long as dangerous keys cannot enter as properties.
- Only modify the code in the region shown; do not change other logic.
-
Copy modified lines R521-R526 -
Copy modified line R534 -
Copy modified line R538
| @@ -518,6 +518,12 @@ | ||
| return convertAssociationsRecord(record) | ||
| } | ||
|
|
||
| // Prevent prototype pollution by skipping dangerous property names | ||
| const dangerousKeys = new Set(['__proto__', 'constructor', 'prototype']); | ||
| function isSafeKey(key: string): boolean { | ||
| return !dangerousKeys.has(key); | ||
| } | ||
|
|
||
| function buildaAssociation (stringKey: string, record: Record<string, any>): void { | ||
| const parts = stringKey.split('$associations.').filter((it) => it.length > 0) | ||
| let curr = record | ||
| @@ -525,10 +531,11 @@ | ||
| if (part.endsWith('.')) { | ||
| part = part.slice(0, -1) | ||
| } | ||
| if (!isSafeKey(part)) continue; | ||
| if (curr[part] === undefined) { | ||
| curr[part] = {} | ||
| } | ||
| curr = record[part] | ||
| curr = curr[part] | ||
| } | ||
| } | ||
|
|
No description provided.