Commit graph

4072 commits

Author SHA1 Message Date
Robin Sommer
6fcbb55ccd Merge remote-tracking branch 'origin/topic/awelzel/analyzer-module-enable-disable-file-analyzer'
* origin/topic/awelzel/analyzer-module-enable-disable-file-analyzer:
  analyzer: Add file_analyzer support to enable_analyzer()/disable_analyzer()
2022-10-05 13:27:23 +02:00
Tim Wojtulewicz
37d4a28816 Merge remote-tracking branch 'origin/topic/awelzel/http-no-current-entity'
* origin/topic/awelzel/http-no-current-entity:
  http: Prevent script errors when http$current_entity is not set
2022-10-03 09:44:46 -07:00
Arne Welzel
81fe46f123 analyzer: Add file_analyzer support to enable_analyzer()/disable_analyzer()
This allows to enable/disable file analyzers through the same interfaces
as packet and protocol analyzers, specifically Analyzer::disable_analyzer
could be interesting.
2022-09-30 11:47:56 +02:00
Arne Welzel
af5a0215c0 packet_analysis: Introduce PacketAnalyzer::__disable_analyzer()
This adds machinery to the packet_analysis manager for disabling
and enabling packet analyzers and implements two low-level bifs
to use it.

Extend Analyzer::enable_analyzer() and Analyzer::disable_analyzer()
to transparently work with packet analyzers, too. This also allows
to add packet analyzers to Analyzer::disabled_analyzers.
2022-09-30 09:27:22 +02:00
Arne Welzel
700a9a4f37 Introduce basic test triggering when zeek -r triggers script errors
I wonder if there's another one that covers errors during a basic zeek -r,
but didn't seem like.
2022-09-27 17:49:58 +02:00
Arne Welzel
d5cd023dff file_analysis: Implement AnalyzerViolation() for file_analysis/Analyzer
Add a test parsing a malformed PE file showing that analyzer_violation_info
is raised with the fa_file object set.

It could be interesting to pass through an optional connection if one
exists, but access is provided through f$conns, too.
2022-09-27 17:49:58 +02:00
Arne Welzel
bc8fd5a4c6 Introduce generic analyzer_confirmation_info and analyzer_violation_info
Introduce two new events for analyzer confirmation and analyzer violation
reporting. The current analyzer_confirmation and analyzer_violation
events assume connection objects and analyzer ids are available which
is not always the case. We're already passing aid=0 for packet analyzers
and there's not currently a way to report violations from file analyzers
using analyzer_violation, for example.

These new events use an extensible Info record approach so that additional
(optional) information can be added later without changing the signature.
It would allow for per analyzer extensions to the info records to pass
analyzer specific info to script land. It's not clear that this would be
a good idea, however.

The previous analyzer_confirmation and analyzer_violation events
continue to exist, but are deprecated and will be removed with Zeek 6.1.
2022-09-27 17:49:51 +02:00
Arne Welzel
3a320fc6b6 packet_analysis: Do not raise analyzer_confirmation per-packet for tunnels
There's a logic error in the packet analyzer's AnalyzerConfirmation()
method that causes analyzer_confirmation() events to be raised for every
packet rather than stopping after the first confirmation which appears to
have been the intention. This affects, for example, VXLAN and Geneve tunnels.

The optional arg_tag parameter was used for short-circuit'ing, but the return
value of GetAnalyzerTag() used for setting the session state causing the
disconnect.

In scenarios where Zeek receives purely tunneled monitoring traffic, this may
result in a non-negligible performance impact.

Somewhat related, ensure the session state is set to violated before
short-circuiting if no analyzer_violations are installed.

Suggesting this as a 5.0.3 candidate.
2022-09-27 12:49:56 +02:00
Arne Welzel
38e226bf75 http: Prevent script errors when http$current_entity is not set
The current_entity tracking in HTTP assumes that client/server never
send HTTP entities at the same time. The attached pcap (generated
artificially) violates this and triggers:

    1663698249.307259 expression error in <...>base/protocols/http/./entities.zeek, line 89: field value missing (HTTP::c$http$current_entity)

For the http-no-crlf test, include weird.log as baseline. Now that weird is
@load'ed from http, it is actually created and seems to make sense
to btest-diff it, too.
2022-09-26 10:18:24 +02:00
Arne Welzel
660172013b scripts/conn: Open-code determine_service()
...and avoid doing it as suggested by Justin to avoid the extra over-head
in scan scenarios where c$service is empty.
2022-09-20 23:07:26 +02:00
Arne Welzel
0e28a7faf5 strings: Implement join_string_set() as bif
Haven't measured speed, but this is probably faster than
the cat() and string invocations.
2022-09-20 23:07:26 +02:00
Arne Welzel
31aeb58e10 dpd: Replace negated service fmt() magic with dedicated field
...the only known cases where the `-` for `connection$service` was
handled is to skip/ignore these analyzers.

Slight suspicion that join_string_set() should maybe become a bif
now determine_service() runs once for each connection.

Closes #2388
2022-09-20 23:07:26 +02:00
Tim Wojtulewicz
2b60f63123 Start of 5.2.0 development 2022-09-20 09:23:50 -07:00
Tim Wojtulewicz
b3c2988c90 Update broker submodule 2022-09-20 09:02:50 -07:00
Christian Kreibich
d20ffb100c Merge branch 'topic/amazingpp/2384-record-deprecation' of github.com:/AmazingPP/zeek
* 'topic/amazingpp/2384-record-deprecation' of github.com:/AmazingPP/zeek:
  Replace all the Warning() calls after IsFieldDeprecated() over to Warn()
  Fix deprecation not flagged and incorrect line number in record
2022-09-19 18:15:39 -07:00
Tim Wojtulewicz
f04f070d9f Merge remote-tracking branch 'origin/topic/vern/cpp-maint-Sep22'
* origin/topic/vern/cpp-maint-Sep22:
  oof more manual fixups
  undo inadvertently committed tweak to test
  update for btest only run in some environments
  btest tweaks for recent changes
  updates to notes for compile-to-C++ maintenance
  newly-created btest files
  baseline updates for -a cpp alternative (compile-to-C++)
  tweak btest so it's recognized as a candidate for C++ compilation testing
  split basic "int" btests into main part versus now-separate overflow part
  fix deprecated "local" scoping in test scripts
  annotated scripts to skip when testing compilation-to-C++
  C++ script generation fix for lambdas that have identical bodies
  fix for C++ scripts that refer to "opaque" types
  C++ compilation support for 2-valued vector "for" loops
  C++ compilation support for RE /s operator
  run-time checking of vector operations for overflows and division-by-zero
  error propagation fix to avoid a crash
2022-09-19 13:51:41 -07:00
Vern Paxson
2dfaa00c61 oof more manual fixups 2022-09-16 18:45:46 -07:00
Vern Paxson
bf0a74264a undo inadvertently committed tweak to test 2022-09-16 18:44:09 -07:00
Vern Paxson
3c0b07d149 update for btest only run in some environments 2022-09-16 18:43:05 -07:00
Vern Paxson
9d24e9f71a btest tweaks for recent changes 2022-09-16 17:04:06 -07:00
Vern Paxson
914caf2f88 newly-created btest files 2022-09-16 16:53:31 -07:00
Vern Paxson
d7adf81859 baseline updates for -a cpp alternative (compile-to-C++) 2022-09-16 16:51:45 -07:00
Vern Paxson
b6b4503dd7 tweak btest so it's recognized as a candidate for C++ compilation testing 2022-09-16 16:49:55 -07:00
Vern Paxson
fd5fa528ca split basic "int" btests into main part versus now-separate overflow part 2022-09-16 16:49:22 -07:00
Vern Paxson
510f83c889 fix deprecated "local" scoping in test scripts 2022-09-16 16:48:19 -07:00
Vern Paxson
ce5d840800 annotated scripts to skip when testing compilation-to-C++ 2022-09-16 16:47:43 -07:00
Vern Paxson
6e84a1da57 updates to ZAM btest baselines 2022-09-16 10:06:57 -07:00
Robin Sommer
627b97c8ff Merge remote-tracking branch 'origin/topic/awelzel/2289-at-if-else-if-no-way'
* origin/topic/awelzel/2289-at-if-else-if-no-way:
  parse.y/directives: Reject directives as statements
2022-09-07 14:33:15 +02:00
Robin Sommer
a60d569f7b Merge remote-tracking branch 'origin/topic/awelzel/dpd-analyzer-merger'
* origin/topic/awelzel/dpd-analyzer-merger:
  analyzer/dpd: Address review comments
  Remove @load base/frameworks/dpd from tests
  frameworks/dpd: Move to frameworks/analyzer/dpd, load by default
  scripts/dce-rpc,ntlm: Do not load base/frameworks/dpd
  btest: Remove unnecessary loading of frameworks/dpd
2022-09-07 14:30:28 +02:00
Tim Wojtulewicz
7cc876d84a Merge remote-tracking branch 'origin/topic/timw/2338-signature-eval-unused'
* origin/topic/timw/2338-signature-eval-unused:
  Add is_used attribute to an ID if used in a signature eval statement
2022-09-06 07:44:34 -07:00
Arne Welzel
4aaebf613e analyzer/dpd: Address review comments
* word-smith deprecation message
* do not load scripts/base/analyzer in segment logging policy script
2022-09-06 14:32:10 +02:00
AmazingPP
970f45d686 Replace all the Warning() calls after IsFieldDeprecated() over to Warn() 2022-09-03 19:15:47 +08:00
AmazingPP
997d3ed126 Fix deprecation not flagged and incorrect line number in record 2022-09-03 10:36:01 +08:00
Christian Kreibich
c7860e3238 Expand Supervisor to support loading additional scripts before user scripts
In supervised nodes, the Supervisor's NodeConfig$scripts vector adds scripts to
the end of the user-provided scripts (options.scripts_to_load), so they load
_after_ any user-provided ones. This can cause confusing redef pitfalls when
users expect their customizations to run last, as they normally do.

This adds two members in Supervisor::NodeConfig, `addl_base_scripts` and
`addl_user_scripts`, to store scripts to load before and after the user scripts,
respectively. The latter serves the same purpose as the old `scripts` member,
which is still there but deprecated (in scriptland only). It functions as
before, after any scripts added via `addl_user_scripts`.
2022-09-02 10:23:35 -07:00
Tim Wojtulewicz
0a0dd7143b Add is_used attribute to an ID if used in a signature eval statement 2022-08-31 14:58:23 -07:00
Christian Kreibich
a726418d38 Merge branch 'topic/awelzel/cluster-telemetry-defaults'
* topic/awelzel/cluster-telemetry-defaults:
  telemetry: Use dynamic metrics port, remove broker topic mentioning from NEWS entry
  telemetry: In a cluster, open port 9911 for Prometheus by default
2022-08-31 10:53:47 -07:00
Tim Wojtulewicz
9ccbf9063a Merge remote-tracking branch 'origin/topic/awelzel/topic/to-port-empty-string'
* origin/topic/awelzel/topic/to-port-empty-string:
  bifs/to_port: Avoid ASAN errors when calling to_port("")
2022-08-31 08:17:04 -07:00
Arne Welzel
c89be2a13b bifs/to_port: Avoid ASAN errors when calling to_port("")
Ran into this when using to_port(getenv(...)) for an undefined/empty
environment variable. ASAN doesn't like that the slash variable ends
up being access behind the string.
2022-08-31 17:15:50 +02:00
Arne Welzel
654fd9c7da Remove @load base/frameworks/dpd from tests
Now that it's loaded in bare mode, no need to load it explicitly.

The main thing that tests were relying on seems to be tracking of
c$service for conn.log baselines. Very few were actually checking
for dpd.log
2022-08-31 17:00:55 +02:00
Arne Welzel
9e7f2a04c1 frameworks/dpd: Move to frameworks/analyzer/dpd, load by default
* Because frameworks/analyzer is loaded via init-frameworks-and-bifs the
  dpd functionality (really just dpd.log and disabling of analyzers) is
  now enabled even in bare mode.
* Not sure we need to keep frameworks/base/dpd/__load__.zeek around
  or can just remove it right away.
2022-08-31 16:50:47 +02:00
Arne Welzel
b2d33db3d9 btest: Remove unnecessary loading of frameworks/dpd
These tests do not test conn.log or dpd.log, so they don't actually
need to @load dpd - dynamic-protocol-detection is enabled anyway.
2022-08-31 16:50:37 +02:00
Arne Welzel
65b31c525d telemetry: Use dynamic metrics port, remove broker topic mentioning from NEWS entry 2022-08-30 11:20:14 +02:00
Tim Wojtulewicz
ed4521af60 Add type checking to string_cat arguments 2022-08-29 08:45:59 -07:00
Tim Wojtulewicz
686eb54f95 Merge remote-tracking branch 'origin/topic/awelzel/gtpv1-no-protocol-detection'
* origin/topic/awelzel/gtpv1-no-protocol-detection:
  gtpv1: Do not register for protocol detection
2022-08-26 14:49:54 -07:00
Dominik Charousset
456efd8082 Revert to regular peering fn for ssl_auth_failure
With the fixed Broker version, the `ssl_auth_failure` btest can use the
regular `peer` function again.
2022-08-26 17:00:45 +02:00
Arne Welzel
42be2444a7 gtpv1: Do not register for protocol detection
While reviewing/understanding the analyzer setup, it didn't seem like
GTPv1 implements packet_analysis::Analyzer::DetectProtocol(), so
should not register it for protocol_detection either.

Alternatively, maybe DetectProtocol() should've been implemented in
which case maybe this should be an issue?
2022-08-26 10:47:38 +02:00
Arne Welzel
171846a37a parse.y/directives: Reject directives as statements
Avoid the issue outlined in #2289 where the @if or @else is taken as the
statement of an `if`, `for` or `while` by rejecting such constructs.

Effectively this means the following scripts are now rejected:

    # Print's "cond true" with Zeek 5.0 even though the `if ( F )`
    # should be in effect.

    if ( F )
        @if ( T )
            print "cond true";
        @else
            print "cond false";
        @endif

or

    # Print's "hello" once with Zeek 5.0
    local v = vector( 1, 2, 3 );

    for ( i in v )
        @if ( T )
        print("hello")
        @endif

To make above work as intended, additional braces can be used.

    if ( T )
        {
    @if ( cond )
            print "cond true";
    @else
            print "cond false";
    @endif
        }

    for ( i in v )
        {
    @if ( T )
        print("hello")
    @endif
        }
2022-08-26 09:42:50 +02:00
Arne Welzel
7310952358 telemetry: In a cluster, open port 9911 for Prometheus by default
Port 9911 has been allocated here:

https://github.com/prometheus/prometheus/wiki/Default-port-allocations

Logic is put into telemetry/cluster.zeek. Doing it in `cluster/nodes/`
seemed like quite some extra splitting for just those few settings.
2022-08-26 09:42:12 +02:00
Tim Wojtulewicz
c88a362d1b Avoid race conditions in broker.ssl_auth_failure btest 2022-08-24 12:10:42 -07:00
Tim Wojtulewicz
76b6cf7afa Merge remote-tracking branch 'simeonmiteff/master'
* simeonmiteff/master:
  Pull changes from zeek/cmake fork
  Skip test based on preprocessor flag set by cmake
  Set flag for libpcap without DLT_LINUX_SLL2
  Force event order in core/init-error btest
  Update some coverage baselines
  Update plugins/hooks baseline
  Add support for DLT_LINUX_SLL2 PCAP link-type
2022-08-24 09:23:01 -07:00