Skip to content

Commit 063d614

Browse files
authored
Fix appsec truncation object_depth test (#4380)
Signed-off-by: Eliott Bouhana <eliott.bouhana@datadoghq.com>
1 parent f7362a4 commit 063d614

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

tests/appsec/waf/test_truncation.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ def test_truncation(self):
3737

3838
assert int(metrics["_dd.appsec.truncated.string_length"]) == 5000
3939
assert int(metrics["_dd.appsec.truncated.container_size"]) == 300
40-
assert int(metrics["_dd.appsec.truncated.container_depth"]) == 20
40+
41+
# Because finding the actual depth is non-trivial and the definition of depth could differ between libraries
42+
# depending on if the addresses are counted or not, we are not asserting the exact value here.
43+
# Max value of 28 is made of:
44+
# * 25 "a" from create_nested_object()
45+
# * 1 "deepObject" from setup_truncation()
46+
# * 1 "server.request.body" address
47+
# * 1 of leeway depending on how leafs of the tree are counted
48+
assert 20 <= int(metrics["_dd.appsec.truncated.container_depth"]) <= 28
4149

4250
waf_requests_series = find_series("generate-metrics", "appsec", ["waf.requests"])
4351
has_input_truncated = any("input_truncated:true" in series["tags"] for series in waf_requests_series)

0 commit comments

Comments
 (0)