Commit graph

483 commits

Author SHA1 Message Date
Robin Sommer
d0b206fa36 Remove APIs that were explicitly deprecated to be removed in 3.1.
Special handling for bro_{init,done,script_loaded} events: if still
used, they cause Zeek to abort at startup.
2020-01-29 12:08:09 +00:00
Johanna Amann
68f0fe9e8c Automatic bro table->brokerstore insert operations
We now have an &broker_store attribute which automatically sends
inserts/deletes into a set/table to broker.

This might work - I actually did not test if the data ends up in the
broker store in the end. A limitation is that the table/set currently
only can have a one-element type since Broker doesn't support the list
type.
2020-01-23 13:13:10 -08:00
Johanna Amann
98ad95d00b Merge remote-tracking branch 'origin/master' into topic/johanna/table-changes 2020-01-22 16:02:12 -08: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
Johanna Amann
382c4ddc2f &on_change: add insertion/change notifications.
Also - work with sets in addition to tables.
2020-01-13 19:39:40 -08:00
Johanna Amann
b343cf9bb7 &on_change working for removals from tables.
Insertions and changes are still noops.
2020-01-13 15:28:56 -08:00
Johanna Amann
96329e2172 Merge remote-tracking branch 'origin/master' into topic/johanna/table-changes 2020-01-09 12:48:20 -05:00
Johanna Amann
bf31587c2c Beginning implementation of &on_change for tables. 2020-01-09 12:47:16 -05:00
Tim Wojtulewicz
65a4e36a92 Merge remote-tracking branch 'origin/topic/jsiwek/asan'
* origin/topic/jsiwek/asan: (28 commits)
  Increase timeout for a btest
  Switch CI scripts to use ASAN/LSAN instead of gperftools
  Remove redundant memory leak btests
  Fix reference counting issues related to lambdas/closures
  Disable LeakSanitizer for btests that have known leaks
  Rewrite the btest for when-statement timeouts
  Fix memory leak when a logging plugin hook prevents a write
  Fix memory leaks in various input framework error-handling cases
  Fix memory leak in Reporter::get_weird_sampling_whitelist() BIF
  Fix reference counting of Log::Filter "config" field
  Fix memory leak in system_env() BIF
  Clean up triggers awaiting global state modification at shutdown
  Fix memory leak in initializing log writers with no local backend
  Fix packet filter memory leaks
  Skip sending thread heartbeat if it alread asked to be finished
  Fix memory leak of sqlite input reader prepared statement
  Prevent duplicate "finish" threading messages
  Fix memory leak when table-based input stream overwrites old entries
  Fix scripting error in a DHCP btest
  Fix memory leaks in Kerberos ticket decryption
  ...
2020-01-06 11:20:47 -07:00
Jon Siwek
44d922c4b5 Fix reference counting issues related to lambdas/closures
For example, circular references between a lambda function the frame
it's stored within and/or its closure could cause memory leaks.

This also fixes other various reference-count ownership issues that
could lead to memory errors.

There may still be some potential/undiscovered issues because the "outer
ID" finding logic doesn't look quite right as the AST traversal descends
within nested lambdas and considers their locals as "outer", but
possibly the other logic for locating values in closures or cloning
closures just works around that behavior.
2020-01-02 23:04:22 -08:00
Tim Wojtulewicz
67fcc9b5af Mark safe_snprintf and safe_vsnprintf as deprecated, remove uses of them
safe_snprintf and safe_vsnprintf just exist to ensure that the resulting strings are always null-terminated. The documentation for snprintf/vsnprintf states that the output of those methods are always null-terminated, thus making the safe versions obsolete.
2020-01-02 15:36:39 -07:00
Jon Siwek
c0d6eb9efb Fix malloc/delete mismatch in JSON formatting
ODesc allocated with malloc() and BroString deallocated with delete[],
but really the intermediate BroString wasn't even needed when copying
into std::string.
2020-01-01 12:47:39 -08:00
Tim Wojtulewicz
98d1aadb9e GHI-599: avoid memory leak with default pattern matching and json formatting 2019-12-13 10:07:51 -07:00
Johanna Amann
b86a8acc2b Merge remote-tracking branch 'origin/topic/jsiwek/improve-record-fields-bif'
* origin/topic/jsiwek/improve-record-fields-bif:
  Allow record_fields() string arguments that name a record type
2019-11-07 13:49:14 -08:00
Jon Siwek
63fe835acf Allow record_fields() string arguments that name a record type 2019-11-01 12:46:17 -07:00
Dominik Charousset
72e15fe4d4 Integrate review feedback 2019-10-29 21:24:56 +01:00
Dominik Charousset
0f41b063b2 Add and use new IntrusivePt type in Zeek
Manual memory management via Ref/Unref is verbose and prone to error. An
intrusive smart pointer automates the reference counting, makes code
more robust (in particular w.r.t. to exceptions) and reduces boilerplate
code. A big benefit of the intrusive smart pointers for Zeek is that
they can co-exist with the manual memory management. Rather than having
to port the entire code base at once, we can migrate components
one-by-one. In this first step, we add the new template
`IntrusivePtr<T>` and start using it in the Broker Manager. This makes
the previous `unref_guard` obsolete.
2019-10-29 16:49:27 +01:00
Johanna Amann
ff612876c5 Revert "Fix compilation on OS-X."
This reverts commit cde28074a1.

We now have a c++14 compiler.

Fixes GH-626
2019-10-29 11:42:45 +01:00
Johanna Amann
cde28074a1 Fix compilation on OS-X.
OS X complains about std::pair not having a constexpr constructor. Which
seems to be the case for C++11. Hence, let's make it static const for
the moment.

This commit should be reverted when we move to C++17.
2019-10-07 18:52:11 -07:00
Johanna Amann
e615d1f4a8 Merge remote-tracking branch 'origin/topic/jsiwek/gh-589-sub-microsecond-printing'
* origin/topic/jsiwek/gh-589-sub-microsecond-printing:
  GH-589: improve printing of sub-microsecond intervals
2019-10-07 10:51:40 -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
Jon Siwek
a34ade4876 Improve RecordVal JSON formatting
No need to create a record introspection table each time when all
the required information can be obtained directly in the RecordVal
and RecordType objects.  Besides the additional overhead, using such
a table will re-order the fields arbitrarily instead of using the
order in which they're defined.
2019-09-30 19:04:55 -07:00
Jon Siwek
d258ebe5ca Fix memory leak in RecordVal JSON formatting 2019-09-30 19:02:33 -07:00
Jon Siwek
97519e4350 Merge remote-tracking branch 'origin/topic/timw/606-json-nulls'
* origin/topic/timw/606-json-nulls:
  GH-606: Output nulls into json data if a field isn't set
2019-09-30 17:40:27 -07:00
Jon Siwek
3d4fef012a Merge remote-tracking branch 'origin/topic/timw/598-multikey-set-json'
Adjustments:
- Changed a push_back(...) into emplace_back(std:move(...))
- Removed superfluous table Lookup() since we already have the value
  while iterating

* origin/topic/timw/598-multikey-set-json:
  GH-598: handle multi-key sets correctly when outputting json
2019-09-30 17:34:11 -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
756f363185 GH-598: handle multi-key sets correctly when outputting json 2019-09-27 12:01:47 -07:00
Tim Wojtulewicz
d4d1009b5c Use json::emplace to avoid some extra calls to operator[] 2019-09-27 09:58:24 -07:00
Tim Wojtulewicz
c8f2d52d91 Use tessil/unordered-map instead of nlohmann/fifo-map to mitigate performance issues when logging JSON 2019-09-25 16:21:38 -07:00
Jon Siwek
f287d9abe8 GH-589: improve printing of sub-microsecond intervals 2019-09-23 19:57:49 -07:00
Tim Wojtulewicz
53c82cc872 Remove dead check in Val::check_and_promote. (Coverity 1401810) 2019-09-16 10:56:41 -07:00
Tim Wojtulewicz
54752ef9a1 Deprecate the internal int/uint types in favor of the cstdint types they were based on 2019-08-12 13:50:07 -07:00
Jon Siwek
ec4df80c67 Improve error messages from to_addr and to_subnet BIFs
Related to GH-514
2019-08-01 10:49:03 -07:00
Robin Sommer
bae60aee31 Merge remote-tracking branch 'origin/topic/jsiwek/fix-expire-func-leaks'
* origin/topic/jsiwek/fix-expire-func-leaks:
  Fix memory leaks in expire_func introduced by recent changes
2019-07-30 18:12:58 +00:00
Robin Sommer
13c373086d Merge remote-tracking branch 'origin/topic/zeke/closures' 2019-07-30 02:32:34 +00:00
Jon Siwek
01611177f7 Fix memory leaks in expire_func introduced by recent changes 2019-07-29 18:07:35 -07:00
Zeke Medley
bdc8e0e6c4 Merge branch 'master' of https://github.com/zeek/zeek into topic/robin/closures-merge 2019-07-25 11:23:40 -07:00
Johanna Amann
ff4845aa80 Merge branch 'master' of github.com:zeek/zeek 2019-07-22 12:46:21 -07:00
Johanna Amann
3159577821 Merge remote-tracking branch 'origin/topic/zeke/expire-func'
* origin/topic/zeke/expire-func:
  Ignore abs-path in test.
  Report argument # type check failed on.
  Update test baseline.
  Improve func arg type checking.
  &expire_func(table, arg1, arg2, ...) + type checking.
2019-07-22 12:44:55 -07:00
Tim Wojtulewicz
6144f459e1 Mark List::append/insert deprecated in favor of push_back/push_front for consistency with Queue 2019-07-22 09:47:43 -07:00
Robin Sommer
1bf0cd29fd Edit pass over changes before merge. 2019-07-20 00:00:51 +00:00
Zeke Medley
0ca6b3e013 &expire_func(table, arg1, arg2, ...) + type checking. 2019-07-18 12:11:27 -07:00
Zeke Medley
1692be4c2d Fix bug in selective cloning. 2019-07-16 15:15:05 -07:00
Jon Siwek
8c45937798 Merge branch 'topic/jsiwek/template-containers-merge'
* topic/jsiwek/template-containers-merge:
  Fix a potential usage of List::remove_nth(-1)
  Change List::remote(const T&) to return a bool
  Fix debug build due to old int_list usage within assert
  Convert uses of loop_over_list to ranged-for loops
  Remove loop_over_queue (as an example for later removing loop_over_list)
  Change int_list in CCL.h to be a vector, fix uses of int_list to match
  Remove List<> usage from strings.bif
  Replace uses of the old Queue/PQueue generation code with new template versions
  Convert BaseQueue/Queue/PQueue into templates, including iterator support
  Replace uses of the old Dict generation code with new template versions
  Convert PDict into template
  Replace uses of the old List generation code with new template versions
  Convert BaseList/List/PList into templates, including iterator support

* Generally squashed fixups from topic/timw/template-containers

* Add missing include file in List.h: <cassert>
2019-07-15 19:51:27 -07:00
Tim Wojtulewicz
e51f02737b Convert uses of loop_over_list to ranged-for loops 2019-07-15 19:00:24 -07:00
Tim Wojtulewicz
50943a580c Replace uses of the old Dict generation code with new template versions 2019-07-15 18:54:07 -07:00
Tim Wojtulewicz
5d37428819 Fix a couple of resource leaks from JSON changes 2019-07-12 14:31:40 -07:00
Zeke Medley
8d9355eb51 Merge branch 'master' of https://github.com/zeek/zeek into topic/zeke/closures 2019-07-12 10:33:43 -07:00
Jon Siwek
e5e84041b7 Fix uncaught exceptions from Val cloning failures 2019-07-11 16:55:39 -07:00