Commit graph

4897 commits

Author SHA1 Message Date
Vern Paxson
56300db4a6 mark a couple of new BTests as not apt for -O gen-C++ 2024-08-13 13:15:16 -07:00
Arne Welzel
159f40a4bf Merge remote-tracking branch 'upstream/topic/awelzel/3774-skip-script-args-test-under-tsan'
* upstream/topic/awelzel/3774-skip-script-args-test-under-tsan:
  btest: Skip core.script-args under TSAN
2024-08-08 18:53:23 +02:00
Arne Welzel
3e6511af41 btest: Skip core.script-args under TSAN
TSAN may re-execute the executable when the memory layout doesn't
fullfill requirements, causing argument confusion when that happens.

Closes #3774.
2024-08-08 15:32:20 +02:00
Tim Wojtulewicz
15d404dd19 Remove deprecated port/ports fields for spicy analyzers 2024-08-07 11:58:22 -07:00
Tim Wojtulewicz
4e9d843cec Remove deprecated Cluster::Node::interface field 2024-08-07 11:58:22 -07:00
Tim Wojtulewicz
9142a48725 Remove deprecated signature definition format 2024-08-07 11:58:22 -07:00
Tim Wojtulewicz
2d68b1d834 Return an error if GLOBAL:: prefix is used 2024-08-07 11:58:22 -07:00
Tim Wojtulewicz
7a5b29ea81 Remove deprecated load-balacing policy script 2024-08-07 11:58:21 -07:00
Tim Wojtulewicz
1d0f01d6bc Remove deprecated prometheus telemetry policy script 2024-08-07 11:58:21 -07:00
Tim Wojtulewicz
85b4dc773e Remove deprecated policy/tuning/default package 2024-08-07 11:58:21 -07:00
Tim Wojtulewicz
a716903f3a Remove deprecated time machine settings 2024-08-07 11:58:21 -07:00
Tim Wojtulewicz
401a074036 Remove deprecated modbus event definitions 2024-08-07 11:58:21 -07:00
Tim Wojtulewicz
e2b03681d1 Remove EventRegistry::Used and EventRegistry::SetUsed 2024-08-07 11:58:21 -07:00
Arne Welzel
11bc233f45 coverage/lcov_html: Ignore testing/btest/.tmp
gcda/gcno files in the btest/.tmp directory are from .htlo files
referencing ephemeral cc files. No need to include these.
2024-08-06 18:20:09 +02:00
Arne Welzel
bae15230bb btest/spicy: Make replaces-conflicts trigger replaces code path
The current test attempts to instantiate two spicy::SSH_1 protocol
analyzers in the .evt file. The intention likely was to use two
distinct protocol analyzer both trying to replace the builtin SSH
analyzer.

Coincidentally, fixing this happens to workaround TSAN errors tickled
by the FatalError() call while loading the .hlto with two identically
named analyzers.

    $ cat .tmp/spicy.replaces-conflicts/output
    error: redefinition of protocol analyzer spicy::SSH_1
    ThreadSanitizer: main thread finished with ignores enabled
      One of the following ignores was not ended (in order of probability)
      Ignore was enabled at:
        #0 __llvm_gcov_init __linker___d192e45c25d5ee23-484d3e0fc2caf5b4.cc (ssh.hlto+0x34036) (BuildId: 091934ca4da885e7)
        #1 __llvm_gcov_init __linker___d192e45c25d5ee23-484d3e0fc2caf5b4.cc (ssh.hlto+0x34036) (BuildId: 091934ca4da885e7)
        ...

I was tempted to replace FatalError() with Error() and rely on
zeek-setup.cc's early exiting on any reporter errors, but this
seems easier for now.

Relates to #3865.
2024-08-06 11:52:52 +02:00
Tim Wojtulewicz
a81f6ab9a6 Add extra metrics to session_mgr
- Sessions killed by activity
- Current number of sessions across all types
2024-08-05 13:21:44 -07:00
Tim Wojtulewicz
7ac7ce1d2b Process metric callbacks from the main-loop thread
This avoids the callbacks from being processed on the worker thread
spawned by Civetweb. It fixes data race issues with lookups involving
global variables, amongst other threading issues.
2024-08-02 15:30:47 -07:00
Arne Welzel
02e3d30227 ldap: Recognize SASL+SPNEGO+NTLMSSP
The ctu-sme-11-win7ad-1-ldap-tcp-50041.pcap file was harvested
from the CTU-SME-11 (Experiment-VM-Microsoft-Windows7AD-1) dataset
at https://zenodo.org/records/7958259 (DOI 10.5281/zenodo.7958258).

Closes #3853
2024-07-26 14:37:36 +02:00
Arne Welzel
7b8bbc6d00 btest/mysql: Clean query-attr.pcapng
It contained some unrelated IntelliJ traffic.
2024-07-25 11:53:41 +02:00
Arne Welzel
2894ae38d0 mysql: Support non-string query attributes
The query attributes aren't exposed to script layer right now, but this
should at least parse over them once encountered and some fixups.
2024-07-25 11:53:41 +02:00
Arne Welzel
93f5813be3 btest/mysql: Add pcap with non-string query attributes
Pcap was generated as follows. Doesn't seem wireshark even parses
this properly right now.

    with common.get_connection() as c:
        with c.cursor() as cur:
            date1 = datetime.date(1987, 10, 18)
            datetime1 = datetime.datetime(1990, 9, 26, 12, 13, 14)
            cur.add_attribute("number1", 42)
            cur.add_attribute("string1", "a string")
            cur.add_attribute("date1", date1)
            cur.add_attribute("datetime1", datetime1)
            cur.execute("SELECT version()")
            result = cur.fetchall()
            print("result", result)
2024-07-25 11:53:41 +02:00
Arne Welzel
0a1568f1a1 mysql: Introduce mysql_ssl_request event
This should've been added with fa48c885 for completion. Do it now.
The MySQL spec calls it SSLRequest packet, so keep SSL in the name for
consistency.
2024-07-25 11:53:41 +02:00
Arne Welzel
40f1c2cb6d mysql: Add mysql_auth_plugin, mysql_auth_more_data and mysql_auth_switch_request events
Remove caching_sha2_password parsing/state from the analyzer and implement
the generic events. If we actually want to peak into the authentication
mechanism, we could write a separate analyzer for it. For now, treat it
as opaque values that are exposed to script land.

The added tests show the --get-server-public-key in use where
mysql_auth_more_data contains an RSA public key.
2024-07-25 11:53:41 +02:00
Fupeng Zhao
e8bdf149f2 Add support for "auth switch" and "query attrs"
Also fix the issue where Resultset could not correctly distinguish between EOF_Packet and OK_Packet.
2024-07-25 11:53:40 +02:00
Fupeng Zhao
9cb618c718 Add support for parsing the "caching_sha2_password" auth plugin 2024-07-25 11:53:35 +02:00
Tim Wojtulewicz
2844d54f67 Fix handling of zero-length SMB2 error responses 2024-07-24 12:44:46 -07:00
Arne Welzel
52bcc92e40 Merge remote-tracking branch 'origin/topic/vern/script-opt-maint.Aug24'
* origin/topic/vern/script-opt-maint.Aug24:
  minor optimization of boolean comparisons
  fix & regression test for GH-3839 (spurious warnings for "when" constructs)
2024-07-24 11:18:18 +02:00
Christian Kreibich
146cf99ff6 Bump zeek-testing-cluster to reflect deprecation of prometheus.zeek 2024-07-23 16:58:52 -07:00
Vern Paxson
e960c29acb fix & regression test for GH-3839 (spurious warnings for "when" constructs) 2024-07-23 15:18:21 -07:00
Arne Welzel
a70ccc51ab ldap: Add LDAP sample with SASL-SRP mechanism
This is what @dopheide-esnet actually saw. Produced with a custom
cyrus-sasl and openldap build :-(
2024-07-23 11:29:00 +02:00
Arne Welzel
724c08f286 ldap: Fix assuming GSS-SPNEGO for all bindResponses
In retrospect that's an obvious bug.
2024-07-23 11:29:00 +02:00
Arne Welzel
09a48c7028 ldap: Implement extended request/response and StartTLS support
PCAP was produced with a local OpenLDAP server configured to support StartTLS.

This puts the Zeek calls into a separate ldap_zeek.spicy file/module
to separate it from LDAP.
2024-07-23 11:29:00 +02:00
Arne Welzel
bf9704f339 telemetry: Deprecate prometheus.zeek policy script
With Cluster::Node$metrics_port being optional, there's not really
a need for the extra script. New rule, if a metrics_port is set, the
node will attempt to listen on it.

Users can still redef Telemetry::metrics_port *after*
base/frameworks/telemetry was loaded to change the port defined
in cluster-layout.zeek.
2024-07-21 17:49:21 +02:00
Arne Welzel
3797622152 input/Manager: Improve type checks of record fields with type any
Calling AsRecordType() or AsFunc() on a Val of type any isn't safe.

Closes #3836
2024-07-19 11:35:54 +02:00
Christian Kreibich
0ba80d13b4 Merge branch 'topic/christian/bump-cluster-testsuite'
* topic/christian/bump-cluster-testsuite:
  Bump zeek-testing-cluster to pull in tee SIGPIPE fix
2024-07-17 15:37:29 -07:00
Christian Kreibich
b51a46f94d Bump zeek-testing-cluster to pull in tee SIGPIPE fix 2024-07-17 15:34:24 -07:00
Arne Welzel
0cab87c185 ldap: Harden parsing a bit
ASN1Message(True) may go off parsing arbitrary input data as
"something ASN.1" This could be GBs of octet strings or just very
long sequences. Avoid this by open-coding some top-level types expected.

This also tries to avoid some of the &parse-from usages that result
in unnecessary copies of data.

Adds a locally generated PCAP with addRequest/addResponse that we
don't currently handle.
2024-07-17 15:27:14 +02:00
Arne Welzel
31122f335f ldap: Handle integrity-only KRB wrap tokens
Mostly staring at the PCAPs and opened a few RFCs. For now, only if the
MS_KRB5 OID is used and accepted in a bind response, start stripping
KRB5 wrap tokens for both, client and server traffic.

Would probably be nice to forward the GSS-API data to the analyzer...

Closes zeek/spicy-ldap#29.
2024-07-17 15:26:30 +02:00
Tim Wojtulewicz
822102382c Start of 7.1.0 development 2024-07-11 13:19:15 -07:00
Christian Kreibich
c4bc9078ef Merge branch 'topic/christian/broker-prometheus-cpp'
* topic/christian/broker-prometheus-cpp:
  Update the scripts.base.frameworks.telemetry.internal-metrics test
  Revert "Temporarily disable the scripts/base/frameworks/telemetry/internal-metrics btest"
  Bump Broker to pull in new Prometheus support and pass in Zeek's registry
2024-07-11 12:15:16 -07:00
Christian Kreibich
77816f9a6b Update the scripts.base.frameworks.telemetry.internal-metrics test
This now uses different record fields, and for now we no longer have CAF
telemetry. We indicate we're running under test to get reliable ordering in the
baselined output.
2024-07-11 12:13:05 -07:00
Christian Kreibich
b387da3489 Revert "Temporarily disable the scripts/base/frameworks/telemetry/internal-metrics btest"
This reverts commit d6e97ab306.
Broker's telemetry is now available again.
2024-07-11 12:13:05 -07:00
Arne Welzel
a9c4daaa22 Merge remote-tracking branch 'jgras/topic/jgras/log-disable-analyzer'
* jgras/topic/jgras/log-disable-analyzer:
  Extend btest for logging of disabled analyzers
  Add logging of disabled analyzers to analyzer.log
2024-07-10 18:51:26 +02:00
Arne Welzel
7b99fc01a9 testing/btest: Default to HILTI_JIT_PARALLELISM=1
This is a rework of b59bed9d06 moving
HILTI_JIT_PARALLELISM=1 into btest.cfg to make it default applicable to
btest -j users (and CI).

The background for this change is that spicyz may spawn up to nproc compiler
instances by default. Combined with btest -j, this may be nproc x nproc
instances worst case. Particularly with gcc, this easily overloads CI or
local systems, putting them into hard-to-recover-from thrashing/OOM states.

Exporting HILTI_JIT_PARALLELISM in the shell allows overriding.
2024-07-10 11:04:47 +02:00
Jan Grashoefer
c6c8d078c0 Extend btest for logging of disabled analyzers 2024-07-09 20:15:46 +02:00
Tim Wojtulewicz
c557b2156a Merge remote-tracking branch 'origin/topic/vern/script-opt-maint.Jul24'
* origin/topic/vern/script-opt-maint.Jul24:
  minor script optimization updates to reflect recent changes, Coverity findings
2024-07-09 10:15:26 -07:00
Christian Kreibich
cdd5062f45 Management framework: bump cluster testsuite to pull in telemetry tests 2024-07-08 23:05:24 -07:00
Vern Paxson
a53e28be87 minor script optimization updates to reflect recent changes, Coverity findings 2024-07-06 16:44:27 -07:00
Arne Welzel
377fd711bd HTTP: Implement FlipRoles()
When Zeek flips roles of a HTTP connection subsequent to the HTTP analyzer
being attached, that analyzer would not update its own ContentLine analyzer
state, resulting in the wrong ContentLine analyzer being switched into
plain delivery mode.

In debug builds, this would result in assertion failures, in production
builds, the HTTP analyzer would receive HTTP bodies as individual header
lines, or conversely, individual header lines would be delivered as a
large chunk from the ContentLine analyzer.

PCAPs were generated locally using tcprewrite to select well-known-http ports
for both endpoints, then editcap to drop the first SYN packet.

Kudos to @JordanBarnartt for keeping at it.

Closes #3789
2024-07-04 11:38:33 +02:00
Christian Kreibich
737b1a2013 Remove the Supervisor's internal ClusterEndpoint struct.
This eliminates one place in which we currently need to mirror changes to the
script-land Cluster::Node record. Instead of keeping an exact in-core equivalent, the
Supervisor now treats the data structure as opaque, and stores the whole cluster
table as a JSON string.

We may replace the script-layer Supervisor::ClusterEndpoint in the future, using
Cluster::Node directly. But that's a more invasive change that will affect how
people invoke Supervisor::create() and similars.

Relying on JSON for serialization has the side-effect of removing the
Supervisor's earlier quirk of using 0/tcp, not 0/unknown, to indicate unused
ports in the Supervisor::ClusterEndpoint record.
2024-07-02 14:52:17 -07:00