@@ -10,6 +10,9 @@ import spock.lang.Shared
10
10
11
11
import java.nio.CharBuffer
12
12
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
13
16
import static com.datadog.appsec.event.data.ObjectIntrospection.convert
14
17
15
18
class ObjectIntrospectionSpecification extends DDSpecification {
@@ -381,7 +384,7 @@ class ObjectIntrospectionSpecification extends DDSpecification {
381
384
382
385
void ' jackson string truncation' () {
383
386
setup :
384
- final longString = ' A' * (ObjectIntrospection . MAX_STRING_LENGTH + 1 )
387
+ final longString = ' A' * (MAX_STRING_SIZE + 1 )
385
388
final jsonInput = ' {"long": "' + longString + ' "}'
386
389
387
390
when :
@@ -390,14 +393,14 @@ class ObjectIntrospectionSpecification extends DDSpecification {
390
393
then :
391
394
1 * ctx. setWafTruncated()
392
395
1 * wafMetricCollector. wafInputTruncated(true , false , false )
393
- result[" long" ]. length() <= ObjectIntrospection . MAX_STRING_LENGTH
396
+ result[" long" ]. length() <= MAX_STRING_SIZE
394
397
}
395
398
396
399
void ' jackson with deep nesting triggers depth limit' () {
397
400
setup :
398
401
// Create deeply nested JSON
399
402
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] })
401
404
)
402
405
403
406
when :
@@ -407,13 +410,13 @@ class ObjectIntrospectionSpecification extends DDSpecification {
407
410
// Should truncate at max depth and set truncation flag
408
411
1 * ctx. setWafTruncated()
409
412
1 * wafMetricCollector. wafInputTruncated(false , false , true )
410
- countNesting(result as Map , 0 ) <= ObjectIntrospection . MAX_DEPTH
413
+ countNesting(result as Map , 0 ) <= MAX_DEPTH
411
414
}
412
415
413
416
void ' jackson with large arrays triggers element limit' () {
414
417
setup :
415
418
// Create large array
416
- final largeArray = (1 .. (ObjectIntrospection . MAX_ELEMENTS + 1 )). toList()
419
+ final largeArray = (1 .. (MAX_ELEMENTS + 1 )). toList()
417
420
final json = new JsonBuilder (largeArray). toString()
418
421
419
422
when :
@@ -423,7 +426,7 @@ class ObjectIntrospectionSpecification extends DDSpecification {
423
426
// Should truncate and set truncation flag
424
427
1 * ctx. setWafTruncated()
425
428
1 * wafMetricCollector. wafInputTruncated(false , true , false )
426
- result. size() <= ObjectIntrospection . MAX_ELEMENTS
429
+ result. size() <= MAX_ELEMENTS
427
430
}
428
431
429
432
void ' jackson number type variations' () {
0 commit comments