Commit graph

6667 commits

Author SHA1 Message Date
Johanna Amann
d451fb8184 Merge branch 'topic/AbdelSaTd/case-insensitive-find'
* topic/AbdelSaTd/case-insensitive-find:
  testing-do-find-str_case-insensitive
  case-insensitive-search-features-for-do_find_str

I did a few small style-fixes while merging this and expanded the test
a bit. I also removed unecessary commits.

Closes GH-1828
2021-11-10 11:33:47 +00:00
Abdel
82b3606cdd case-insensitive-search-features-for-do_find_str 2021-11-10 11:25:20 +00:00
Robin Sommer
1bb21bfcb4 Merge remote-tracking branch 'origin/topic/robin/gh-1757-loadfile2'
* origin/topic/robin/gh-1757-loadfile2:
  Tweaking a couple of debug message.
  Add new hook `HookLoadFileExtended` that allows plugins to supply Zeek script code to parse.
  Move logic to execute `HookLoadFile` for signatures into rule matcher code.
2021-11-10 11:28:53 +01:00
Robin Sommer
64e34b52aa Tweaking a couple of debug message.
As suggested during review.
2021-11-10 09:39:16 +01:00
Benjamin Bannier
65bc817fcf Install include headers from src/3rdparty/.
This is a fixup commit for 72cbc7cd13
where we move some header files from `src/` to `src/3rdparty/` but
missed adding install rules for these header. Since some of these
headers are exposed in installed headers they need to be installed as
well.
2021-11-10 09:17:40 +01:00
Tim Wojtulewicz
0604df01e3 Merge remote-tracking branch 'origin/topic/bbannier/issue-1780'
* origin/topic/bbannier/issue-1780:
  Add Github action exercising pre-commit
  Add pre-commit config.
  Format code with `clang-format`
  Remove stale files `src/DebugCmdInfoConstants.*`
  Disable formatting for files in `testing/btest/plugins`
  Move 3rdparty source files to `3rdparty/`
2021-11-09 10:30:14 -07:00
Johanna Amann
a011b4cb70 Packets with TSO: address review feedback.
This addresses review feedback of GH-1831 and additionally fixes one
case in which PayloadLen was used in a way that would have given
problematic results when TSO is enabled.
2021-11-09 15:11:27 +00:00
Benjamin Bannier
4e16037acd Format code with clang-format
This patch formats files not conforming to the C++ formatting with
`clang-format`.
2021-11-09 07:20:18 +01:00
Benjamin Bannier
dafc9691c5 Remove stale files src/DebugCmdInfoConstants.*
The files generated from `src/DebugCmdInfoConstants.in` are placed in
`build/src/` by the build setup, and generated file in `src/` removed
here were unused and possibly out-of-date.
2021-11-09 07:20:18 +01:00
Benjamin Bannier
72cbc7cd13 Move 3rdparty source files to 3rdparty/
This patch moves in-tree 3rdparty source files to `3rdparty/`. With that
we can remove special treatment of these files for `run-clang-format`.
2021-11-09 07:20:18 +01:00
Tim Wojtulewicz
e0b116154a GH-1819: Handle recursive types when describing type in binary mode 2021-11-08 15:19:57 -07:00
Vern Paxson
55b2ce7dbc Merge branch 'topic/vern/CPP-speedup' of github.com:zeek/zeek into topic/vern/CPP-speedup 2021-11-07 17:56:26 -08:00
Vern Paxson
3ea362be91 fix for case-sensitive file systems 2021-11-07 17:54:56 -08:00
Vern Paxson
0bdc268a00 geez sometimes it's signed sometimes it's not 2021-11-07 17:49:30 -08:00
Vern Paxson
ab1a29184c documentation updates 2021-11-07 17:05:21 -08:00
Vern Paxson
bb618bae30 remove -O add-C++ and -O update-C++ options 2021-11-07 17:02:18 -08:00
Vern Paxson
e1a760e674 extensive rewrite of generation & execution of run-time initialization 2021-11-07 17:00:19 -08:00
Vern Paxson
bc3bf4ea6c factoring out CPPEscape to be a standalone function 2021-11-07 16:57:52 -08:00
Vern Paxson
14abfc6831 removing unused SubNetType class 2021-11-07 16:56:57 -08:00
Florian Wilkens
cc9e38f58b add missing call to EVP_KDF_CTX_set_params 2021-11-05 22:03:29 +01:00
Robin Sommer
34eaf42b92 Add new hook HookLoadFileExtended that allows plugins to supply Zeek script code to parse.
The new hooks works similar to the existing `HookLoadFile` but,
additionally, allows the plugin to return a string that contains the
code to be used for the file being loaded. If the plugin does so, the
content of any actual file on disk will be ignored (in fact, there
doesn't even need to be a file on disk in that case). This works for
both Zeek scripts and signatures.

There's a new test that covers the new functionality, testing loading
both scripts and signatures from memory. I also manually tested that the
debugger integration works, but I don't see much of a way to add a
regression test for that part.

We keep the existing hook as well for backwards compatibility. We could
decide to deprecate it, but not sure that buys us much, so left that
out.

Closes #1757.
2021-11-05 13:01:19 +01:00
Robin Sommer
1efaf8d7a4 Move logic to execute HookLoadFile for signatures into rule matcher code.
This (1) fixes an issue where signature files supplied on the command
line wouldn't pass through the hooks, and (2) prepares for allowing
hooks to supply the content of a signature file directly.
2021-11-05 12:58:38 +01:00
Yacin Nadji
96c45a6c93 Remove unused tbl 2021-11-03 15:44:55 -04:00
Yacin Nadji
aacb812b9a Fix C++ Intersection code 2021-11-03 14:26:31 -04:00
Tim Wojtulewicz
ceaec09024 GH-693: use pcap_dump_open_append where supported 2021-11-02 17:09:39 -07:00
Tim Wojtulewicz
b6444dce0c Fix issue with broken libpcaps that return repeat packets
This is apparently a problem with the Myricom version of libpcap, where
instead of returning a null or a zero if no packets are available, it
returns the previous packet. This causes Zeek to improperly parse the
packet and crash. We thought we had fixed this previously with a check
for a null packet but that fix was not enough.
2021-11-01 09:19:55 -07:00
Johanna Amann
e14b695497 Accept packets that use tcp segment offloading.
When checksum offloading is enabled, we now forward packets that
have 0 header lengths set - and assume that they have TSO enabled.

If checksum offloading is not enabled, we drop the packets.

Addresses GH-1829
2021-10-28 17:12:54 +02:00
Tim Wojtulewicz
e63ea95664 Apply some missing clang-format changes 2021-10-21 16:38:57 -07:00
Johanna Amann
fe4e06e8ca TLS decryption: remove payload from ssl_encrypted_data again.
There is no reason to make the payload available in the event - it is
still encrypted.
2021-10-19 17:36:48 +02:00
Johanna Amann
303e84ad86 Merge branch 'master' of https://github.com/FlyingWithJerome/zeek
Merge includes small changes, e.g. fixing the comsumption of remaining
raw data.

* 'master' of https://github.com/FlyingWithJerome/zeek:
  remove excussive fields in dns_svcb_rr
  address code reviews (formatting and type and intrusiveptr)
  newlines at the end of test outputs
  lazy commit
  use tabs in init-bare.zeek
  add svcb test case
  add a dns https test case
  remove test logs
  fix a few syntax errors
  initial commit for SVCB/HTTPS records
2021-10-19 15:03:08 +02:00
Johanna Amann
1b3b9a3cfc Merge branch 'fsync-shadow-files-before-rename' of https://github.com/awelzel/zeek
* 'fsync-shadow-files-before-rename' of https://github.com/awelzel/zeek:
  logging/writers/ascii: shadow files: Add fsync() before rename()
2021-10-15 09:47:08 +01:00
Johanna Amann
eabb6eb743 TLS 1.2 decryption: adapt OpenSSL 3.0 changes for 1.1
Now this should compile and work with both OpenSSL 3 and OpenSSL 1.1.
2021-10-15 09:13:31 +01:00
Tim Wojtulewicz
59013dedcf Fix typo in typedef changes that broke tests on 32-bit Debian 9 2021-10-14 13:09:54 -07:00
Florian Wilkens
8393868207 ssl: adapt TLS-PRF to openSSL 3.0 2021-10-14 17:45:41 +02:00
Arne Welzel
dc6e21d6ae logging/writers/ascii: shadow files: Add fsync() before rename()
We're using shadow files for log rotation on systems with ext4 running
Linux 4.19. We've observed zero-length shadow files in the logger's working
directory after a power-outage. This leads to a broken/stuck logger
process due to empty shadow files being considered invalid and the
process exiting:

    error: failed to process leftover log 'conn.log.gz': Found leftover log, 'conn.log.gz', but the associated shadow  file, '.shadow.conn.log.gz', required to process it is invalid

PR #1137 introduced atomic renaming of shadow files and was supposed to
handle this. However, after more investigation, the rename() has to be
preceded by an fsync() in order to avoid zero-length files in the presence
of hard-crashes or power-failures. This is generally operating system
and filesystem dependent, but should not hurt to add. The performance impact
can likely be neglected due to the low frequency and limited number of
log streams.

This has happened to others, too. Some references around this issue:

* https://stackoverflow.com/questions/7433057/is-rename-without-fsync-safe
* https://unix.stackexchange.com/questions/464382/which-filesystems-require-fsync-for-crash-safety-when-replacing-an-existing-fi
* https://bugzilla.kernel.org/show_bug.cgi?id=15910

Reproducer

This issue was reproduced artificially on Linux using the sysrq-trigger
functionality to hard-reset the system shortly after a .shadow file was
renamed to it's final destination with the following script watching for
.shadow.conn.log.gz:

    #!/bin/bash
    set -eu
    dir=/data/logger-01/

    # Allow everything via /proc/sysrq-trigger
    echo "1" > /proc/sys/kernel/sysrq

    inotifywait -m -e MOVED_TO --format '%e %w%f' "${dir}" | while read -r line; do
        if echo "${line}" | grep -q '^MOVED_TO .*/.shadow.conn.log.gz$'; then
            echo "RESET: $line"
            sleep 4
            # Trigger a hard-reset without sync/unmount
            echo "b" > /proc/sysrq-trigger
        fi
    done

This quite reliably (4 out of 4 times) yielded a system with zero-length
shadow files and a broken logger after it came back online:

    $ ls -lha /data/logger-01/.shadow.*
    -rw-r--r-- 1 bro bro 0 Oct 14 02:26 .shadow.conn.log.gz
    -rw-r--r-- 1 bro bro 0 Oct 14 02:26 .shadow.dns.log.gz
    -rw-r--r-- 1 bro bro 0 Oct 14 02:26 .shadow.files.log.gz

After this change while running the reproducer, the shadow files always
contained content after a hard-reset.

Rework with util::safe_fsync helper
2021-10-14 15:54:45 +02:00
Johanna Amann
b8b6ac744e Merge remote-tracking branch 'origin/master' into topic/johanna/tls12-decryption 2021-10-13 10:49:29 +01:00
FlyingWithJerome
605d4024e4 remove excussive fields in dns_svcb_rr 2021-10-12 21:40:56 -04:00
FlyingWithJerome
c957e3e91e address code reviews (formatting and type and intrusiveptr) 2021-10-12 20:36:35 -04:00
FlyingWithJerome
b238cf3dca lazy commit 2021-10-12 17:43:32 -04:00
FlyingWithJerome
ca4b181d35 add a dns https test case 2021-10-12 17:43:32 -04:00
FlyingWithJerome
0849332eb9 fix a few syntax errors 2021-10-12 17:43:32 -04:00
FlyingWithJerome
8fce51bf83 initial commit for SVCB/HTTPS records 2021-10-12 17:43:32 -04:00
Tim Wojtulewicz
64748edab1 Replace most uses of typedef with using for type aliasing 2021-10-11 14:51:10 -07:00
Christian Kreibich
175d9297e3 Expression tweaks to get complex types to work as container indices 2021-10-01 14:03:08 -07:00
Tim Wojtulewicz
9af6b2f48d clang-format: Set penalty for breaking after assignment operator 2021-09-27 10:49:48 -07:00
Tim Wojtulewicz
4423574d26 clang-format: Set IndentCaseBlocks to false 2021-09-27 10:49:48 -07:00
Tim Wojtulewicz
02206f3215 clang-format: Other minor formatting changes 2021-09-27 10:49:48 -07:00
Tim Wojtulewicz
e97c14add5 clang-format: Other include ordering changes 2021-09-27 10:49:48 -07:00
Tim Wojtulewicz
cb99ae2b7c clang-format: Enforce ordering of includes in ZBody 2021-09-25 11:52:55 -07:00
Tim Wojtulewicz
07e276ab2e clang-format: A few minor comment-spacing fixes 2021-09-25 11:52:55 -07:00