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

Patch 6 #1

Merged
merged 8 commits into from
Nov 18, 2024
Merged

Patch 6 #1

merged 8 commits into from
Nov 18, 2024

Conversation

tsu-ki
Copy link
Owner

@tsu-ki tsu-ki commented Nov 18, 2024

No description provided.

tsu-ki and others added 8 commits November 15, 2024 21:34
Build a markdown badge which shows increment in the daily repository visit count from IP, corresponding to each day of the week visualised in the form of bar graph. A total count will be shown at the top-most right corner
Scaled up the Edit Profile form to maintain consistent UI throughout the website.
OWASP-BLT#2937
@@ -277,7 +298,7 @@
user_issues.update(is_hidden=hide)
request.user.userprofile.issues_hidden = hide
request.user.userprofile.save()
return redirect(reverse("profile", kwargs={"slug": kwargs.get("slug")}))
return redirect(self.request.path_info)

Check warning

Code scanning / CodeQL

URL redirection from remote source Medium

Untrusted URL redirection depends on a
user-provided value
.

Copilot Autofix AI 4 months ago

To fix the problem, we need to ensure that the URL used in the redirect is safe. We can use Django's url_has_allowed_host_and_scheme function to validate the URL. This function checks that the URL is safe to redirect to by ensuring it does not include an explicit host name and is within the allowed hosts.

  • Import the url_has_allowed_host_and_scheme function from django.utils.http.
  • Validate self.request.path_info before using it in the redirect.
  • If the URL is not valid, redirect to a safe default URL (e.g., the home page).
Suggested changeset 1
website/views/user.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/website/views/user.py b/website/views/user.py
--- a/website/views/user.py
+++ b/website/views/user.py
@@ -30,2 +30,3 @@
 from django.utils.decorators import method_decorator
+from django.utils.http import url_has_allowed_host_and_scheme
 from django.views.generic import DetailView, ListView, TemplateView, View
@@ -300,3 +301,6 @@
             request.user.userprofile.save()
-        return redirect(self.request.path_info)
+        if url_has_allowed_host_and_scheme(self.request.path_info, allowed_hosts=None):
+            return redirect(self.request.path_info)
+        else:
+            return redirect('/')
 
EOF
@@ -30,2 +30,3 @@
from django.utils.decorators import method_decorator
from django.utils.http import url_has_allowed_host_and_scheme
from django.views.generic import DetailView, ListView, TemplateView, View
@@ -300,3 +301,6 @@
request.user.userprofile.save()
return redirect(self.request.path_info)
if url_has_allowed_host_and_scheme(self.request.path_info, allowed_hosts=None):
return redirect(self.request.path_info)
else:
return redirect('/')

Copilot is powered by AI and may make mistakes. Always verify output.
@tsu-ki tsu-ki merged commit 31d5f08 into gsoc-updated-page Nov 18, 2024
12 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