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

Initial implementation of azure blob container interface #1853

Merged
merged 39 commits into from
Nov 12, 2024

Conversation

jrtcppv
Copy link
Member

@jrtcppv jrtcppv commented Oct 19, 2024

No description provided.

@@ -49,10 +49,17 @@

// Uploads using a single request.
uploadSingle(info) {
let headers = {};
if (info.urls[0].includes("blob.core.windows.net")) {

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High

'
blob.core.windows.net
' can be anywhere in the URL, and arbitrary hosts may come before or after it.

Copilot Autofix AI 22 days ago

To fix the problem, we need to parse the URL and check the host explicitly rather than using a substring check. This ensures that the host is exactly what we expect and not just a part of a longer, potentially malicious URL.

The best way to fix this is to use the URL class available in modern JavaScript environments to parse the URL and then check the hostname property. We will replace the substring check with a check against a whitelist of allowed hosts.

Suggested changeset 1
ui/src/js/components/inputs/feature/single-upload.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/ui/src/js/components/inputs/feature/single-upload.js b/ui/src/js/components/inputs/feature/single-upload.js
--- a/ui/src/js/components/inputs/feature/single-upload.js
+++ b/ui/src/js/components/inputs/feature/single-upload.js
@@ -52,3 +52,5 @@
     let headers = {};
-    if (info.urls[0].includes("blob.core.windows.net")) {
+    const url = new URL(info.urls[0]);
+    const allowedHosts = ["blob.core.windows.net"];
+    if (allowedHosts.includes(url.hostname)) {
       headers = {
EOF
@@ -52,3 +52,5 @@
let headers = {};
if (info.urls[0].includes("blob.core.windows.net")) {
const url = new URL(info.urls[0]);
const allowedHosts = ["blob.core.windows.net"];
if (allowedHosts.includes(url.hostname)) {
headers = {
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
@jrtcppv jrtcppv closed this Nov 12, 2024
@jrtcppv jrtcppv merged commit 575ad2f into main Nov 12, 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.

2 participants