Do not load Spicy scripts if Spicy is not available.

This commit is contained in:
Robin Sommer 2023-05-15 13:27:01 +02:00
parent 57eb7b4d2a
commit a62e153dd3
No known key found for this signature in database
GPG key ID: D8187293B3FFE5D0
7 changed files with 29 additions and 1 deletions

View file

@ -5702,4 +5702,7 @@ event net_done(t: time)
@endif
@load base/packet-protocols
@if ( have_spicy() )
@load base/frameworks/spicy/init-bare
@endif

View file

@ -43,7 +43,10 @@
@load base/frameworks/openflow
@load base/frameworks/netcontrol
@load base/frameworks/telemetry
@if ( have_spicy() )
@load base/frameworks/spicy
@endif
@load base/protocols/conn
@load base/protocols/dce-rpc

View file

@ -17,7 +17,9 @@
# Load BiFs defined by plugins.
@load base/bif/plugins
@if ( have_spicy() )
@load base/frameworks/spicy/init-framework
@endif
# This sets up secondary/subdir BIFs such that they can be used by any
# further scripts within their global initializations and is intended to be

View file

@ -5811,8 +5811,19 @@ function has_module_events%(group: string%) : bool
group->CheckString()));
%}
## Returns true if Zeek was built with support for using Spicy analyzers (which
# is the default).
function have_spicy%(%) : bool
%{
#ifdef HAVE_SPICY
return zeek::val_mgr->Bool(true);
#else
return zeek::val_mgr->Bool(false);
#endif
%}
## Returns true if Zeek was built with support for its in-tree Spicy analyzers
## (which is the default).
## (which is the default if Spicy support is available).
function have_spicy_analyzers%(%) : bool
%{
return zeek::val_mgr->Bool(USE_SPICY_ANALYZERS);

View file

@ -801,6 +801,7 @@
0.000000 MetaHookPost CallFunction(gsub, ..., ...) -> <no result>
0.000000 MetaHookPost CallFunction(has_event_group, <frame>, (Analyzer::Logging)) -> <no result>
0.000000 MetaHookPost CallFunction(has_module_events, <frame>, (Analyzer::Logging)) -> <no result>
0.000000 MetaHookPost CallFunction(have_spicy, <null>, ()) -> <no result>
0.000000 MetaHookPost CallFunction(have_spicy_analyzers, <null>, ()) -> <no result>
0.000000 MetaHookPost CallFunction(is_file_analyzer, <frame>, (AllAnalyzers::ANALYZER_ANALYZER_TCPSTATS)) -> <no result>
0.000000 MetaHookPost CallFunction(is_packet_analyzer, <frame>, (AllAnalyzers::ANALYZER_ANALYZER_TCPSTATS)) -> <no result>
@ -2414,6 +2415,7 @@
0.000000 MetaHookPre CallFunction(gsub, ..., ...)
0.000000 MetaHookPre CallFunction(has_event_group, <frame>, (Analyzer::Logging))
0.000000 MetaHookPre CallFunction(has_module_events, <frame>, (Analyzer::Logging))
0.000000 MetaHookPre CallFunction(have_spicy, <null>, ())
0.000000 MetaHookPre CallFunction(have_spicy_analyzers, <null>, ())
0.000000 MetaHookPre CallFunction(is_file_analyzer, <frame>, (AllAnalyzers::ANALYZER_ANALYZER_TCPSTATS))
0.000000 MetaHookPre CallFunction(is_packet_analyzer, <frame>, (AllAnalyzers::ANALYZER_ANALYZER_TCPSTATS))
@ -4026,6 +4028,7 @@
0.000000 | HookCallFunction gsub(...)
0.000000 | HookCallFunction has_event_group(Analyzer::Logging)
0.000000 | HookCallFunction has_module_events(Analyzer::Logging)
0.000000 | HookCallFunction have_spicy()
0.000000 | HookCallFunction have_spicy_analyzers()
0.000000 | HookCallFunction is_file_analyzer(AllAnalyzers::ANALYZER_ANALYZER_TCPSTATS)
0.000000 | HookCallFunction is_packet_analyzer(AllAnalyzers::ANALYZER_ANALYZER_TCPSTATS)

View file

@ -4,6 +4,9 @@
# Commonly, this test may fail if one forgets to @load some base/ scripts
# when writing a new zeek scripts.
#
# Require Spicy, otherwise its scripts cannot be loaded.
# @TEST-REQUIRES: have-spicy
#
# @TEST-EXEC: test -d $DIST/scripts
# @TEST-EXEC: for script in `find $DIST/scripts/ -name \*\.zeek`; do zeek -b --parse-only $script >>errors 2>&1; done
# @TEST-EXEC: TEST_DIFF_CANONIFIER="grep -v -e 'Use the external.*bro-simple-scan package' -e 'The MQTT scripts have been moved out of policy/' | $SCRIPTS/diff-remove-abspath | $SCRIPTS/diff-sort" btest-diff errors

View file

@ -7,6 +7,9 @@
# (e.g. cluster operation), and in such cases, the missing_loads baseline
# can be adjusted to tolerate that.
# Require Spicy, otherwise baselines change.
# @TEST-REQUIRES: have-spicy
#@TEST-EXEC: test -d $DIST/scripts/base
#@TEST-EXEC: test -e $DIST/scripts/base/init-default.zeek
#@TEST-EXEC: ( cd $DIST/scripts/base && find . -name '*.zeek' ) | sort >"all scripts found"