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

handling sensitive_post_parameters decorator in django #413

Merged
merged 7 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ jobs:
# certifi dropped support for Python 2 in 2020.4.5.2 but only started
# using Python 3 syntax in 2022.5.18. 2021.10.8 is the last release with
# Python 2 support.
run: pip install certifi==2021.10.8
run: pip install certifi==2021.10.8 requests==2.27.1

- name: Install Python 3.4 dependencies
if: ${{ contains(matrix.python-version, '3.4') }}
Expand Down
14 changes: 14 additions & 0 deletions rollbar/contrib/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,13 @@ def process_response(self, request, response):
def process_exception(self, request, exc):
if isinstance(exc, Http404) and _should_ignore_404(request.get_full_path()):
return
if request.sensitive_post_parameters:
pawelsz-rb marked this conversation as resolved.
Show resolved Hide resolved
post_request = request.POST.copy()
for param in request.sensitive_post_parameters:
if param in post_request:
post_request[param] = "******"
request.POST = post_request

rollbar.report_exc_info(
sys.exc_info(),
request,
Expand Down Expand Up @@ -305,6 +312,13 @@ def process_response(self, request, response):
else:
raise Http404()
except Exception as exc:
if request.sensitive_post_parameters:
post_request = request.POST.copy()
for param in request.sensitive_post_parameters:
if param in post_request:
post_request[param] = "******"
request.POST = post_request

rollbar.report_exc_info(
sys.exc_info(),
request,
Expand Down