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

Make sure body is not a byte string, so data remains serializable #255

Merged
merged 4 commits into from
Nov 6, 2024
Merged
Changes from all 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
6 changes: 6 additions & 0 deletions aikido_zen/sources/django/run_init_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
if len(body) == 0:
# E.g. XML Data
body = request.body
if len(body) == 0:

Check warning on line 21 in aikido_zen/sources/django/run_init_stage.py

View check run for this annotation

Codecov / codecov/patch

aikido_zen/sources/django/run_init_stage.py#L21

Added line #L21 was not covered by tests
# During a GET request, django leaves the body as an empty byte string (e.g. `b''`).
# When an attack is detected, this body needs to be serialized which would fail.
# So a byte string gets converted into a string to stop that from happening.
body = ""

Check warning on line 25 in aikido_zen/sources/django/run_init_stage.py

View check run for this annotation

Codecov / codecov/patch

aikido_zen/sources/django/run_init_stage.py#L25

Added line #L25 was not covered by tests
# Set body to an empty string.

context = None
if hasattr(request, "scope"): # This request is an ASGI request
Expand Down
Loading