Skip to content

Commit

Permalink
Add comments explaining why we check if the body is bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Wout Feys committed Nov 6, 2024
1 parent d393afd commit 47ac147
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aikido_zen/sources/django/run_init_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def run_init_stage(request):
# E.g. XML Data
body = request.body
if isinstance(body, bytes):

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 = str(body, "utf-8")

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

context = None
Expand Down

0 comments on commit 47ac147

Please sign in to comment.