Skip to content

Strict JSON validation during parsing of configuration parameters #679

@brenuart

Description

@brenuart

A Jackson JsonParser is used at different places in the project to convert a JSON string into a JsonNode. Reading the string is usually done as follows:

try (JsonParser parser = jsonFactory.createParser(json)) {
   JsonNode node = parser.readValueAsTree();
}

It should be notated that the parser will stop reading the input after it found a valid JsonNode entry, leaving the rest of the string unread. This means that a string like "1 garbage" is accepted and returns a single NumericNode with value 1, ignoring the garbage at the end of the string. For the same reason, parsing "{"name":"value"} garbage" will return an ObjectNode with the name/value pair, leaving garbage unread until the next attempt at reading from the same parser.

Converting a JSON string into a JsonNode is required when processing user-supplied configuration settings (expressed as string in the XML configuration). These fields are meant to contain a valid JSON and should obviously fail or raise an ERROR status in the scenarios described above.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions