Skip to content

Commit dcaec5a

Browse files
authored
Merge branch 'main' into yunkim/llmobs-evals-assessment
2 parents d16c9a8 + 23fe9e1 commit dcaec5a

20 files changed

+64
-20
lines changed

.gitlab/benchmarks/bp-runner.microbenchmarks.fail-on-breach.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ experiments:
10671067
- max_rss_usage < 34.00 MB
10681068
- name: span-start-finish-traceid128
10691069
thresholds:
1070-
- execution_time < 56.00 ms
1070+
- execution_time < 57.00 ms
10711071
- max_rss_usage < 34.00 MB
10721072
- name: span-start-traceid128
10731073
thresholds:

ddtrace/__init__.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
import os
2+
import sys
33

44

55
LOADED_MODULES = frozenset(sys.modules.keys())
@@ -12,20 +12,18 @@
1212
# configure ddtrace logger before other modules log
1313
configure_ddtrace_logger() # noqa: E402
1414

15-
from .settings._config import config
16-
17-
1815
# Enable telemetry writer and excepthook as early as possible to ensure we capture any exceptions from initialization
1916
import ddtrace.internal.telemetry # noqa: E402
17+
from ddtrace.vendor import debtcollector
2018

2119
from ._monkey import patch # noqa: E402
2220
from ._monkey import patch_all # noqa: E402
2321
from .internal.compat import PYTHON_VERSION_INFO # noqa: E402
2422
from .internal.utils.deprecations import DDTraceDeprecationWarning # noqa: E402
25-
26-
from ddtrace.vendor import debtcollector
23+
from .settings._config import config
2724
from .version import get_version # noqa: E402
2825

26+
2927
__version__ = get_version()
3028

3129
# TODO: Deprecate accessing tracer from ddtrace.__init__ module in v4.0
@@ -41,12 +39,12 @@
4139

4240

4341
def check_supported_python_version():
44-
if PYTHON_VERSION_INFO < (3, 8):
42+
if PYTHON_VERSION_INFO < (3, 9):
4543
deprecation_message = (
46-
"Support for ddtrace with Python version %d.%d is deprecated and will be removed in 3.0.0."
44+
"Support for ddtrace with Python version %d.%d is deprecated and will be removed in 4.0.0."
4745
)
48-
if PYTHON_VERSION_INFO < (3, 7):
49-
deprecation_message = "Support for ddtrace with Python version %d.%d was removed in 2.0.0."
46+
if PYTHON_VERSION_INFO < (3, 8):
47+
deprecation_message = "Support for ddtrace with Python version %d.%d was removed in 3.0.0."
5048
debtcollector.deprecate(
5149
(deprecation_message % (PYTHON_VERSION_INFO[0], PYTHON_VERSION_INFO[1])),
5250
category=DDTraceDeprecationWarning,

ddtrace/appsec/_ddwaf/ddwaf_types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from collections.abc import Mapping
2+
from collections.abc import Sequence
13
import ctypes
24
import ctypes.util
35
from enum import IntEnum
@@ -128,7 +130,7 @@ def truncate_string(string: bytes) -> bytes:
128130
ddwaf_object_string(self, truncate_string(struct))
129131
elif isinstance(struct, float):
130132
ddwaf_object_float(self, struct)
131-
elif isinstance(struct, list):
133+
elif isinstance(struct, Sequence):
132134
if max_depth <= 0:
133135
observator.set_container_depth(DDWAF_MAX_CONTAINER_DEPTH)
134136
max_objects = 0
@@ -145,7 +147,7 @@ def truncate_string(string: bytes) -> bytes:
145147
max_string_length=max_string_length,
146148
)
147149
ddwaf_object_array_add(array, obj)
148-
elif isinstance(struct, dict):
150+
elif isinstance(struct, Mapping):
149151
if max_depth <= 0:
150152
observator.set_container_depth(DDWAF_MAX_CONTAINER_DEPTH)
151153
max_objects = 0

ddtrace/settings/asm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ def _eval_asm_can_be_enabled(self) -> None:
311311
self._asm_can_be_enabled = APPSEC_ENV not in os.environ and tracer_config._remote_config_enabled
312312
self._load_modules = bool(self._ep_enabled and (self._asm_enabled or self._asm_can_be_enabled))
313313
self._asm_rc_enabled = (self._asm_enabled and tracer_config._remote_config_enabled) or self._asm_can_be_enabled
314+
if APPSEC_ENV in os.environ and self._asm_enabled:
315+
tracer_config._trace_resource_renaming_enabled = True
314316

315317
@property
316318
def _api_security_feature_active(self) -> bool:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
fixes:
3+
- |
4+
AAP: This fix resolves an issue where downstream request analysis would not match headers in rules when using `requests` with `urllib3<2`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
deprecations:
3+
- |
4+
Support for ddtrace with Python 3.8 is deprecated and will be removed in version 4.0.0.

scripts/docs/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -eux
33

44
# DEV: unless it's built with editable, following sphinx-build fails
5-
CMAKE_BUILD_PARALLEL_LEVEL=12 CARGO_BUILD_JOBS=12 pip install -v -e .
5+
DD_FAST_BUILD=1 CMAKE_BUILD_PARALLEL_LEVEL=12 CARGO_BUILD_JOBS=12 pip install -v -e .
66

77
if [[ "$(uname)" == "Darwin" ]]; then
88
export PYENCHANT_LIBRARY_PATH=/opt/homebrew/lib/libenchant-2.dylib

scripts/gen_gitlab_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ def gen_build_docs() -> None:
199199
".readthedocs.yml",
200200
}
201201
):
202+
date_str = datetime.datetime.now().strftime("%Y-%m")
203+
202204
with TESTS_GEN.open("a") as f:
203205
print("build_docs:", file=f)
204206
print(" extends: .testrunner", file=f)
@@ -212,7 +214,7 @@ def gen_build_docs() -> None:
212214
print(" hatch run docs:build", file=f)
213215
print(" mkdir -p /tmp/docs", file=f)
214216
print(" cache:", file=f)
215-
print(" key: v2-build_docs-pip-cache", file=f)
217+
print(f" key: build_docs-pip-cache-{date_str}", file=f)
216218
print(" paths:", file=f)
217219
print(" - .cache", file=f)
218220
print(" artifacts:", file=f)

tests/appsec/appsec/test_ddwaf_fuzz.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from hypothesis import given
44
from hypothesis import strategies as st
55
import pytest
6+
from requests.structures import CaseInsensitiveDict
67

78
from ddtrace.appsec._ddwaf.ddwaf_types import _observator
89
from ddtrace.appsec._ddwaf.ddwaf_types import ddwaf_object
@@ -57,6 +58,19 @@ def test_small_objects(obj, res):
5758
assert dd_obj.struct == res
5859

5960

61+
@pytest.mark.parametrize(
62+
["obj", "res"],
63+
[
64+
(CaseInsensitiveDict({"SomeHeader": "SomeValue"}), {"SomeHeader": "SomeValue"}),
65+
(range(1, 4), [1, 2, 3]),
66+
((1, 2, 3), [1, 2, 3]),
67+
],
68+
)
69+
def test_mappings_and_sequences(obj, res):
70+
dd_obj = ddwaf_object(obj)
71+
assert dd_obj.struct == res
72+
73+
6074
@pytest.mark.parametrize(
6175
"obj, res, trunc",
6276
[

tests/commands/test_runner.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,12 @@ def test_global_trace_tags_deprecation_warning():
531531
warnings.simplefilter("always")
532532
import ddtrace.auto # noqa: F401
533533

534-
assert len(warns) == 1
535-
warning_message = str(warns[0].message)
534+
assert len(warns) >= 1
535+
warning_messages = [str(warn.message) for warn in warns]
536536
assert (
537-
warning_message
538-
== "DD_TRACE_GLOBAL_TAGS is deprecated and will be removed in version '4.0.0': Please migrate to using DD_TAGS instead" # noqa: E501
539-
), warning_message
537+
"DD_TRACE_GLOBAL_TAGS is deprecated and will be removed in version '4.0.0': Please migrate to using "
538+
"DD_TAGS instead" in warning_messages
539+
), warning_messages
540540

541541

542542
@pytest.mark.subprocess(ddtrace_run=False, err="")

0 commit comments

Comments
 (0)