-
Notifications
You must be signed in to change notification settings - Fork 103
Add ObjectMapper unescaping ASCII control characters when using DTOs #1429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| import java.nio.file.Path | ||
|
|
||
| class JavaDtoOutput: JvmDtoOutput() { | ||
| class JavaDtoOutput(val outputFormat: OutputFormat): JvmDtoOutput() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is any special reason to keep outputFormat here as a field? also, in that case, shouldnt we have a init{} block to validate it? (ie throw IllegalArgument if not for Java)
| lines.add("public ObjectMapper create(Type cls, String charset) {") | ||
| lines.indented { | ||
| lines.add("ObjectMapper mapper = new ObjectMapper();") | ||
| lines.add("mapper.registerModule(new Jdk8Module());") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs some comment explanations
| import java.nio.file.Path | ||
|
|
||
| class KotlinDtoOutput: JvmDtoOutput() { | ||
| class KotlinDtoOutput(val outputFormat: OutputFormat): JvmDtoOutput() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input validation?
| lines.indented { | ||
| lines.add(".jsonConfig(JsonConfig.jsonConfig().numberReturnType(JsonPathConfig.NumberReturnType.DOUBLE))") | ||
| lines.add(".redirect(redirectConfig().followRedirects(false))") | ||
| if (config.dtoSupportedForPayload() && containsDtos) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need some comments here to explain why this is done
| lines.add(".redirect(redirectConfig().followRedirects(false))") | ||
| if (config.dtoSupportedForPayload() && containsDtos) { | ||
| lines.indented { | ||
| lines.add(".objectMapperConfig(") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this now always applied? so we go through this custom mapper even if there are no issues with the payloads?
ASCII control characters were being escaped by Jackson when using DTOs. Control characters in a JSON payload generate an invalid payload, which was being tested by EvoMaster. As such, we created a custom object mapper that will not escape the ASCII control characters, allowing for incorrect payloads to be tested.