Actions
Bug #6921
closedjsonbuilder: serializes Rust f64 NaNs to an invalid literal
Affected Versions:
Effort:
Difficulty:
Label:
Description
Flagging as a bug, although could be argued that it's not.
The JSON builder has two methods for handling floats:- append_float - https://github.com/OISF/suricata/blob/master/rust/src/jsonbuilder.rs#L425
- set_float - https://github.com/OISF/suricata/blob/master/rust/src/jsonbuilder.rs#L637
These do not check whether the float value is NaN (https://doc.rust-lang.org/std/primitive.f64.html#method.is_nan), and may as such serialize a float as the literal keyword "NaN".
Some JSON parsers like serde_json will not accept this as valid JSON. serde-rs writes a bit more about this here: https://github.com/serde-rs/json/issues/879
We decided to patch this to a string "NaN" as this is good enough for our use, patch attached.
Doing this does mean that all the JSON Schemas for EVE logs needs to be updated.
I expect that "Infinity" will behave similarly to "NaN", although I haven't checked this.
Files
Updated by Jason Ish 8 months ago
- Subject changed from jsonbuilder serializes Rust f64 NaNs to an invalid literal to jsonbuilder: serializes Rust f64 NaNs to an invalid literal
- Status changed from New to In Progress
- Assignee changed from OISF Dev to Jason Ish
- Target version changed from TBD to 8.0.0-beta1
- Label Needs backport to 7.0 added
Actions