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

10.0.0-beta1 #971

Open
wants to merge 778 commits into
base: main
Choose a base branch
from
Open

10.0.0-beta1 #971

wants to merge 778 commits into from

Conversation

bcordis
Copy link
Member

@bcordis bcordis commented Dec 2, 2024

First Beta release for public testing.

bcordis and others added 30 commits July 21, 2023 16:40
$.find(targetImage).show()
}

$.find(targetImage).attr('src', activeDir.join('/') + '/' + $(this).val())

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

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

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the value retrieved from $(this).val() is properly sanitized or escaped before being used to set the src attribute of the image element. This can be achieved by using a function that escapes any potentially dangerous characters in the value.

The best way to fix this without changing existing functionality is to use a utility function to escape the value before concatenating it with the rest of the URL. We can use a well-known library like lodash for this purpose, which provides a method _.escape to escape HTML characters.

Suggested changeset 2
media/js/cwmcore.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/media/js/cwmcore.js b/media/js/cwmcore.js
--- a/media/js/cwmcore.js
+++ b/media/js/cwmcore.js
@@ -1 +1,2 @@
+import _ from 'lodash';
 /**
@@ -105,3 +106,3 @@
 
-			$.find(targetImage).attr('src', activeDir.join('/') + '/' + $(this).val())
+			$.find(targetImage).attr('src', activeDir.join('/') + '/' + _.escape($(this).val()))
 			},
EOF
@@ -1 +1,2 @@
import _ from 'lodash';
/**
@@ -105,3 +106,3 @@

$.find(targetImage).attr('src', activeDir.join('/') + '/' + $(this).val())
$.find(targetImage).attr('src', activeDir.join('/') + '/' + _.escape($(this).val()))
},
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
@@ -30,4 +30,3 @@
     "comments": false,
-    "ignore": [
-    ]
+    "ignore": []
   },
@@ -38,3 +37,4 @@
     "@hapi/hoek": "<=9.2.1",
-    "less": "^4.1.2"
+    "less": "^4.1.2",
+    "lodash": "^4.17.21"
   }
EOF
@@ -30,4 +30,3 @@
"comments": false,
"ignore": [
]
"ignore": []
},
@@ -38,3 +37,4 @@
"@hapi/hoek": "<=9.2.1",
"less": "^4.1.2"
"less": "^4.1.2",
"lodash": "^4.17.21"
}
This fix introduces these dependencies
Package Version Security advisories
lodash (npm) 4.17.21 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

if (sE && (url = sE.options[sE.selectedIndex].value))
{
location.href = url

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

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

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the url value is properly validated before it is used to set location.href. This can be done by checking that the url value is a valid and safe URL. We can use a regular expression to validate the URL format or use the URL constructor to ensure it is a valid URL.

The best way to fix the problem without changing existing functionality is to add a validation step before setting location.href. We will use the URL constructor to validate the URL.

Suggested changeset 1
media/js/cwmcore.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/media/js/cwmcore.js b/media/js/cwmcore.js
--- a/media/js/cwmcore.js
+++ b/media/js/cwmcore.js
@@ -204,3 +204,8 @@
 	{
-		location.href = url
+		try {
+			new URL(url);
+			location.href = url;
+		} catch (e) {
+			console.error('Invalid URL:', url);
+		}
 	}
EOF
@@ -204,3 +204,8 @@
{
location.href = url
try {
new URL(url);
location.href = url;
} catch (e) {
console.error('Invalid URL:', url);
}
}
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
const newmp4 = videolink.attr('data-src')
const player = $('#' + videoID)
player.get(0).pause()
player.attr('src', newmp4)

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

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

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the value extracted from the data-src attribute is properly sanitized before being used. One way to achieve this is by using a library like DOMPurify to sanitize the URL. This will help prevent any malicious content from being executed.

  1. Import the DOMPurify library.
  2. Sanitize the newmp4 value before assigning it to the src attribute of the video element.
Suggested changeset 2
media/js/videoswitch.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/media/js/videoswitch.js b/media/js/videoswitch.js
--- a/media/js/videoswitch.js
+++ b/media/js/videoswitch.js
@@ -1 +1,2 @@
+import DOMPurify from 'dompurify';
 (function (window, document, $) {
@@ -7,3 +8,3 @@
 			const videolink = $('#' + contentPanelId)
-			const newmp4 = videolink.attr('data-src')
+			const newmp4 = DOMPurify.sanitize(videolink.attr('data-src'))
 			const player = $('#' + videoID)
EOF
@@ -1 +1,2 @@
import DOMPurify from 'dompurify';
(function (window, document, $) {
@@ -7,3 +8,3 @@
const videolink = $('#' + contentPanelId)
const newmp4 = videolink.attr('data-src')
const newmp4 = DOMPurify.sanitize(videolink.attr('data-src'))
const player = $('#' + videoID)
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
@@ -30,4 +30,3 @@
     "comments": false,
-    "ignore": [
-    ]
+    "ignore": []
   },
@@ -38,3 +37,4 @@
     "@hapi/hoek": "<=9.2.1",
-    "less": "^4.1.2"
+    "less": "^4.1.2",
+    "dompurify": "^3.2.2"
   }
EOF
@@ -30,4 +30,3 @@
"comments": false,
"ignore": [
]
"ignore": []
},
@@ -38,3 +37,4 @@
"@hapi/hoek": "<=9.2.1",
"less": "^4.1.2"
"less": "^4.1.2",
"dompurify": "^3.2.2"
}
This fix introduces these dependencies
Package Version Security advisories
dompurify (npm) 3.2.2 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
Copy link
Member

@tomfuller2 tomfuller2 left a comment

Choose a reason for hiding this comment

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

Approved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants