Skip to content

dbeaver/pro#5802 feat: table api #3487

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

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

Wroud
Copy link
Member

@Wroud Wroud commented May 29, 2025

closes dbeaver/pro#5802

@Wroud Wroud self-assigned this May 29, 2025
};
this._history.push(historyEntry);

row[position.colIdx] = value;

Check warning

Code scanning / CodeQL

Prototype-polluting assignment Medium

This assignment may alter Object.prototype if a malicious '__proto__' string is injected from
library input
.

Copilot Autofix

AI about 2 months ago

To fix the issue, we need to ensure that the position parameter cannot introduce prototype pollution. This can be achieved by explicitly validating that position.rowIdx and position.colIdx are numeric indices and do not contain dangerous keys like __proto__, constructor, or prototype.

The best approach is to enhance the isValidPosition method (if it exists) or add explicit checks in the setCellValue method to reject invalid or dangerous keys. This ensures that the _data array is only accessed with safe indices.


Suggested changeset 1
common-typescript/@dbeaver/table-data/src/editor/TableEditor.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/common-typescript/@dbeaver/table-data/src/editor/TableEditor.ts b/common-typescript/@dbeaver/table-data/src/editor/TableEditor.ts
--- a/common-typescript/@dbeaver/table-data/src/editor/TableEditor.ts
+++ b/common-typescript/@dbeaver/table-data/src/editor/TableEditor.ts
@@ -43,4 +43,10 @@
   setCellValue(position: ICellPosition, value: TValue): void {
-    if (!this.isValidPosition(position)) {
-      throw new Error(`Invalid cell position: row ${position.rowIdx}, column ${position.colIdx}`);
+    if (
+      !this.isValidPosition(position) ||
+      typeof position.rowIdx !== 'number' ||
+      typeof position.colIdx !== 'number' ||
+      ['__proto__', 'constructor', 'prototype'].includes(String(position.rowIdx)) ||
+      ['__proto__', 'constructor', 'prototype'].includes(String(position.colIdx))
+    ) {
+      throw new Error(`Invalid or unsafe cell position: row ${position.rowIdx}, column ${position.colIdx}`);
     }
EOF
@@ -43,4 +43,10 @@
setCellValue(position: ICellPosition, value: TValue): void {
if (!this.isValidPosition(position)) {
throw new Error(`Invalid cell position: row ${position.rowIdx}, column ${position.colIdx}`);
if (
!this.isValidPosition(position) ||
typeof position.rowIdx !== 'number' ||
typeof position.colIdx !== 'number' ||
['__proto__', 'constructor', 'prototype'].includes(String(position.rowIdx)) ||
['__proto__', 'constructor', 'prototype'].includes(String(position.colIdx))
) {
throw new Error(`Invalid or unsafe cell position: row ${position.rowIdx}, column ${position.colIdx}`);
}
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link
Contributor

@SychevAndrey SychevAndrey left a comment

Choose a reason for hiding this comment

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

👍🏻
I like Mutex!
I'm not sure about nanoevents. We have built-in EventTarget, why to add something?
We definitely need to decide how we gonna write private methods/props, using private _method or #method.

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