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

Ramadan Release #2330

Merged
merged 160 commits into from
Feb 28, 2025
Merged

Ramadan Release #2330

merged 160 commits into from
Feb 28, 2025

Conversation

osamasayed
Copy link
Member

No description provided.

AhmedCodeGuy and others added 30 commits October 17, 2024 18:30
* QF-984 add support for multiple authors per learning plan

* QF-985 Add multiple learning plan editors (#2218)
* Add the ability to embed iframes in markdown

* Fix TS issue

* Fix TS issue

* Fix TS issue

* Fix TS issue
* introduced proxy to backend with redirect to auth

* feat: introduced signature generation for interecting with api gateway

* fix: added documentation and resolved some changes requested

* adds documentation

* fix: added comment to explain the purpose of [...path] file

* Fix linting issues

* fix: added support for content and auth service through API gateway

* fix: resolve build issue for static props building

* fix: fixed env var name

---------

Co-authored-by: Osama Sayed <[email protected]>
return getFormErrors(t, ErrorType.API, errors);
}

router.push(redirect || '/');

Check failure

Code scanning / CodeQL

Client-side cross-site scripting High

Cross-site scripting vulnerability due to
user-provided value
.

Copilot Autofix AI about 10 hours ago

To fix the problem, we need to ensure that the redirect parameter is properly sanitized before being used in the router.push function. The best way to do this is to use a library that provides URL validation and sanitization functions. One such library is validator, which offers a isURL function to validate URLs.

We will:

  1. Import the validator library.
  2. Use the isURL function to validate the redirect parameter.
  3. If the redirect parameter is not a valid URL, we will default to the root URL ('/').
Suggested changeset 2
src/components/Login/SignInForm.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/src/components/Login/SignInForm.tsx b/src/components/Login/SignInForm.tsx
--- a/src/components/Login/SignInForm.tsx
+++ b/src/components/Login/SignInForm.tsx
@@ -4,2 +4,3 @@
 import useTranslation from 'next-translate/useTranslation';
+import validator from 'validator';
 
@@ -62,3 +63,4 @@
 
-      router.push(redirect || '/');
+      const safeRedirect = redirect && validator.isURL(redirect) ? redirect : '/';
+      router.push(safeRedirect);
       return undefined;
@@ -102,3 +104 @@
 };
-
-export default SignInForm;
EOF
@@ -4,2 +4,3 @@
import useTranslation from 'next-translate/useTranslation';
import validator from 'validator';

@@ -62,3 +63,4 @@

router.push(redirect || '/');
const safeRedirect = redirect && validator.isURL(redirect) ? redirect : '/';
router.push(safeRedirect);
return undefined;
@@ -102,3 +104 @@
};

export default SignInForm;
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
@@ -115,3 +115,4 @@
     "swr": "1.2.1",
-    "xstate": "^4.33.6"
+    "xstate": "^4.33.6",
+    "validator": "^13.12.0"
   },
EOF
@@ -115,3 +115,4 @@
"swr": "1.2.1",
"xstate": "^4.33.6"
"xstate": "^4.33.6",
"validator": "^13.12.0"
},
This fix introduces these dependencies
Package Version Security advisories
validator (npm) 13.12.0 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
return getFormErrors(t, ErrorType.API, errors);
}

router.push(redirect || '/');

Check warning

Code scanning / CodeQL

Client-side URL redirect Medium

Untrusted URL redirection depends on a
user-provided value
.

Copilot Autofix AI about 10 hours ago

To fix the problem, we need to ensure that the redirect parameter is validated against a list of authorized URLs before performing the redirection. This can be achieved by maintaining a list of allowed redirect URLs and checking if the redirect parameter matches any of these URLs before calling router.push.

  1. Create a list of authorized redirect URLs.
  2. Validate the redirect parameter against this list.
  3. Only perform the redirection if the redirect parameter is in the list of authorized URLs; otherwise, redirect to a default safe URL.
Suggested changeset 1
src/components/Login/SignInForm.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/src/components/Login/SignInForm.tsx b/src/components/Login/SignInForm.tsx
--- a/src/components/Login/SignInForm.tsx
+++ b/src/components/Login/SignInForm.tsx
@@ -62,3 +62,5 @@
 
-      router.push(redirect || '/');
+      const authorizedRedirects = ['/', '/dashboard', '/profile']; // Add authorized URLs here
+      const safeRedirect = authorizedRedirects.includes(redirect) ? redirect : '/';
+      router.push(safeRedirect);
       return undefined;
EOF
@@ -62,3 +62,5 @@

router.push(redirect || '/');
const authorizedRedirects = ['/', '/dashboard', '/profile']; // Add authorized URLs here
const safeRedirect = authorizedRedirects.includes(redirect) ? redirect : '/';
router.push(safeRedirect);
return undefined;
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
@osamasayed osamasayed marked this pull request as ready for review February 28, 2025 08:45
@osamasayed osamasayed merged commit 6e43c8a into production Feb 28, 2025
3 of 4 checks passed
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.

3 participants