Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
Rename plugin from _Zeek::Spicy to Zeek::Spicy.
Browse files Browse the repository at this point in the history
This used to be a hack for Zeek 3.x. We also remove any library still
in place under the old name inside the plugin build directory.

Closes #44.
  • Loading branch information
rsmmr committed Apr 19, 2022
1 parent 165856a commit c9ca2d9
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 21 deletions.
10 changes: 5 additions & 5 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ zkg_ubuntu_task:
- zkg install --force --skiptests .

check_script:
- zeek -N _Zeek::Spicy
- zeek -N Zeek::Spicy
- zeek local

always:
Expand Down Expand Up @@ -70,15 +70,15 @@ standalone_ubuntu_task:
- (cd build && run-clang-tidy -j $(nproc) $(jq -r '.[].file | select(contains(".bif") | not)' <compile_commands.json ))

test_build_script:
- ZEEK_PLUGIN_PATH=$(pwd)/build zeek -N _Zeek::Spicy
- ZEEK_PLUGIN_PATH=$(pwd)/build zeek -N Zeek::Spicy
- make -C tests test

install_script:
- (cd build && ninja install)
- rm -rf build

test_install_script:
- zeek -N _Zeek::Spicy
- zeek -N Zeek::Spicy
- PATH=/opt/spicy-plugin/bin:$PATH make -C tests test-install

static_zeek_master_ubuntu_task:
Expand Down Expand Up @@ -113,10 +113,10 @@ static_zeek_master_ubuntu_task:

# Note that the build tests need the Zeek headers installed.
test_build_script:
- (. zeek/build/zeek-path-dev.sh && ./zeek/build/src/zeek -N _Zeek::Spicy)
- (. zeek/build/zeek-path-dev.sh && ./zeek/build/src/zeek -N Zeek::Spicy)
- PATH=$(pwd)/zeek/build/src:$(pwd)/zeek/build/src/builtin-plugins/$(basename $(pwd))/bin:$PATH make -C tests test

test_install_script:
- rm -rf zeek/build
- PATH=/opt/zeek-master/bin:$PATH zeek -N _Zeek::Spicy
- PATH=/opt/zeek-master/bin:$PATH zeek -N Zeek::Spicy
- PATH=/opt/zeek-master/bin:$PATH make -C tests test-install
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ include(BroPlugin)
set(CMAKE_C_FLAGS ${save_c_flags})
set(CMAKE_CXX_FLAGS ${save_cxx_flags})

zeek_plugin_begin(_Zeek Spicy)
zeek_plugin_begin(Zeek Spicy)

if (SPICY_HAVE_TOOLCHAIN)
zeek_plugin_cc(src/driver.cc)
Expand Down Expand Up @@ -182,6 +182,20 @@ endif ()
spicy_include_directories(${_plugin_lib} PRIVATE)
set_property(TARGET ${_plugin_lib} PROPERTY ENABLE_EXPORTS true)

# TODO: The following is temporary to help people building from source
# avoid trouble. We can remove this a couple releases after v1.3.10.
if (NOT ZEEK_SPICY_PLUGIN_INTERNAL_BUILD)
# Remove any old _Zeek_Spicy.so left-over from previous versions.
get_property(plugin_dir TARGET ${_plugin_lib} PROPERTY LIBRARY_OUTPUT_DIRECTORY)
set(old_plugin_location
"${plugin_dir}/_Zeek-Spicy.${HOST_ARCHITECTURE}${CMAKE_SHARED_MODULE_SUFFIX}")
add_custom_command(
TARGET ${_plugin_lib}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove -f "${old_plugin_location}"
COMMENT "")
endif ()

####
#### Prepare the plugin build directory so that it resembles our installation layout.
####
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ through the Zeek package manager:

This will pull down the package, compile and test the plugin, and then
install and activate it. To check that the plugin becomes available,
run `zeek -N _Zeek::Spicy` afterwards, it should show output like
run `zeek -N Zeek::Spicy` afterwards, it should show output like
this:

# zeek -NN _Zeek::Spicy
_Zeek::Spicy - Support for Spicy parsers (*.spicy, *.evt, *.hlto) (dynamic, version x.y.z)
# zeek -NN Zeek::Spicy
Zeek::Spicy - Support for Spicy parsers (*.spicy, *.evt, *.hlto) (dynamic, version x.y.z)

If you want to develop your own Spicy analyzers for Zeek, you will
need a tool that comes with the plugin: ``spicyz``. Please see the
Expand All @@ -68,8 +68,8 @@ that you can write to the Zeek plugin directory):

Zeek should now show it:

# zeek -N _Zeek::Spicy
_Zeek::Spicy - Support for Spicy parsers (*.spicy, *.evt, *.hlto) (dynamic, version x.y.z)
# zeek -N Zeek::Spicy
Zeek::Spicy - Support for Spicy parsers (*.spicy, *.evt, *.hlto) (dynamic, version x.y.z)

You will also find `spicyz` in `${prefix}/bin` now.

Expand Down
2 changes: 1 addition & 1 deletion src/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ bool plugin::Zeek_Spicy::Plugin::toggleAnalyzer(::zeek::EnumVal* tag, bool enabl

::zeek::plugin::Configuration plugin::Zeek_Spicy::Plugin::Configure() {
::zeek::plugin::Configuration config;
config.name = "_Zeek::Spicy"; // Prefix with underscore to make sure it gets loaded first
config.name = "Zeek::Spicy";
config.description = "Support for Spicy parsers (*.spicy, *.evt, *.hlto)";
config.version.major = spicy::zeek::configuration::PluginVersionMajor;
config.version.minor = spicy::zeek::configuration::PluginVersionMinor;
Expand Down
4 changes: 2 additions & 2 deletions tests/zeek/analyzer-tag.zeek
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# @TEST-EXEC: spicyz -o ssh.hlto ssh.spicy ./ssh.evt
# @TEST-EXEC: ${ZEEK} -b _Zeek::Spicy ssh.hlto %INPUT >>output
# @TEST-EXEC: ${ZEEK} -b Zeek::Spicy ssh.hlto %INPUT >>output
# @TEST-EXEC: echo >>output
# @TEST-EXEC: ${ZEEK} -b _Zeek::Spicy %INPUT >>output
# @TEST-EXEC: ${ZEEK} -b Zeek::Spicy %INPUT >>output
# @TEST-EXEC: btest-diff output
#
# @TEST-DOC: Check that we can access ANALYZER_* tags during Zeek-side script parse time.
Expand Down
4 changes: 2 additions & 2 deletions tests/zeek/conn-id.spicy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @TEST-EXEC: spicyz -o test.hlto %INPUT test.evt
# @TEST-EXEC: ${ZEEK} -b -r ${TRACES}/ssh-single-conn.trace _Zeek::Spicy test.hlto Spicy::enable_print=T >>output
# @TEST-EXEC: ${ZEEK} -b -r ${TRACES}/ipv6.trace _Zeek::Spicy test.hlto Spicy::enable_print=T >>output
# @TEST-EXEC: ${ZEEK} -b -r ${TRACES}/ssh-single-conn.trace Zeek::Spicy test.hlto Spicy::enable_print=T >>output
# @TEST-EXEC: ${ZEEK} -b -r ${TRACES}/ipv6.trace Zeek::Spicy test.hlto Spicy::enable_print=T >>output
# @TEST-EXEC: btest-diff output

module Test;
Expand Down
2 changes: 1 addition & 1 deletion tests/zeek/context.spicy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# @TEST-EXEC: spicyz -o x.hlto %INPUT ./ssh.evt
# @TEST-EXEC: ${ZEEK} -b -r ${TRACES}/ssh-single-conn.trace _Zeek::Spicy x.hlto Spicy::enable_print=T >output
# @TEST-EXEC: ${ZEEK} -b -r ${TRACES}/ssh-single-conn.trace Zeek::Spicy x.hlto Spicy::enable_print=T >output
# @TEST-EXEC: btest-diff output
#
# @TEST-DOC: Check that the Zeek plugin passes a (and the same) %context object to both sides of a connection.
Expand Down
4 changes: 2 additions & 2 deletions tests/zeek/module-path.spicy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# @TEST-EXEC: spicyz -o x.hlto %INPUT
# @TEST-EXEC: ${ZEEK} -b _Zeek::Spicy x.hlto Spicy::enable_print=T >>output
# @TEST-EXEC: ${ZEEK} -b Zeek::Spicy x.hlto Spicy::enable_print=T >>output
# @TEST-EXEC: mkdir -p y/z && mv x.hlto y/z
# @TEST-EXEC: ZEEK_SPICY_MODULE_PATH=FOO:y:BAR ${ZEEK} -b _Zeek::Spicy Spicy::enable_print=T >>output
# @TEST-EXEC: ZEEK_SPICY_MODULE_PATH=FOO:y:BAR ${ZEEK} -b Zeek::Spicy Spicy::enable_print=T >>output
# @TEST-EXEC: btest-diff output

module Test;
Expand Down
4 changes: 2 additions & 2 deletions tests/zeek/ssh-banner.zeek
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# @TEST-EXEC: spicyz -o ssh.hlto ssh.spicy ./ssh.evt
# @TEST-EXEC: echo === confirmation >>output
# @TEST-EXEC: ${ZEEK} -b -r ${TRACES}/ssh-single-conn.trace -s ./ssh.sig _Zeek::Spicy ssh.hlto %INPUT ./extern.zeek | sort >>output
# @TEST-EXEC: ${ZEEK} -b -r ${TRACES}/ssh-single-conn.trace -s ./ssh.sig Zeek::Spicy ssh.hlto %INPUT ./extern.zeek | sort >>output
# @TEST-EXEC: echo === violation >>output
# @TEST-EXEC: ${ZEEK} -b -r ${TRACES}/http-post.trace -s ./ssh.sig _Zeek::Spicy ssh.hlto ./extern.zeek %INPUT | sort >>output
# @TEST-EXEC: ${ZEEK} -b -r ${TRACES}/http-post.trace -s ./ssh.sig Zeek::Spicy ssh.hlto ./extern.zeek %INPUT | sort >>output
# @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff output

event ssh::banner(c: connection, is_orig: bool, version: string, software: string)
Expand Down

0 comments on commit c9ca2d9

Please sign in to comment.