-
Couldn't load subscription status.
- Fork 148
WIP - insert many with generated embeddings #688
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
base: main
Are you sure you want to change the base?
Conversation
9326ed4 to
3bf73da
Compare
|
|
||
| const lastPart = parts[parts.length - 1]; | ||
| if (lastPart) { | ||
| current[lastPart] = value; |
Check warning
Code scanning / CodeQL
Prototype-polluting function Medium
here
current
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 21 hours ago
To fix this vulnerability, we need to prevent untrusted property chains from traversing or assigning to dangerous property names such as "__proto__", "constructor", and "prototype". The single best way to accomplish this without affecting existing functionality is to skip any assignment where any element in the parts array matches these restricted names. Modify the loop in setFieldValue so that it continues (i.e., skips) upon encountering such property names in the chain, both when traversing intermediate objects and at the final assignment. This is a minimal, targeted fix. All changes occur in the setFieldValue method of InsertManyTool in src/tools/mongodb/create/insertMany.ts. No external libraries required.
-
Copy modified line R214 -
Copy modified line R217 -
Copy modified line R225
| @@ -211,10 +211,10 @@ | ||
| private setFieldValue(document: Document, path: string, value: unknown): void { | ||
| const parts = path.split("."); | ||
| let current: Record<string, unknown> = document; | ||
|
|
||
| const dangerousProperties = ["__proto__", "constructor", "prototype"]; | ||
| for (let i = 0; i < parts.length - 1; i++) { | ||
| const part = parts[i]; | ||
| if (!part) { | ||
| if (!part || dangerousProperties.includes(part)) { | ||
| continue; | ||
| } | ||
| if (!(part in current) || typeof current[part] !== "object") { | ||
| @@ -224,7 +222,7 @@ | ||
| } | ||
|
|
||
| const lastPart = parts[parts.length - 1]; | ||
| if (lastPart) { | ||
| if (lastPart && !dangerousProperties.includes(lastPart)) { | ||
| current[lastPart] = value; | ||
| } | ||
| } |
Do not review.
This is still very WIP and not ready for review, just running accuracy tests.