Skip to content

Commit b2da201

Browse files
committed
Fix
1 parent 949ee8c commit b2da201

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

dd-java-agent/appsec/src/main/java/com/datadog/appsec/event/data/ObjectIntrospection.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ private static boolean setAccessible(Field field) {
345345
}
346346

347347
private static String checkStringLength(final String str, final State state) {
348+
if (str == null) {
349+
return null;
350+
}
348351
if (str.length() > MAX_STRING_SIZE) {
349352
state.stringTooLong = true;
350353
return str.substring(0, MAX_STRING_SIZE);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ class ObjectIntrospectionSpecification extends DDSpecification {
354354
MAPPER.readTree('{"key": "value"}') || [key: 'value']
355355
}
356356

357+
void 'jackson text nodes with null textual value are handled gracefully'() {
358+
given:
359+
def node = new com.fasterxml.jackson.databind.node.NullTextJsonNode()
360+
361+
expect:
362+
convert(node, ctx) == null
363+
}
364+
357365
void 'jackson nested structures'() {
358366
when:
359367
final result = convert(input, ctx)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.fasterxml.jackson.databind.node
2+
3+
import com.fasterxml.jackson.core.JsonGenerator
4+
import com.fasterxml.jackson.core.JsonToken
5+
import com.fasterxml.jackson.databind.JsonNode
6+
import com.fasterxml.jackson.databind.SerializerProvider
7+
import java.io.IOException
8+
9+
class NullTextJsonNode extends BaseJsonNode {
10+
@Override
11+
JsonNodeType getNodeType() {
12+
return JsonNodeType.STRING
13+
}
14+
15+
@Override
16+
String textValue() {
17+
return null
18+
}
19+
20+
@Override
21+
JsonToken asToken() {
22+
return JsonToken.VALUE_STRING
23+
}
24+
25+
@Override
26+
void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException {
27+
gen.writeNull()
28+
}
29+
30+
@Override
31+
JsonNode deepCopy() {
32+
return this
33+
}
34+
}

0 commit comments

Comments
 (0)