Commit graph

3749 commits

Author SHA1 Message Date
Vern Paxson
db7f88e661 new "-a cpp" btest alternative 2021-05-05 16:55:04 -07:00
Vern Paxson
24e92fa54a hooks for activating the compiler & associated BiF 2021-05-05 16:55:04 -07:00
Jon Siwek
9e8eb30620 Add missing zeek/ prefix to a telemetry header's includes 2021-04-30 18:29:34 -07:00
Tim Wojtulewicz
72ba93d9a3 Merge remote-tracking branch 'origin/topic/jsiwek/gh-1534-better-duplicate-enum-error'
* origin/topic/jsiwek/gh-1534-better-duplicate-enum-error:
  GH-1534: Fix excessive coredump for duplicate enum definitions
2021-04-30 09:42:40 -07:00
Tim Wojtulewicz
ad67d810be Merge remote-tracking branch 'origin/topic/jsiwek/fix-netbios-decode-bifs'
* origin/topic/jsiwek/fix-netbios-decode-bifs:
  Fixes to `decode_netbios_name` and `decode_netbios_name_type` BIFs
2021-04-30 09:40:46 -07:00
Jon Siwek
13f3cb377f GH-1534: Fix excessive coredump for duplicate enum definitions
An adequate error message was previously reported for duplicate enum
definitions, this just now prevents trying to access it as a constant in
subsequent parsing and further generating a coredump.
2021-04-29 15:20:09 -07:00
Tim Wojtulewicz
0b7ca5e7bc Remove Session prefix from some session-related classes and files 2021-04-29 11:09:35 -07:00
Tim Wojtulewicz
18c6aaaa33 Move session code into new directory and into zeek::session namespace 2021-04-29 11:09:35 -07:00
Tim Wojtulewicz
db1d753b35 Rename NetSessions to SessionManager
This also includes:
- Deprecating the NetSessions name.
- Renaming the zeek::sessions global to zeek::session_mgr and deprecating the old name.
- Renaming Sessions.{h,cc} to SessionManager.{h,cc}.
2021-04-29 10:24:45 -07:00
Tim Wojtulewicz
f7e3556a67 Store a single map of Sessions instead of split maps of Connections.
This commit also includes:
- Storing the transport protocol in ConnID and ConnIDKey to allow tcp and
  udp connections from the same IP/Port combinations. This happens in the
  core.cisco-fabric-path test, for example.
- Lots of test updates. The reasons for these are two fold. First, with
  the change to only store a single map means that TCP, UDP, and ICMP
  connections are now mixed. When Zeek drains the map at shutdown, it drains
  each of those protocols together instead of separately. The second is
  because of how Sessions are stored in the map. We're now storing them
  keyed by the hash of the key stored by the Session objects, which causes
  them to again be in the map in a different order.
2021-04-29 10:24:45 -07:00
Tim Wojtulewicz
114077fd93 Add test for get_conn_stats BIF before reworking session stats 2021-04-29 10:24:45 -07:00
Tim Wojtulewicz
14ffd9646f Merge remote-tracking branch 'origin/topic/bbannier/issue-1517'
* origin/topic/bbannier/issue-1517:
  Add basic testing for Geneve protocol analyzer
  GH-1517: Add Geneve decap support
2021-04-29 09:01:11 -07:00
Jon Siwek
76fb1e7fd0 Fixes to decode_netbios_name and decode_netbios_name_type BIFs
Fixes to `decode_netbios_name`:

* Improve validation that input string is a NetBIOS encoding
  (32 bytes, with characters ranging from 'A' to 'P').  This helps
  prevent Undefined Behavior of left-shifting negative values.
  Invalid encodings now cause a return-value of an empty string.

* More liberal in what decoded characters are allowed.  Namely,
  spaces are now allowed (but any trailing null-bytes and spaces
  are trimmed, similar to before).

Fixes to `decode_netbios_name_type`:

* Improve validation that input string is a NetBIOS encoding
  (32 bytes, with characters ranging from 'A' to 'P').  This helps
  prevent Undefined Behavior of left-shifting negative values and
  a heap-buffer-overread when the input string is too small.
  Invalid encodings now cause a return-value of 256.
2021-04-27 15:27:04 -07:00
Benjamin Bannier
83ecbeea6d Add basic testing for Geneve protocol analyzer
The added pcap file was downloaded from an attachment to
https://gitlab.com/wireshark/wireshark/-/issues/10193 without explicit
license.
2021-04-27 11:21:29 +02:00
Benjamin Bannier
5b2bf374fd GH-1517: Add Geneve decap support
This patch adds the ability to decap Geneve packets to process the inner
payload. The structure of the analyzer borrows heavily from the VXLAN
analyzer.
2021-04-27 11:21:29 +02:00
Jon Siwek
d51bd4bc46 Fix using clear_table() within an &expire_func
This previously crashed since clear_table()/TableVal::RemoveAll() left
behind a stale iterator to the old table causing a heap-use-after-free
when resuming table expiry iteration in TableVal::DoExpire().
2021-04-26 22:49:44 -07:00
Vlad Grigorescu
ac720a1313 Add tests for e-mail actions, and cleanup the new logic a bit. 2021-04-26 23:01:34 -05:00
Jon Siwek
b44ae62ce4 Merge remote-tracking branch 'origin/topic/jsiwek/gh-1483-mismatch-ctor-init-errors'
* origin/topic/jsiwek/gh-1483-mismatch-ctor-init-errors:
  GH-1483: Improve error for mismatched container initialization types
2021-04-26 11:15:34 -07:00
Tim Wojtulewicz
f4fe068882 Update btest baselines for --enable-mobile-ipv6 builds 2021-04-22 18:20:53 -07:00
Jon Siwek
486f187b15 GH-1483: Improve error for mismatched container initialization types
For example, trying to assign a vector, table, set, or record
constructor expression to a global variable of a different type now
provides a more explanatory error message than the previous
"Val::CONVERTER" fatal-error and coredump.
2021-04-20 19:14:13 -07:00
Jon Siwek
e8247c2472 Merge remote-tracking branch 'origin/topic/vern/vector-holes'
* origin/topic/vern/vector-holes:
  Remove NEWS entry regarding changed vector-holes functionality
  Fix potential segfaults in VectorVal Insert/Remove methods
  Fix copy() to work with a vector that has trailing holes
  update test suite for vector holes now being supported for numeric types
  add vector tests for creating holes, "in" operator, "?" operator, copying vectors with holes
  restore support for vectors with holes remove vestigial comment
  fix using ++/-- to vectors that contain holes
2021-04-20 14:43:01 -07:00
Jon Siwek
fd5cdbbe50 Fix potential segfaults in VectorVal Insert/Remove methods
The existence/hole check for managed types was needed to prevent
accessing a nil-optional value.
2021-04-19 19:29:37 -07:00
Jon Siwek
819fc1aac0 Fix copy() to work with a vector that has trailing holes
Previously, the trailing holes would not be preserved in the copy.
2021-04-19 19:23:04 -07:00
Florian Wilkens
2d950ffde9 ssl: rudimentary decryption for TLS 1.2
Several limitations still apply:
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 is the only supported cipher suite
- Some tests are broken due to a failing assertion regarding bytestring
- No newly written tests for decryption (the patch was tested extensively for our paper)
- Several small open technical questions marked with FIXME
- Architecture in the ssl module might not be optimal
2021-04-19 17:38:02 +02:00
Jon Siwek
f176da200e Merge remote-tracking branch 'origin/topic/jsiwek/gh-1506-fix-broker-func-indices'
- Extended a btest to cover tables/sets with index types
  (this was originally broken until fixed by GH-1514)

* origin/topic/jsiwek/gh-1506-fix-broker-func-indices:
  GH-1506: Fix Broker unserialization of set/table function indices
2021-04-16 16:03:29 -07:00
Tim Wojtulewicz
df22bdd52e Merge remote-tracking branch 'origin/topic/timw/1487-not-valid-enum'
* origin/topic/timw/1487-not-valid-enum:
  Move an assert() in input/Manager.cc to account for ValueToVal errors
  Add test for config framework
  Fix similar issues with ValueTo* methods in the input framework
  GH-1487: Handle error from ValueToVal instead of ignoring it
2021-04-16 08:08:59 -07:00
Jon Siwek
846cc53780 Merge remote-tracking branch 'origin/topic/jsiwek/fix-table-vector-index'
* origin/topic/jsiwek/fix-table-vector-index:
  Fix indexing of set/table types with a vector
2021-04-15 17:59:31 -07:00
Jon Siwek
7d0d57d33b Merge remote-tracking branch 'origin/topic/jsiwek/gh-1507-sip-junk'
* origin/topic/jsiwek/gh-1507-sip-junk:
  GH-1507: Tolerate junk data before SIP requests
2021-04-15 17:43:51 -07:00
Jon Siwek
df9b57118d Merge remote-tracking branch 'origin/topic/jsiwek/gh-1503-improve-expire-func-type-check'
* origin/topic/jsiwek/gh-1503-improve-expire-func-type-check:
  Extend language.expire-func-type-check btest
  GH-1503: Improve &expire_func compatibility type-checking
2021-04-15 17:42:33 -07:00
Jon Siwek
05b992b865 Extend language.expire-func-type-check btest
Now covers more forms of both valid and invalid &expire_funcs
2021-04-15 16:13:35 -07:00
Jon Siwek
d3ace9b7ac GH-1506: Fix Broker unserialization of set/table function indices
Zeek function types are serialized as a broker::vector, but the
unserialization logic for Zeek set/table types that use a function for
as an index incorrectly identified it as a composite-index, which also
use broker::vector, rather than a singleton-index, and makes such
unserialization fail.

A general example where this failure can happen in practice is when
trying to unserialize a connection record for which there's a
Conn::RemovalHook, since that's a set[function], and a specific case of
that is use of the Intel Framework in a Zeek cluster.
2021-04-15 01:13:51 -07:00
Jon Siwek
735ac0b4fa Fix indexing of set/table types with a vector
Previous behavor:

  internal error: bad index type in CompositeHash::ComputeSingletonHash
  Aborted (core dumped)
2021-04-14 21:58:14 -07:00
Vern Paxson
d00748a2e7 update test suite for vector holes now being supported for numeric types 2021-04-14 18:19:26 -07:00
Vern Paxson
e96b29d4d8 add vector tests for creating holes, "in" operator, "?" operator, copying vectors with holes 2021-04-14 18:19:13 -07:00
Tim Wojtulewicz
fc3438bda5 Merge remote-tracking branch 'origin/topic/jsiwek/gh-1450-large-double-format'
* origin/topic/jsiwek/gh-1450-large-double-format:
  GH-1450: Improve printing/logging of large double/interval/time values
2021-04-14 16:06:11 -07:00
Jon Siwek
183789294f GH-1507: Tolerate junk data before SIP requests
This allows for data that won't match a SIP request method to precede an
actual request and generates a new 'sip_junk_before_request' weird when
encountering such a situation.
2021-04-14 15:34:07 -07:00
Jon Siwek
01f6264c87 GH-1503: Improve &expire_func compatibility type-checking
Previously, incompatible &expire_funcs could mistakenly be used, such as
when using that attribute on the unspecified table()/set()
initializations/assignments, resulting in invalid function calls that
eventually crash Zeek.
2021-04-12 16:27:50 -07:00
Jon Siwek
952d8de8fd Add btest for unterminated pattern parsing error behavior
And clarified the error message that it's more about finding an
unterminated pattern than knowing for sure there's remaining pattern
text spanning multiple lines.
2021-04-09 11:15:06 -07:00
Jon Siwek
312547ab0a GH-1497: Support CRLF line-endings in Zeek scripts and signature files 2021-04-08 20:32:30 -07:00
Tim Wojtulewicz
e5d3d009fc Add test for config framework 2021-04-08 14:07:40 -07:00
Tim Wojtulewicz
04c201393f Fix similar issues with ValueTo* methods in the input framework 2021-04-08 14:07:16 -07:00
Jon Siwek
cc15c985ca GH-1450: Improve printing/logging of large double/interval/time values
The modp_dtoa/modp_dtoa2 functions aren't capable of handling double
values larger than INT_MAX and fallback on using sprintf() in that
situation.  Previously, the format string to that sprintf() was "%e",
defaulting to a precision of 6, which is already too few digits to
represent a number known to be larger than INT_MAX.  Now, an sprintf()
is still performed for values larger than INT_MAX and still uses a
scientific notation format, but in a way that uses as many decimal
digits as needed to preserve information.
2021-04-06 19:54:02 -07:00
Jon Siwek
cd8f19328a Merge remote-tracking branch 'origin/topic/neverlord/gh-1408'
- Minor adjustments to header includes, whitespace, and a
  compiler warning fix during merge

* origin/topic/neverlord/gh-1408:
  Add new Timer class to the telemetry API
  Fix build with latest VectorVal API
  Update baselines
  Prefix telemetry BIFs with __
  Expose telemetry API to scripting land
  Add handle types for histogram metrics
  Move duplicated code to detail header
  Adhere to Zeek coding style
  Apply suggestions from code review
  Add telemetry Manager to Zeek setup / teardown
  Add missing whitespaces for Zeek coding style
  Add gauge metric types
  Add scaffold for new metrics API with counters
2021-04-05 14:21:44 -07:00
Jon Siwek
e6955d55dd Increase timeout of plugins.reader btest 2021-04-03 09:40:45 -07:00
Jon Siwek
3e9ac00f21 Separate stdout from stderr in btest baselines
Redirecting both to the same file can show platform-specific differences
(e.g. Alpine), likely due to different buffering defaults.
2021-03-30 16:23:23 -07:00
Jon Siwek
8e47494dff Remove newline-eof canonification attempt in diff-remove-timestamps
On Alpine (BusyBox `sed`), the previous `sed -e '$a\'` invocation always
added a newline, breaking most every diff.  There doesn't seem to be a
need to attempt normalizing EOF newlines at the moment and doing it that
way doesn't seem to be portable anyway.  If canonifiers need to be
portable, `sed` should be treated as a text-processing tool and POSIX
definition of text-file is zero or more newline-terminated
character-sequences, so if canonification of Baselines via `sed` is
required, those Baselines should always end with a newline to be
considered text files.  I.e. that's not the job of this canonifier, and
changing it also doesn't necessarily generalize since it could be
considered coincidental that diff-remove-timestamps in particular is the
default canonifier that's commonly used while there's still others that
also make use of `sed`.
2021-03-30 16:04:34 -07:00
Jon Siwek
c033bd20aa Merge remote-tracking branch 'origin/topic/vern/global-stmts'
* origin/topic/vern/global-stmts:
  whitespace adjustment
  "balance" tests with multiple Zeek scripts to load the same elements
  put global statements into a quasi-function to support script optimization
2021-03-29 15:42:43 -07:00
Dominik Charousset
600d1118cd Update baselines 2021-03-29 10:47:32 +02:00
Dominik Charousset
e476911075 Prefix telemetry BIFs with __ 2021-03-29 10:47:32 +02:00
Dominik Charousset
2bac354e43 Expose telemetry API to scripting land 2021-03-29 10:47:32 +02:00