Skip to content

Comments

Core Integration | Initial#1

Merged
TreyWW merged 15 commits intomainfrom
initial
Dec 28, 2024
Merged

Core Integration | Initial#1
TreyWW merged 15 commits intomainfrom
initial

Conversation

@TreyWW
Copy link
Contributor

@TreyWW TreyWW commented Dec 25, 2024

Moved to "core" namespace

Fixed team dropdown style issues

Fixed migration signals, converted core:dashboard to just dashboard

Added github actions + templates

Moved to "core" namespace

Fixed team dropdown style issues

Fixed migration signals, converted core:dashboard to just dashboard

Added github actions + templates
@github-actions
Copy link

github-actions bot commented Dec 25, 2024

Dependency Review

The following issues were found:

  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 19 package(s) with unknown licenses.
  • ⚠️ 10 packages with OpenSSF Scorecard issues.

View full job summary

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

def redirect_to_login(email: str, redirect_url: str):
if not url_has_allowed_host_and_scheme(redirect_url, allowed_hosts=None):
redirect_url = reverse("dashboard")
return redirect(f"{reverse('core:auth:login')}?email={email}&next={redirect_url}")

Check warning

Code scanning / CodeQL

URL redirection from remote source Medium

Untrusted URL redirection depends on a
user-provided value
.

Copilot Autofix

AI about 1 year ago

To fix the problem, we need to ensure that the redirect_url is validated against a whitelist of allowed URLs or ensure that it does not contain an explicit host name. This can be done by using the urlparse function to parse the URL and check that the netloc attribute is empty. Additionally, we should handle backslashes and mistyped URLs to ensure they are correctly parsed.

  1. Import the urlparse function from the urllib.parse module.
  2. Replace the current validation logic with a more robust check using urlparse.
  3. Ensure that the redirect_url does not contain an explicit host name and is a relative path.
Suggested changeset 1
src/core/views/auth/login.py

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/core/views/auth/login.py b/src/core/views/auth/login.py
--- a/src/core/views/auth/login.py
+++ b/src/core/views/auth/login.py
@@ -18,2 +18,3 @@
 from django_ratelimit.decorators import ratelimit
+from urllib.parse import urlparse
 
@@ -80,3 +81,5 @@
 
-    if url_has_allowed_host_and_scheme(redirect_url, allowed_hosts=None):
+    redirect_url = redirect_url.replace('\\', '')
+    parsed_url = urlparse(redirect_url)
+    if not parsed_url.netloc and not parsed_url.scheme:
         try:
@@ -91,3 +94,5 @@
 def redirect_to_login(email: str, redirect_url: str):
-    if not url_has_allowed_host_and_scheme(redirect_url, allowed_hosts=None):
+    redirect_url = redirect_url.replace('\\', '')
+    parsed_url = urlparse(redirect_url)
+    if parsed_url.netloc or parsed_url.scheme:
         redirect_url = reverse("dashboard")
EOF
@@ -18,2 +18,3 @@
from django_ratelimit.decorators import ratelimit
from urllib.parse import urlparse

@@ -80,3 +81,5 @@

if url_has_allowed_host_and_scheme(redirect_url, allowed_hosts=None):
redirect_url = redirect_url.replace('\\', '')
parsed_url = urlparse(redirect_url)
if not parsed_url.netloc and not parsed_url.scheme:
try:
@@ -91,3 +94,5 @@
def redirect_to_login(email: str, redirect_url: str):
if not url_has_allowed_host_and_scheme(redirect_url, allowed_hosts=None):
redirect_url = redirect_url.replace('\\', '')
parsed_url = urlparse(redirect_url)
if parsed_url.netloc or parsed_url.scheme:
redirect_url = reverse("dashboard")
Copilot is powered by AI and may make mistakes. Always verify output.
Signed-off-by: Trey <73353716+TreyWW@users.noreply.github.com>
Signed-off-by: Trey <73353716+TreyWW@users.noreply.github.com>
Signed-off-by: Trey <73353716+TreyWW@users.noreply.github.com>
Signed-off-by: Trey <73353716+TreyWW@users.noreply.github.com>
@TreyWW TreyWW marked this pull request as ready for review December 28, 2024 16:17
Signed-off-by: Trey <73353716+TreyWW@users.noreply.github.com>
Signed-off-by: Trey <73353716+TreyWW@users.noreply.github.com>
Signed-off-by: Trey <73353716+TreyWW@users.noreply.github.com>
@TreyWW TreyWW merged commit 8759ae9 into main Dec 28, 2024
5 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.

1 participant