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

Add a form to allow panorama uploads to Pano #90

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

Conversation

WillNilges
Copy link
Collaborator

@WillNilges WillNilges commented Oct 7, 2024

Adding a form to allow panorama uploads to pano: https://github.com/willNilges/pano

Comment on lines +61 to +65
src={URL.createObjectURL(
formSubmission.dropzoneImages.find(
(file: File) => file.name === k,
),
)}

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix AI 29 days ago

To fix the problem, we need to ensure that any data used in the DOM is properly sanitized or validated. Specifically, we should:

  1. Validate the file objects in formSubmission.dropzoneImages before using them with URL.createObjectURL.
  2. Ensure that URLs in the possibleDuplicates array are sanitized before being used in the DOM.

We can use a library like DOMPurify to sanitize URLs and ensure that they do not contain any malicious content.

Suggested changeset 2
components/PanoramaDuplicateDialog/PanoramaDuplicateDialog.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/components/PanoramaDuplicateDialog/PanoramaDuplicateDialog.tsx b/components/PanoramaDuplicateDialog/PanoramaDuplicateDialog.tsx
--- a/components/PanoramaDuplicateDialog/PanoramaDuplicateDialog.tsx
+++ b/components/PanoramaDuplicateDialog/PanoramaDuplicateDialog.tsx
@@ -1,2 +1,3 @@
 import * as React from "react";
+import DOMPurify from "dompurify";
 import Button from "@mui/material/Button";
@@ -61,5 +62,5 @@
                           src={URL.createObjectURL(
-                            formSubmission.dropzoneImages.find(
+                            DOMPurify.sanitize(formSubmission.dropzoneImages.find(
                               (file: File) => file.name === k,
-                            ),
+                            )),
                           )}
@@ -96,4 +97,4 @@
                         />
-                        <a href={new URL(v).origin + new URL(v).pathname}>
-                          {new URL(v).origin + new URL(v).pathname}
+                        <a href={DOMPurify.sanitize(new URL(v).origin + new URL(v).pathname)}>
+                          {DOMPurify.sanitize(new URL(v).origin + new URL(v).pathname)}
                         </a>
EOF
@@ -1,2 +1,3 @@
import * as React from "react";
import DOMPurify from "dompurify";
import Button from "@mui/material/Button";
@@ -61,5 +62,5 @@
src={URL.createObjectURL(
formSubmission.dropzoneImages.find(
DOMPurify.sanitize(formSubmission.dropzoneImages.find(
(file: File) => file.name === k,
),
)),
)}
@@ -96,4 +97,4 @@
/>
<a href={new URL(v).origin + new URL(v).pathname}>
{new URL(v).origin + new URL(v).pathname}
<a href={DOMPurify.sanitize(new URL(v).origin + new URL(v).pathname)}>
{DOMPurify.sanitize(new URL(v).origin + new URL(v).pathname)}
</a>
package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -35,3 +35,4 @@
     "typescript": "5.3.3",
-    "zod": "^3.22.4"
+    "zod": "^3.22.4",
+    "dompurify": "^3.1.7"
   },
EOF
@@ -35,3 +35,4 @@
"typescript": "5.3.3",
"zod": "^3.22.4"
"zod": "^3.22.4",
"dompurify": "^3.1.7"
},
This fix introduces these dependencies
Package Version Security advisories
dompurify (npm) 3.1.7 None
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
@WillNilges WillNilges changed the title Wdn/upload Add a form to allow panorama uploads to Pano Oct 17, 2024
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