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

Use htmx for old table batch actions #4210

Closed
wants to merge 6 commits into from

Conversation

sandeepsajan0
Copy link
Member

Fixes #ISSUEID

  • Use htmx for batch lead update

Test Steps

form = self.form_class(self.request.POST)
if form.is_valid():
# If a user without archive edit access is somehow able to access batch archive submissions
# (ie. they were looking at the submission list when permissions changed) "refresh" the page

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 redirection is validated to prevent open redirect vulnerabilities. We can use Django's url_has_allowed_host_and_scheme function to check that the URL is safe to redirect to. This function ensures that the URL is either relative or belongs to an allowed host.

We will modify the code to validate self.request.path before using it in the redirection. If the URL is not valid, we will redirect to a safe default URL, such as the home page.

Suggested changeset 1
hypha/apply/funds/views.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/hypha/apply/funds/views.py b/hypha/apply/funds/views.py
--- a/hypha/apply/funds/views.py
+++ b/hypha/apply/funds/views.py
@@ -25,2 +25,3 @@
 from django.shortcuts import get_object_or_404, redirect, render
+from django.utils.http import url_has_allowed_host_and_scheme
 from django.urls import reverse_lazy
@@ -380,3 +381,6 @@
             if not can_alter_archived_submissions(self.request.user):
-                return HttpResponseRedirect(self.request.path)
+                if url_has_allowed_host_and_scheme(self.request.path, allowed_hosts=None):
+                    return HttpResponseRedirect(self.request.path)
+                else:
+                    return redirect('/')
             submissions = form.cleaned_data["submissions"]
EOF
@@ -25,2 +25,3 @@
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.http import url_has_allowed_host_and_scheme
from django.urls import reverse_lazy
@@ -380,3 +381,6 @@
if not can_alter_archived_submissions(self.request.user):
return HttpResponseRedirect(self.request.path)
if url_has_allowed_host_and_scheme(self.request.path, allowed_hosts=None):
return HttpResponseRedirect(self.request.path)
else:
return redirect('/')
submissions = form.cleaned_data["submissions"]
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
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
@sandeepsajan0 sandeepsajan0 requested review from frjo and theskumar and removed request for frjo November 14, 2024 09:04
@sandeepsajan0
Copy link
Member Author

Closing this in favor of #4226

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