Commit graph

6667 commits

Author SHA1 Message Date
Vern Paxson
074b18f3e8 tracking of optimization information associated with expressions 2021-09-08 10:23:38 -07:00
Vern Paxson
3ac725f44b tracking of optimization information associated with statements 2021-09-08 10:23:38 -07:00
Vern Paxson
ed3c87d253 simple AST optimization for ?: operator 2021-09-08 10:23:38 -07:00
Vern Paxson
fb101f7b0e track implicit assignments when profiling, associate counts with assignees 2021-09-08 10:23:38 -07:00
Vern Paxson
dbb509448f preparing for a new Stmt subclass for ZAM function bodies 2021-09-08 10:23:38 -07:00
Vern Paxson
51fee244c9 provide ZAM execution with direct access to ZVal elements 2021-09-08 10:23:38 -07:00
Vern Paxson
9f68002392 factoring to support debugging of Dict iterators - no semantic changes 2021-09-08 10:23:38 -07:00
Vern Paxson
b4a44ed663 low-level tidying/nits - no semantic changes 2021-09-08 10:23:38 -07:00
Vern Paxson
4c80bd6782 fix for looping over vectors with holes per https://github.com/zeek/zeek/issues/1763 2021-09-07 10:26:42 -07:00
Tim Wojtulewicz
58cb9163d1 Fix mis-usage of string::append that leads to an overflow 2021-09-07 09:16:53 -07:00
Tim Wojtulewicz
404fed6923 Use json_escape_utf8 for all utf8 data in ODesc 2021-09-07 09:16:53 -07:00
Tim Wojtulewicz
a54ffd18f3 Merge remote-tracking branch 'origin/topic/vlad/snmp_asn1_oid_performance'
* origin/topic/vlad/snmp_asn1_oid_performance:
  Code modernization: use ranged-based for loop where possible
  Improve performance of asn1_oid_to_val string conversions.
2021-09-03 18:11:01 +00:00
Tim Wojtulewicz
4dc20826fd Mark MsgThread::cnt_sent_{in,out} as atomic to avoid a data race 2021-09-03 10:38:15 -07:00
Tim Wojtulewicz
a2ab1b1484 Disable call to sqlite3_enable_shared_cache under ThreadSanitizer
See https://sqlite.org/forum/forumpost/54424d80ee for details.
2021-09-03 10:38:15 -07:00
Robin Sommer
6997f83e57 Merge remote-tracking branch 'origin/topic/johanna/gh-1709'
* origin/topic/johanna/gh-1709:
  Fix signed integer overflow in PIA on big sequence number holes
2021-08-31 15:58:48 +02:00
Vlad Grigorescu
6082ab23d9 Code modernization: use ranged-based for loop where possible 2021-08-30 18:34:22 -05:00
Vlad Grigorescu
a357c609b0 Improve performance of asn1_oid_to_val string conversions. 2021-08-30 16:42:50 -05:00
Benjamin Bannier
ebe285f591 Allow -B flag in non-Debug builds, but ignore it.
The `-B` flag allows to enable debug streams in Debug builds. We
previously didn't support passing the flag for other builds. With that
whether an invocation of `zeek` executed or not depended on the way zeek
was built.

With this patch we accept and parse the flag when passed in the
invocation, but ignore any requests for actual debug streams in
non-Debug builds (no streams are available). If `-B help` is passed we
emit a message and abort.
2021-08-27 13:52:50 +02:00
Johanna Amann
f6fe613c61 Fix signed integer overflow in PIA on big sequence number holes
This patch fixes a signed integer overflow in PIA. When starting a
connection, and then ack-ing ~0x7FFFFFFF (INT32_MAX) bytes, the integer
holding the size of buffered bytes will overflow.

This change simply switches that count to only count bytes that were
actually seen on the wire. In my opinion, this is actually the desired
beavior here - the size is only used to decide if buffering should be
continued, as well as for the output of some debug messages (which, in
my opinion, so far is wrong if there are TCP holes).

This fixes GH-1709. Please see that ticket for more discussion.
2021-08-26 14:06:12 +01:00
Christian Kreibich
66e71c7fd2 Remove unneccessary >= 0 check in a UTF32 comparison
Resolves Coverity CID 1461523.
2021-08-25 14:13:17 -07:00
Christian Kreibich
ddbba17e57 Trivial signedness warning fix 2021-08-25 13:45:19 -07:00
Christian Kreibich
2bcaa33563 Merge branch 'topic/christian/gh-1731-broker-peers-bug'
* topic/christian/gh-1731-broker-peers-bug:
  Fix addr/string type confusion in Broker::peers()
2021-08-19 15:13:37 -07:00
Tim Wojtulewicz
f442893c98 Return fully-escaped string if utf8 conversion fails
This adds a new function for validating UTF-8 sequences by converting to
UTF-32. This allows us to also check for various blocks of codepointsi
that we consider invalid while checking for valid sequences in general.
2021-08-19 08:56:27 -07:00
Christian Kreibich
fa38d81a7b Fix addr/string type confusion in Broker::peers()
Broker::NetworkInfo$address is of type string. The Broker::peers() BiF treated
it as an address, which caused ZVal's type validation to flag a
mismatch and abort.

Includes a small tweak to the broker.unpeer test that makes it invoke
Broker::peers(), which breaks in absence of the fix.
2021-08-18 15:16:58 -07:00
Benjamin Bannier
28e8abbf19 Fix option length computation in Geneve analyzer.
We previously computed the length of the Geneve options field
incorrectly which lead to us passing data at an incorrect offset to
inner analyzers. With this patch we now interpret the length field
correctly, according the the spec
https://datatracker.ietf.org/doc/html/rfc8926#section-3.4.

Closes #1726.
2021-08-18 09:19:49 +02:00
Tim Wojtulewicz
9c29c8ddfc GH-1713: Avoid unneeded reallocs in SerializationFormat::WriteData 2021-08-11 15:40:09 -07:00
Johanna Amann
8192ad581d Do not lookup ignore_checksums_nets for every packet
This could lead to a noticeable (single-percent) performance
improvement.

Most of the functionality for this is in the packet analyzers that now
cache ignore_chesksums_nets.

Based on a patch by Arne Welzel (Corelight).
2021-08-06 10:32:53 +01:00
Johanna Amann
d24cecf268 Merge remote-tracking branch 'origin/topic/timw/sessions-unordered-map'
* origin/topic/timw/sessions-unordered-map:
  Only sort sessions during Drain() if a random seed is set
  Use unordered_map to store sessions for performance reasons
2021-08-04 10:01:37 +01:00
Tim Wojtulewicz
201617540d Only sort sessions during Drain() if a random seed is set 2021-08-03 10:07:47 -07:00
Johanna Amann
ec6b954499 Merge branch 'master' of https://github.com/sowmyaramapatruni/zeek
Fixes GH-1689

* 'master' of https://github.com/sowmyaramapatruni/zeek:
  Fix issue-1689
2021-08-03 10:25:26 +01:00
Johanna Amann
8b506ca113 Merge branch 'topic/jgvt/issue-1598' of https://github.com/ThalesGroup/zeek
* 'topic/jgvt/issue-1598' of https://github.com/ThalesGroup/zeek:
  Fix when HTTP header are on several packet
  Fix HTTP evasion     - Happen when there is no CRLF at the end of HTTP     - Fix by adding CRLF when packet is complete (in relation to content-length in header)
2021-08-03 10:21:41 +01:00
Sowmya Ramapatruni
58fae22708 Fix issue-1689 2021-08-02 13:52:43 -07:00
Tim Wojtulewicz
d343dbbd76 Merge remote-tracking branch 'origin/topic/timw/patricia-rebase'
* origin/topic/timw/patricia-rebase:
  Fix failing test due to patricia change
  Rebase patricia code on upstream version
2021-08-02 11:10:15 -07:00
Tim Wojtulewicz
e2dc6df8a2 Use unordered_map to store sessions for performance reasons 2021-07-29 13:26:46 -07:00
Tim Wojtulewicz
b5841d0ab8 GH-1692: Add some safety to ASN's binary_to_int64 to avoid bad shifts 2021-07-29 10:11:50 -07:00
Tim Wojtulewicz
cea9194650 Fix a use-after-free during shutdown 2021-07-26 14:26:22 -07:00
Tim Wojtulewicz
41273afad8 GH-1693: Fix potential crash with elements being modified during robust iteration 2021-07-26 11:22:38 -07:00
jerome Grandvalet
83f4903250 Fix when HTTP header are on several packet 2021-07-26 15:58:14 +02:00
Tim Wojtulewicz
802dfd80c1 Fix failing test due to patricia change 2021-07-23 12:26:09 -07:00
Tim Wojtulewicz
083e0c5bdc Rebase patricia code on upstream version 2021-07-23 09:57:58 -07:00
jerome Grandvalet
8cabecec40 Fix HTTP evasion
- Happen when there is no CRLF at the end of HTTP
    - Fix by adding CRLF when packet is complete (in relation to content-length in header)
2021-07-23 09:28:29 +02:00
Tim Wojtulewicz
5fab986ccb GH-1684: Ensure that the time gets updated every pass if we're reading live traffic
This is necessary for e.g. packet sources that don't have a selectable
file descriptor. They'll always be ready on a very short timeout, but
won't necessarily have a packet to process. In these case, sometimes
the time won't get updated for a long time and timers don't function
correctly.
2021-07-22 14:08:21 -07:00
Johanna Amann
13cfa4c938 Fix handling of timers when cloning TableVals
When cloning TableVals, a new timer was created for the wrong object
(the existing TableVal, not the clone). This lead to the already
existing timer being no longer accessible. Which, in turn, leads to an
abandoned timer reading into no longer allocated data when the original
TableVal is deleted.

Fixes GH-1687
2021-07-21 12:52:22 +01:00
Tim Wojtulewicz
58a5118149 Merge remote-tracking branch 'origin/topic/robin/update-doctest'
* origin/topic/robin/update-doctest:
  Update 3rdparty submodule to pull in doctest to 2.4.6.
2021-07-19 08:55:19 -07:00
Robin Sommer
bb59e7e0c8 Update 3rdparty submodule to pull in doctest to 2.4.6.
Our old version didn't support compilation on Apple's M1 yet.
2021-07-18 10:07:01 +02:00
Robin Sommer
a7343ee019 Fix registration of protocol analyzers from inside plugins.
With the recent packet manager work, it broke to register a protocol
analyzer for a specific port from inside a plugin's initialization code.
That's because that registration now depends on the packet manager being
set up, which isn't case at that time a plugin's `InitPostInit()` runs.
This fix contains two parts:

    - Initialize the packet manager before the analyzer manager, so that
      the latter's `InitPostScript()` can rely on the former being
      ready.

    - Change the analyzer manager to (only) record port registrations
      happening before it's fully initialized. Its `InitPostScript()`
      then performs the actual registrations, knowing it can use the
      packet manager now.

This comes with a `cmake/` to add a missing include directory.
2021-07-18 10:00:49 +02:00
Vlad Grigorescu
5e021f7d3c Add a TODO to return a correct status for ParseRR_WKS 2021-07-15 13:03:38 -05:00
Vlad Grigorescu
5f3fa57298 Remove unnecessary if 2021-07-15 13:02:23 -05:00
Vlad Grigorescu
8b4c2a88a5 Generate dns_WKS_reply event 2021-07-15 10:11:48 -05:00
Vlad Grigorescu
15b294098c dns_HINFO_reply event was never being generated.
On top of that, I modified the event to pass the relevant fields from the DNS message.
2021-07-15 09:56:38 -05:00