Skip to content

Commit

Permalink
Merge branch '2.16' into backport-11652-to-2.16
Browse files Browse the repository at this point in the history
  • Loading branch information
sabrenner authored Dec 13, 2024
2 parents c336797 + 095f958 commit a454a0e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ddtrace/appsec/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from ddtrace.appsec._constants import API_SECURITY
from ddtrace.appsec._constants import APPSEC
from ddtrace.internal._unpatched import unpatched_json_loads
from ddtrace.internal.compat import to_unicode
from ddtrace.internal.logger import get_logger
from ddtrace.internal.utils.http import _get_blocked_template # noqa:F401
Expand All @@ -17,8 +18,6 @@


def parse_response_body(raw_body):
import json

import xmltodict

from ddtrace.appsec import _asm_request_context
Expand Down Expand Up @@ -54,7 +53,7 @@ def access_body(bd):
try:
# TODO handle charset
if "json" in content_type:
req_body = json.loads(access_body(raw_body))
req_body = unpatched_json_loads(access_body(raw_body))
elif "xml" in content_type:
req_body = xmltodict.parse(access_body(raw_body))
else:
Expand Down
1 change: 1 addition & 0 deletions ddtrace/internal/_unpatched.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Acquire a reference to the open function from the builtins module. This is
# necessary to ensure that the open function can be used unpatched when required.
from builtins import open as unpatched_open # noqa
from json import loads as unpatched_json_loads # noqa

# Acquire a reference to the threading module. Some parts of the library (e.g.
# the profiler) might be enabled programmatically and therefore might end up
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
ASM: This fix resolves an issue where AppSec was using a patched JSON loads, creating telemetry errors.

0 comments on commit a454a0e

Please sign in to comment.