-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix conversion of intervals through JSON #4056
base: master
Are you sure you want to change the base?
Conversation
89ceaf5
to
de35626
Compare
de35626
to
d81090c
Compare
Ah, that's a good point. I see you did anyway - to some degree I didn't realize the entry is
I was thinking converting the options RecordVal to a plain struct that's then passed down. Though that one extra parameter for now seems fine. |
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.
Mostly nits, feel free to reject or address.
I like where this ended!
T | ||
T | ||
T | ||
F |
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 one looks a bit off, is it print f$n == f2_v$n;
?
@@ -0,0 +1,102 @@ | |||
# @TEST-DOCS: Test round-trip JSON encoding and decoding using the Zeek methods |
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.
Thanks for adding this! Could also see this one in bifs/
, next to the existing from_json.zeek
test. I thought base/utils
is used for what's actually located in base/utils
.
@@ -5103,14 +5103,18 @@ function anonymize_addr%(a: addr, cl: IPAddrAnonymizationClass%): addr | |||
## rendered name. The default pattern strips a leading | |||
## underscore. | |||
## | |||
## interval_as_double: If true, interval values will be logged as doubles |
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.
## interval_as_double: If true, interval values will be logged as doubles | |
## interval_as_double: If T, interval values will be logged as doubles |
@@ -5103,14 +5103,18 @@ function anonymize_addr%(a: addr, cl: IPAddrAnonymizationClass%): addr | |||
## rendered name. The default pattern strips a leading | |||
## underscore. | |||
## | |||
## interval_as_double: If true, interval values will be logged as doubles | |||
## instead of the broken-out version with units. |
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.
Would be good to mention type string. Maybe this?
## instead of the broken-out version with units. | |
## instead of the broken-out version with units as strings. |
return make_intrusive<IntervalVal>(j.GetDouble()); | ||
|
||
if ( j.IsString() ) { | ||
auto parts = util::split(j.GetString(), " "); |
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.
I'm not sure we care all that much, but IIRC superfluous spaces would yield empty parts. Could filter out empty parts to support more than one spaces as separators. Mostly relevant if someone crafts input by hand.
I'm lifting this out of the storage framework work since it doesn't need to be in there exclusively. This fixes the conversion of
interval
values from JSON toIntervalVal
objects. It also adds a simple btest to test round-trip conversion of Vals through JSON.