Skip to content

Commit 94d92e0

Browse files
committed
new approach test
1 parent fcaf1fb commit 94d92e0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

dd-java-agent/appsec/src/test/groovy/com/datadog/appsec/event/data/ObjectIntrospectionSpecification.groovy

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,4 +583,40 @@ class ObjectIntrospectionSpecification extends DDSpecification {
583583
return map.entrySet().iterator()
584584
}
585585
}
586+
587+
static class DtoWithLogger {
588+
String userId = 'user123'
589+
java.util.logging.Logger logger = java.util.logging.Logger.getLogger('test')
590+
String payload = 'data'
591+
}
592+
593+
void 'logging framework fields are excluded from introspection'() {
594+
given:
595+
def input = new DtoWithLogger()
596+
597+
when:
598+
def result = convert(input, ctx) as Map
599+
600+
then:
601+
result['userId'] == 'user123'
602+
result['payload'] == 'data'
603+
!result.containsKey('logger')
604+
}
605+
606+
static class WrapperWithSoftRef {
607+
String name = 'test'
608+
java.lang.ref.SoftReference<String> ref = new java.lang.ref.SoftReference<>('test')
609+
}
610+
611+
void 'objects with inaccessible JDK fields skip those fields rather than expose toString()'() {
612+
given:
613+
def input = new WrapperWithSoftRef()
614+
615+
when:
616+
def result = convert(input, ctx) as Map
617+
618+
then:
619+
result['name'] == 'test'
620+
result['ref'] instanceof Map
621+
}
586622
}

0 commit comments

Comments
 (0)