Project

General

Profile

Actions

Bug #6921

closed

jsonbuilder: serializes Rust f64 NaNs to an invalid literal

Added by Simen Lybekk 9 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
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:

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

json-nan.patch (1.47 KB) json-nan.patch Simen Lybekk, 04/05/2024 10:33 AM

Subtasks 1 (0 open1 closed)

Bug #6923: jsonbuilder: serializes Rust f64 NaNs to an invalid literal (7.0.x backport)ClosedJason IshActions
Actions #1

Updated by Simen Lybekk 9 months ago

  • Description updated (diff)
Actions #2

Updated by Simen Lybekk 9 months ago

  • Description updated (diff)
Actions #3

Updated by Simen Lybekk 9 months ago

  • Description updated (diff)
Actions #4

Updated by Jason Ish 9 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 #5

Updated by OISF Ticketbot 9 months ago

  • Subtask #6923 added
Actions #6

Updated by OISF Ticketbot 9 months ago

  • Label deleted (Needs backport to 7.0)
Actions #7

Updated by Jason Ish 9 months ago

  • Status changed from In Progress to In Review
Actions #8

Updated by Jason Ish 8 months ago

  • Status changed from In Review to Resolved
Actions #9

Updated by Philippe Antoine 6 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF