Merge remote-tracking branch 'origin/topic/awelzel/duplicate-plugin-no-debug'

* origin/topic/awelzel/duplicate-plugin-no-debug:
  plugin/Manager: Warn when plugin with the same name is found
This commit is contained in:
Arne Welzel 2023-06-15 18:36:25 +02:00
commit 5a9c6d4633
5 changed files with 49 additions and 4 deletions

32
CHANGES
View file

@ -1,3 +1,35 @@
6.1.0-dev.76 | 2023-06-15 18:36:25 +0200
* plugin/Manager: Warn when plugin with the same name is found (Arne Welzel, Corelight)
This was brought up on Slack as a potential source of confusion during
development as it's not visible when plugin directories are ignored outside
of looking into the plugin debug stream. I'd actually prefer to just
FatalError() this, but a warning seems reasonably visible for interactive
usage.
* Options: Do not output full usage on --test error (Arne Welzel, Corelight)
...mostly because the usage output is very long and the actual useful
error message scrolls off the screen.
* GH-3090: CMakeLists: Propagate DOCTEST defines to external plugins (Arne Welzel, Corelight)
If Zeek has not been built with doctest enabled then it's not easy
to run a plugin's tests (and if they really wanted to they could
again undef the DOCTEST_CONFIG_DISABLE and provide their own doctest
main() implementation.
* GH-3090: CMakeLists: Add rapidjson/include to zeek_dynamic_plugin_base (Arne Welzel, Corelight)
threading/formatters/JSON.h has a rapidjson include. Extend the
include directories of external plugins so they are setup to find
these in Zeek's install tree.
* GH-3090: ZeekPluginBootstrap: Encode Zeek's CMAKE_BUILD_TYPE (Arne Welzel, Corelight)
...and bump cmake to have plugin's make use of it.
6.1.0-dev.66 | 2023-06-14 10:09:46 -0700 6.1.0-dev.66 | 2023-06-14 10:09:46 -0700
* Change table initialization deprecation to error (Tim Wojtulewicz, Corelight) * Change table initialization deprecation to error (Tim Wojtulewicz, Corelight)

View file

@ -1 +1 @@
6.1.0-dev.66 6.1.0-dev.76

View file

@ -112,10 +112,10 @@ void Manager::SearchDynamicPlugins(const std::string& dir)
if ( name.empty() ) if ( name.empty() )
reporter->FatalError("empty plugin magic file %s", magic.c_str()); reporter->FatalError("empty plugin magic file %s", magic.c_str());
if ( dynamic_plugins.find(lower_name) != dynamic_plugins.end() ) if ( const auto& other = dynamic_plugins.find(lower_name); other != dynamic_plugins.end() )
{ {
DBG_LOG(DBG_PLUGINS, "Found already known plugin %s in %s, ignoring", name.c_str(), reporter->Warning("ignoring dynamic plugin %s from %s, already found in %s",
dir.c_str()); name.c_str(), dir.c_str(), other->second.c_str());
return; return;
} }

View file

@ -0,0 +1,5 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
warning in <...>/init-bare.zeek, line 1: ignoring dynamic plugin Demo::Foo from <...>/build, already found in <...>/build_backup
Demo::Foo - A Foo packet source (dynamic, version 1.0.0)
[Packet Source] FooPktSrc (interface prefix "foo"; supports live and trace input)

View file

@ -0,0 +1,8 @@
# @TEST-DOC: Loading two plugins with the same name triggers a warning.
# @TEST-EXEC: ${DIST}/auxil/zeek-aux/plugin-support/init-plugin -u . Demo Foo
# @TEST-EXEC: cp -r %DIR/pktsrc-plugin/* .
# @TEST-EXEC: ./configure --zeek-dist=${DIST} && make
# @TEST-EXEC: cp -R build build_backup
# @TEST-EXEC: ZEEK_PLUGIN_PATH=`pwd`/build_backup:`pwd`/build zeek -NN Demo::Foo >output 2>&1
# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-remove-abspath btest-diff output