@@ -10,6 +10,9 @@ import spock.lang.Shared
1010
1111import java.nio.CharBuffer
1212
13+ import static com.datadog.appsec.ddwaf.WAFModule.MAX_DEPTH
14+ import static com.datadog.appsec.ddwaf.WAFModule.MAX_ELEMENTS
15+ import static com.datadog.appsec.ddwaf.WAFModule.MAX_STRING_SIZE
1316import static com.datadog.appsec.event.data.ObjectIntrospection.convert
1417
1518class ObjectIntrospectionSpecification extends DDSpecification {
@@ -381,7 +384,7 @@ class ObjectIntrospectionSpecification extends DDSpecification {
381384
382385 void ' jackson string truncation' () {
383386 setup :
384- final longString = ' A' * (ObjectIntrospection . MAX_STRING_LENGTH + 1 )
387+ final longString = ' A' * (MAX_STRING_SIZE + 1 )
385388 final jsonInput = ' {"long": "' + longString + ' "}'
386389
387390 when :
@@ -390,14 +393,14 @@ class ObjectIntrospectionSpecification extends DDSpecification {
390393 then :
391394 1 * ctx. setWafTruncated()
392395 1 * wafMetricCollector. wafInputTruncated(true , false , false )
393- result[" long" ]. length() <= ObjectIntrospection . MAX_STRING_LENGTH
396+ result[" long" ]. length() <= MAX_STRING_SIZE
394397 }
395398
396399 void ' jackson with deep nesting triggers depth limit' () {
397400 setup :
398401 // Create deeply nested JSON
399402 final json = JsonOutput . toJson(
400- (1 .. (ObjectIntrospection . MAX_DEPTH + 1 )). inject([:], { result , i -> [(" child_$i " . toString()) : result] })
403+ (1 .. (MAX_DEPTH + 1 )). inject([:], { result , i -> [(" child_$i " . toString()) : result] })
401404 )
402405
403406 when :
@@ -407,13 +410,13 @@ class ObjectIntrospectionSpecification extends DDSpecification {
407410 // Should truncate at max depth and set truncation flag
408411 1 * ctx. setWafTruncated()
409412 1 * wafMetricCollector. wafInputTruncated(false , false , true )
410- countNesting(result as Map , 0 ) <= ObjectIntrospection . MAX_DEPTH
413+ countNesting(result as Map , 0 ) <= MAX_DEPTH
411414 }
412415
413416 void ' jackson with large arrays triggers element limit' () {
414417 setup :
415418 // Create large array
416- final largeArray = (1 .. (ObjectIntrospection . MAX_ELEMENTS + 1 )). toList()
419+ final largeArray = (1 .. (MAX_ELEMENTS + 1 )). toList()
417420 final json = new JsonBuilder (largeArray). toString()
418421
419422 when :
@@ -423,7 +426,7 @@ class ObjectIntrospectionSpecification extends DDSpecification {
423426 // Should truncate and set truncation flag
424427 1 * ctx. setWafTruncated()
425428 1 * wafMetricCollector. wafInputTruncated(false , true , false )
426- result. size() <= ObjectIntrospection . MAX_ELEMENTS
429+ result. size() <= MAX_ELEMENTS
427430 }
428431
429432 void ' jackson number type variations' () {
0 commit comments