Commit graph

47 commits

Author SHA1 Message Date
Arne Welzel
d892cac58c formatters/JSON: Make JSON::NullDoubleWriter use zeek::json::detail version
Not using inheritance and preferring composition to avoid including the
detail/json.h header do an indirection via a unique_ptr and then just
re-use the Double() implementation.
2023-06-17 14:11:18 +02:00
Arne Welzel
7c3b5553d8 formatters/JSON: Remove surrounding_braces
This seems to have become unused 4 years ago with 9b76e8faf4,
remove it.
2023-06-17 13:48:25 +02:00
Arne Welzel
6efc696179 formatters/JSON: Prepare to remove rapidjson from installed Zeek headers
threading/formatters/JSON.h currently includes rapidjson headers for declaring
the NullDoubleWriter. This appears mostly an internal detail, but
results in the situation that 1) we need to ship rapidjson headers with
the Zeek install tree and 2) taking care that external plugins are able
to find these headers should they include formatters/JSON.h.

There are currently no other Zeek headers that include rapidjson, so this
seems very unfortunate and self-inflicted given it's not actually required.

Attempt to hide this implementation detail with the goal to remove the
rapidjson includes with v7.1 and then also stop bundling and exposing
the include path to external plugins.

The NullDoubleWriter implementation moves into a new formatters/detail/json.h
header which is not installed.

Closes #3128
2023-06-17 13:48:25 +02:00
Tim Wojtulewicz
f624c18383 Deprecate bro_int_t and bro_uint_t 2022-07-12 12:01:23 -07:00
Tim Wojtulewicz
7c4fd382d9 Code modernization: Convert from deprecated C standard library headers 2022-06-27 09:47:31 -07:00
Christian Kreibich
1aaed1cc2e Add LogAscii::json_include_unset_fields flag to control unset field rendering
The flag controls whether JSON rendering includes unset &optional log fields
(F, the default), or includes them with a null value (T).
2021-12-08 17:29:07 -08:00
Tim Wojtulewicz
4423574d26 clang-format: Set IndentCaseBlocks to false 2021-09-27 10:49:48 -07:00
Tim Wojtulewicz
b2f171ec69 Reformat the world 2021-09-16 15:35:39 -07:00
Jon Siwek
8a8a983c49 Add missing zeek/ to header includes
Related to https://github.com/zeek/zeek/pull/1377
2021-01-29 19:16:29 -08:00
Tim Wojtulewicz
96d9115360 GH-1079: Use full paths starting with zeek/ when including files 2020-11-12 12:15:26 -07:00
Tim Wojtulewicz
fe0c22c789 Base: Clean up explicit uses of namespaces in places where they're not necessary.
This commit covers all of the common and base classes.
2020-08-24 12:07:00 -07:00
Tim Wojtulewicz
8d2d867a65 Move everything in util.h to zeek::util namespace.
This commit includes renaming a number of methods prefixed with bro_ to be prefixed with zeek_.
2020-08-20 16:00:33 -07:00
Tim Wojtulewicz
1262109e5a Move threading classes to zeek namespaces 2020-08-20 15:55:17 -07:00
Johanna Amann
22b401f52f Merge remote-tracking branch 'origin/topic/johanna/1095-just-get-rid-of-it'
* origin/topic/johanna/1095-just-get-rid-of-it:
  Re-add TYPE_COUNTER without function and deprecation marker.
  Completely remove all traces of the COUNTER type.
2020-08-03 10:44:43 -07:00
Tim Wojtulewicz
4e9a5e9d98 Move ODesc to zeek namespace 2020-07-31 16:25:54 -04:00
Tim Wojtulewicz
bfab224d7c Move Reporter to zeek namespace 2020-07-31 16:22:41 -04:00
Johanna Amann
417a6eb1e9 Completely remove all traces of the COUNTER type.
Relates to GH-1095
2020-07-30 12:11:05 -07:00
Tim Wojtulewicz
1248411a2f Use properly-sized loop variables or convert to ranged-for (bugprone-too-small-loop-variable) 2020-07-28 12:36:40 -07:00
Jon Siwek
946ceba832 Fix "possibly-truncated" compiler warning in BuildJSON snprintf() 2020-06-24 17:59:28 -07:00
Tim Wojtulewicz
ed13972924 Move Type types to zeek namespace 2020-06-09 17:20:45 -07:00
Tim Wojtulewicz
d53c1454c0 Remove 'using namespace std' from SerialTypes.h
This unfortunately cuases a ton of flow-down changes because a lot of other
code was depending on that definition existing. This has a fairly large chance
to break builds of external plugins, considering how many internal ones it broke.
2020-04-07 15:59:59 -07:00
Jon Siwek
ba9c06fc2b Move rapidjson submodule to aux directory
This also now installs the full rapidjson include/ tree in order to
allow external plugins to properly build if they include
threading/formatters/JSON.h
2020-03-05 19:24:13 -08:00
Max Kellermann
0db61f3094 include cleanup
The Zeek code base has very inconsistent #includes.  Many sources
included a few headers, and those headers included other headers, and
in the end, nearly everything is included everywhere, so missing
#includes were never noticed.  Another side effect was a lot of header
bloat which slows down the build.

First step to fix it: in each source file, its own header should be
included first to verify that each header's includes are correct, and
none is missing.

After adding the missing #includes, I replaced lots of #includes
inside headers with class forward declarations.  In most headers,
object pointers are never referenced, so declaring the function
prototypes with forward-declared classes is just fine.

This patch speeds up the build by 19%, because each compilation unit
gets smaller.  Here are the "time" numbers for a fresh build (with a
warm page cache but without ccache):

Before this patch:

 3144.94user 161.63system 3:02.87elapsed 1808%CPU (0avgtext+0avgdata 2168608maxresident)k
 760inputs+12008400outputs (1511major+57747204minor)pagefaults 0swaps

After this patch:

 2565.17user 141.83system 2:25.46elapsed 1860%CPU (0avgtext+0avgdata 1489076maxresident)k
 72576inputs+9130920outputs (1667major+49400430minor)pagefaults 0swaps
2020-02-04 20:51:02 +01:00
Robin Sommer
8170baabef Merge remote-tracking branch 'origin/topic/timw/595-rapidjson'
Tweaks:
    - Small change to the logic for removing quotes around strings.
    - Updated NEWS & COPYING.3rdparty
    - Use of intrusive_ptr for stack-allocated StringVals
    - Little bit of refactoring (I would love to merge the two BuildJSON() functions, too, but that's a larger task)

* origin/topic/timw/595-rapidjson:
  Use the list of files from clang-tidy when searching for unit tests
  Optimize json_escape_utf8 a bit by removing repeated calls to string methods
  Expand unit test for json_escape_utf8 to include all of the strings from the ascii-json-utf8 btest
  GHI-595: Convert from nlohmann/json to rapidjson for performance reasons
  Convert type-checking macros to actual functions
2020-01-18 10:49:15 +00:00
Tim Wojtulewicz
46e7308422 GHI-595: Convert from nlohmann/json to rapidjson for performance reasons 2020-01-14 15:43:25 -07:00
Jon Siwek
a5d71ed2d2 Merge remote-tracking branch 'origin/topic/timw/595-json-perf'
* origin/topic/timw/595-json-perf:
  Update COPYING.3rdparty
  Use json::emplace to avoid some extra calls to operator[]
  Use tessil/unordered-map instead of nlohmann/fifo-map to mitigate performance issues when logging JSON
2019-10-01 16:42:59 -07:00
Tim Wojtulewicz
d4c394b72a GH-606: Output nulls into json data if a field isn't set 2019-09-27 14:12:48 -07:00
Tim Wojtulewicz
d4d1009b5c Use json::emplace to avoid some extra calls to operator[] 2019-09-27 09:58:24 -07:00
Johanna Amann
1f329ad541 Merge remote-tracking branch 'origin/topic/timw/150-to-json'
* origin/topic/timw/150-to-json:
  Update submodules for JSON work
  Update unit tests for JSON logger to match new output
  Modify JSON log writer to use the external JSON library
  Update unit test output to match json.zeek being deprecated and slight format changes to JSON output
  Add proper JSON serialization via C++, deprecate json.zeek
  Add new method for escaping UTF8 strings for JSON output
  Move do_sub method from zeek.bif to StringVal class method
  Move record_fields method from zeek.bif to Val class method
  Add ToStdString method for StringVal
2019-07-11 11:17:32 -07:00
Tim Wojtulewicz
9b76e8faf4 Modify JSON log writer to use the external JSON library 2019-07-02 13:14:52 -07:00
Robin Sommer
789cb376fd GH-239: Rename bro to zeek, bro-config to zeek-config, and bro-path-dev to zeek-path-dev.
This also installs symlinks from "zeek" and "bro-config" to a wrapper
script that prints a deprecation warning.

The btests pass, but this is still WIP. broctl renaming is still
missing.

#239
2019-05-01 21:43:45 +00:00
Jon Siwek
b20cd599a0 GH-282: Remove JSON formatter's range restriction on numbers
It now produces numbers as large as is required to match the data it
needs to represent.  It's up to the consumer to decide how to
appropriately handle values that may be outside their supported
range/precision.

Fixes GH-282
2019-02-27 11:22:29 -06:00
Jon Siwek
70233148be GH-186: fix JSON formatting of timestamps before Unix epoch 2018-10-12 21:34:28 +00:00
Johanna Amann
ed3447acaa Fix one more format error found by gcc 5.3.1 2016-08-15 16:54:22 -07:00
Seth Hall
40e9724de7 Switching all use of gmtime and localtime to use reentrant variants.
This was causing occasional problems with the time on processes
running lots of threads.  The use of gmtime in the json
formatter is the likely culprit due to the fact that the
json formatter runs in threads.  More evidence for this is that
the problem only appears to exhibit when logs are being written
as JSON.
2016-05-07 01:22:38 -04:00
Robin Sommer
9d7ec6b6d2 Merge branch 'master' of https://github.com/aeppert/bro
Cleaned up the surrounding code a bit and also added '[' as another
case (not sure that can happen, but doesn't hurt eihter).

* 'master' of https://github.com/aeppert/bro:
  Whitespace
  Remove
  Remove.
  Fix for JSON formatter
  A fatal error, especially in DEBUG, should result in a core.
  Seems to fix a case where an entry in the table may be null on insert.
2015-10-26 16:52:47 -07:00
Aaron Eppert
295dbc3055 Fix for JSON formatter
In the event that the first entry in a record is optional AND not present, the serializer will incorrectly add a leading comma. This leading common is invalid JSON and will, more often than not, cause parser failures downstream.
2015-10-26 17:55:01 -04:00
Robin Sommer
3957091e1b Renaming config.h to bro-config.h.
A couple times now I had this conflicting with files of the same name
in other projects.
2015-07-28 11:57:04 -07:00
Seth Hall
b00bd7702f Add the ability to remove surrounding braces from the JSON formatter. 2015-02-13 22:02:54 -05:00
Jon Siwek
e8a5ea8844 Refactor various hex escaping code. 2014-04-18 13:19:50 -05:00
Bernhard Amann
636d25e526 Fix compile errror on freebsd - defines have to be moved up due to
header dependencies.
2014-03-16 22:22:44 -07:00
Robin Sommer
8b241947d6 Fixing a few cases of undefined behaviour introduced by recent
formatter work.

Thanks, Coverity!
2014-03-14 08:45:36 -07:00
Robin Sommer
17f9d0a47d Fixing compiler error.
Hopefully ...
2014-03-13 18:02:41 -07:00
Robin Sommer
ff261ea626 Merge remote-tracking branch 'origin/topic/seth/json-formatter'
* origin/topic/seth/json-formatter:
  Updating a couple of tests.
  Expanded support for modifying the timestamp format in the JSON formatter.
  Ascii input reader now supports all config options per-input stream.
  Added an option to the JSON formatter to use ISO 8601 for timestamps.
  Refactored formatters and updated the the writers a bit.

Includes some minor bugfixes and cleanup at various places, including
in old code.
2014-03-13 16:50:56 -07:00
Seth Hall
c591e4f57f Expanded support for modifying the timestamp format in the JSON formatter. 2014-03-12 10:01:59 -04:00
Seth Hall
c9aaf9e753 Added an option to the JSON formatter to use ISO 8601 for timestamps.
- It's not *exactly* ISO 8601 which doesn't seem to support
   subseconds, but subseconds are very important to us and
   most things that support ISO8601 seem to also support subseconds
   in the way I'm implemented it.
2014-03-10 14:22:35 -04:00
Seth Hall
a56c343715 Refactored formatters and updated the the writers a bit.
- Formatters have been abstracted similarly to readers and writers now.
 - The Ascii writer has a new option for writing out logs as JSON.
 - The Ascii writer now has all options availble as per-filter
   options as well as global.
2014-03-10 10:42:59 -04:00