Skip to content
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

chore: strongly typed forms #592

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

garethgeorge
Copy link
Owner

No description provided.

curr = curr[parts[i]];
}
}
curr[parts[parts.length - 1]] = value;

Check warning

Code scanning / CodeQL

Prototype-polluting function Medium

The property chain
here
is recursively assigned to
curr
without guarding against prototype pollution.

Copilot Autofix AI about 1 month ago

To fix the problem, we need to ensure that the path parameter does not contain dangerous keys like __proto__ or constructor. We can achieve this by adding a check to block these keys before proceeding with the assignment. This will prevent prototype pollution while maintaining the existing functionality.

Suggested changeset 1
webui/src/components/form/TypedForm.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/webui/src/components/form/TypedForm.tsx b/webui/src/components/form/TypedForm.tsx
--- a/webui/src/components/form/TypedForm.tsx
+++ b/webui/src/components/form/TypedForm.tsx
@@ -45,2 +45,5 @@
   for (let i = 0; i < parts.length - 1; i++) {
+    if (parts[i] === "__proto__" || parts[i] === "constructor") {
+      return;
+    }
     if (Array.isArray(curr)) {
@@ -51,3 +54,5 @@
   }
-  curr[parts[parts.length - 1]] = value;
+  if (parts[parts.length - 1] !== "__proto__" && parts[parts.length - 1] !== "constructor") {
+    curr[parts[parts.length - 1]] = value;
+  }
 };
EOF
@@ -45,2 +45,5 @@
for (let i = 0; i < parts.length - 1; i++) {
if (parts[i] === "__proto__" || parts[i] === "constructor") {
return;
}
if (Array.isArray(curr)) {
@@ -51,3 +54,5 @@
}
curr[parts[parts.length - 1]] = value;
if (parts[parts.length - 1] !== "__proto__" && parts[parts.length - 1] !== "constructor") {
curr[parts[parts.length - 1]] = value;
}
};
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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.

1 participant