Skip to content

Commit

Permalink
Merge pull request #437 from rollbar/fixed/issue-436-django-sensitive…
Browse files Browse the repository at this point in the history
…-post-params

Fixed #436 `WSGIRequest` has no attribute `sensitive_post_parameters`.
  • Loading branch information
danielmorell authored Sep 15, 2023
2 parents 9fe5f8e + a4aecae commit 781da55
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rollbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from rollbar.lib import events, filters, dict_merge, transport, defaultJSONEncode


__version__ = '1.0.0b0'
__version__ = '1.0.0b1'
__log_name__ = 'rollbar'
log = logging.getLogger(__log_name__)

Expand Down
24 changes: 17 additions & 7 deletions rollbar/contrib/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,23 @@ def _should_ignore_404(url):
return any(p.search(url) for p in url_patterns)

def _apply_sensitive_post_params(request):
if request.sensitive_post_parameters:
mutable = request.POST._mutable
request.POST._mutable = True
for param in request.sensitive_post_parameters:
if param in request.POST:
request.POST[param] = "******"
request.POST._mutable = mutable
sensitive_post_parameters = getattr(
request, "sensitive_post_parameters", []
)
if not sensitive_post_parameters:
return
mutable = request.POST._mutable
request.POST._mutable = True

if sensitive_post_parameters == "__ALL__":
for param in request.POST:
request.POST[param] = "******"
return

for param in sensitive_post_parameters:
if param in request.POST:
request.POST[param] = "******"
request.POST._mutable = mutable

class RollbarNotifierMiddleware(MiddlewareMixin):
def __init__(self, get_response=None):
Expand Down

0 comments on commit 781da55

Please sign in to comment.