Skip to content

Commit

Permalink
[Backport 2.x] Prevent raw request body as output in serialization er…
Browse files Browse the repository at this point in the history
…ror messages (#3279)

Backport 9fb106c from #3205.

Signed-off-by: Andrey Pleskach <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 4c9e6eb commit d8a30d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class DefaultObjectMapper {
// if jackson cant parse the entity, e.g. passwords, hashes and so on,
// but provides which property is unknown
objectMapper.disable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION);
defaulOmittingObjectMapper.disable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION);
YAML_MAPPER.disable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION);
// objectMapper.enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS);
objectMapper.enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION);
defaulOmittingObjectMapper.setSerializationInclusion(Include.NON_DEFAULT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class NonValidatingObjectMapper {
private static final ObjectMapper nonValidatingObjectMapper = new ObjectMapper();

static {
nonValidatingObjectMapper.disable(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION);
nonValidatingObjectMapper.setSerializationInclusion(Include.NON_NULL);
nonValidatingObjectMapper.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, false);
nonValidatingObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
Expand All @@ -65,12 +66,7 @@ public static <T> T readValue(String string, JavaType jt) throws IOException {
}

try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<T>() {
@Override
public T run() throws Exception {
return nonValidatingObjectMapper.readValue(string, jt);
}
});
return AccessController.doPrivileged((PrivilegedExceptionAction<T>) () -> nonValidatingObjectMapper.readValue(string, jt));
} catch (final PrivilegedActionException e) {
throw (IOException) e.getCause();
}
Expand Down

0 comments on commit d8a30d4

Please sign in to comment.