mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge branch 'master' into topic/gilbert/plugin-api-tweak
This commit is contained in:
commit
d3a5440cff
29 changed files with 146 additions and 90 deletions
20
CHANGES
20
CHANGES
|
@ -1,4 +1,24 @@
|
||||||
|
|
||||||
|
2.3-440 | 2015-02-23 11:39:17 -0600
|
||||||
|
|
||||||
|
* Updating plugin docs to recent changes. (Robin Sommer)
|
||||||
|
|
||||||
|
* Updating plugin tests to recent changes. (Robin Sommer)
|
||||||
|
|
||||||
|
* Making plugin names case-insensitive for some internal comparisions.
|
||||||
|
Makes plugin system more tolerant against spelling inconsistencies
|
||||||
|
are hard to catch otherwise. (Robin Sommer)
|
||||||
|
|
||||||
|
* Explicitly removing some old scripts on install that have moved
|
||||||
|
into plugins to prevent them causing confusion. (Robin Sommer)
|
||||||
|
|
||||||
|
* BIT-1312: Removing setting installation plugin path from
|
||||||
|
bro-path-dev.sh. Also, adding to existing BRO_PLUGIN_PATH rather
|
||||||
|
than replacing. (Robin Sommer)
|
||||||
|
|
||||||
|
* Creating the installation directory for plugins at install time.
|
||||||
|
(Robin Sommer)
|
||||||
|
|
||||||
2.3-427 | 2015-02-20 13:49:33 -0800
|
2.3-427 | 2015-02-20 13:49:33 -0800
|
||||||
|
|
||||||
* Removing dependency on PCAP_NETMASK_UNKNOWN to compile with
|
* Removing dependency on PCAP_NETMASK_UNKNOWN to compile with
|
||||||
|
|
|
@ -31,12 +31,12 @@ configure_file(bro-path-dev.in ${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev)
|
||||||
|
|
||||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev.sh
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev.sh
|
||||||
"export BROPATH=`${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev`\n"
|
"export BROPATH=`${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev`\n"
|
||||||
"export BRO_PLUGIN_PATH=\"${CMAKE_CURRENT_BINARY_DIR}/src:${BRO_PLUGIN_INSTALL_PATH}\"\n"
|
"export BRO_PLUGIN_PATH=\"${CMAKE_CURRENT_BINARY_DIR}/src\":${BRO_PLUGIN_PATH}\n"
|
||||||
"export PATH=\"${CMAKE_CURRENT_BINARY_DIR}/src\":$PATH\n")
|
"export PATH=\"${CMAKE_CURRENT_BINARY_DIR}/src\":$PATH\n")
|
||||||
|
|
||||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev.csh
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev.csh
|
||||||
"setenv BROPATH `${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev`\n"
|
"setenv BROPATH `${CMAKE_CURRENT_BINARY_DIR}/bro-path-dev`\n"
|
||||||
"setenv BRO_PLUGIN_PATH \"${CMAKE_CURRENT_BINARY_DIR}/src:${BRO_PLUGIN_INSTALL_PATH}\"\n"
|
"setenv BRO_PLUGIN_PATH \"${CMAKE_CURRENT_BINARY_DIR}/src\":${BRO_PLUGIN_PATH}\n"
|
||||||
"setenv PATH \"${CMAKE_CURRENT_BINARY_DIR}/src\":$PATH\n")
|
"setenv PATH \"${CMAKE_CURRENT_BINARY_DIR}/src\":$PATH\n")
|
||||||
|
|
||||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION LIMIT_COUNT 1)
|
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION LIMIT_COUNT 1)
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.3-427
|
2.3-440
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 77a86591dcf89d7252d3676d3f1199d6c927d073
|
Subproject commit 87b732909383c6637437850a75012fe2e376fd10
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0b713c027d3efaaca50e5df995c02656175573cd
|
Subproject commit ccf606ef5dcd2da55efcae2d15fe57fc0b438317
|
|
@ -1 +1 @@
|
||||||
Subproject commit d43cc790e5b8709b5e032e52ad0e00936494739b
|
Subproject commit 7dca802aa8b803033dccc0e6ec9e92a98f709740
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8c9b87bc73e1ddaa304e3d89028c1e7b95d37a91
|
Subproject commit d1c3c5de0f4e8cff923c076ce39d72a86798dbde
|
|
@ -1 +1 @@
|
||||||
Subproject commit ad600b5bdcd56a2723e323c0f2c8e1708956ca4f
|
Subproject commit 14c78567d971dc7fcdc84e36716a1ce5adaa2d56
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
||||||
Subproject commit 1316c07f7059647b6c4a496ea36e4b83bb5d8f0f
|
Subproject commit 8c121c844953026fbaf051a1b065c1671ed47c5b
|
|
@ -3,7 +3,7 @@
|
||||||
Writing Bro Plugins
|
Writing Bro Plugins
|
||||||
===================
|
===================
|
||||||
|
|
||||||
Bro is internally moving to a plugin structure that enables extending
|
Bro internally provides plugin API that enables extending
|
||||||
the system dynamically, without modifying the core code base. That way
|
the system dynamically, without modifying the core code base. That way
|
||||||
custom code remains self-contained and can be maintained, compiled,
|
custom code remains self-contained and can be maintained, compiled,
|
||||||
and installed independently. Currently, plugins can add the following
|
and installed independently. Currently, plugins can add the following
|
||||||
|
@ -42,18 +42,17 @@ certain structure. To get started, Bro's distribution provides a
|
||||||
helper script ``aux/bro-aux/plugin-support/init-plugin`` that creates
|
helper script ``aux/bro-aux/plugin-support/init-plugin`` that creates
|
||||||
a skeleton plugin that can then be customized. Let's use that::
|
a skeleton plugin that can then be customized. Let's use that::
|
||||||
|
|
||||||
# mkdir rot13-plugin
|
# init-plugin ./rot13-plugin Demo Rot13
|
||||||
# cd rot13-plugin
|
|
||||||
# init-plugin Demo Rot13
|
|
||||||
|
|
||||||
As you can see the script takes two arguments. The first is a
|
As you can see, the script takes three arguments. The first is a
|
||||||
namespace the plugin will live in, and the second a descriptive name
|
directory inside which the plugin skeleton will be created. The second
|
||||||
for the plugin itself. Bro uses the combination of the two to identify
|
is the namespace the plugin will live in, and the third is a descriptive
|
||||||
a plugin. The namespace serves to avoid naming conflicts between
|
name for the plugin itself relative to the namespace. Bro uses the
|
||||||
plugins written by independent developers; pick, e.g., the name of
|
combination of namespace and name to identify a plugin. The namespace
|
||||||
your organisation. The namespace ``Bro`` is reserved for functionality
|
serves to avoid naming conflicts between plugins written by independent
|
||||||
distributed by the Bro Project. In our example, the plugin will be
|
developers; pick, e.g., the name of your organisation. The namespace
|
||||||
called ``Demo::Rot13``.
|
``Bro`` is reserved for functionality distributed by the Bro Project. In
|
||||||
|
our example, the plugin will be called ``Demo::Rot13``.
|
||||||
|
|
||||||
The ``init-plugin`` script puts a number of files in place. The full
|
The ``init-plugin`` script puts a number of files in place. The full
|
||||||
layout is described later. For now, all we need is
|
layout is described later. For now, all we need is
|
||||||
|
@ -61,7 +60,7 @@ layout is described later. For now, all we need is
|
||||||
there as follows::
|
there as follows::
|
||||||
|
|
||||||
# cat src/rot13.bif
|
# cat src/rot13.bif
|
||||||
module CaesarCipher;
|
module Demo;
|
||||||
|
|
||||||
function rot13%(s: string%) : string
|
function rot13%(s: string%) : string
|
||||||
%{
|
%{
|
||||||
|
@ -82,18 +81,22 @@ The syntax of this file is just like any other ``*.bif`` file; we
|
||||||
won't go into it here.
|
won't go into it here.
|
||||||
|
|
||||||
Now we can already compile our plugin, we just need to tell the
|
Now we can already compile our plugin, we just need to tell the
|
||||||
configure script put in place by ``init-plugin`` where the Bro source
|
configure script that ``init-plugin`` put in place where the Bro
|
||||||
tree is located (Bro needs to have been built there first)::
|
source tree is located (Bro needs to have been built there first)::
|
||||||
|
|
||||||
|
# cd rot13-plugin
|
||||||
# ./configure --bro-dist=/path/to/bro/dist && make
|
# ./configure --bro-dist=/path/to/bro/dist && make
|
||||||
[... cmake output ...]
|
[... cmake output ...]
|
||||||
|
|
||||||
Now our ``rot13-plugin`` directory has everything that it needs
|
This builds the plugin in a subdirectory ``build/``. In fact, that
|
||||||
for Bro to recognize it as a dynamic plugin. Once we point Bro to it,
|
subdirectory *becomes* the plugin: when ``make`` finishes, ``build/``
|
||||||
it will pull it in automatically, as we can check with the ``-N``
|
has everything it needs for Bro to recognize it as a dynamic plugin.
|
||||||
|
|
||||||
|
Let's try that. Once we point Bro to the ``build/`` directory, it will
|
||||||
|
pull in our new plugin automatically, as we can check with the ``-N``
|
||||||
option::
|
option::
|
||||||
|
|
||||||
# export BRO_PLUGIN_PATH=/path/to/rot13-plugin
|
# export BRO_PLUGIN_PATH=/path/to/rot13-plugin/build
|
||||||
# bro -N
|
# bro -N
|
||||||
[...]
|
[...]
|
||||||
Plugin: Demo::Rot13 - <Insert brief description of plugin> (dynamic, version 1)
|
Plugin: Demo::Rot13 - <Insert brief description of plugin> (dynamic, version 1)
|
||||||
|
@ -127,12 +130,12 @@ more verbose option ``-NN``::
|
||||||
# bro -NN
|
# bro -NN
|
||||||
[...]
|
[...]
|
||||||
Plugin: Demo::Rot13 - Caesar cipher rotating a string's characters by 13 places. (dynamic, version 1)
|
Plugin: Demo::Rot13 - Caesar cipher rotating a string's characters by 13 places. (dynamic, version 1)
|
||||||
[Function] CaesarCipher::rot13
|
[Function] Demo::rot13
|
||||||
[...]
|
[...]
|
||||||
|
|
||||||
There's our function. Now let's use it::
|
There's our function. Now let's use it::
|
||||||
|
|
||||||
# bro -e 'print CaesarCipher::rot13("Hello")'
|
# bro -e 'print Demo::rot13("Hello")'
|
||||||
Uryyb
|
Uryyb
|
||||||
|
|
||||||
It works. We next install the plugin along with Bro itself, so that it
|
It works. We next install the plugin along with Bro itself, so that it
|
||||||
|
@ -141,36 +144,40 @@ environment variable. If we first unset the variable, the function
|
||||||
will no longer be available::
|
will no longer be available::
|
||||||
|
|
||||||
# unset BRO_PLUGIN_PATH
|
# unset BRO_PLUGIN_PATH
|
||||||
# bro -e 'print CaesarCipher::rot13("Hello")'
|
# bro -e 'print Demo::rot13("Hello")'
|
||||||
error in <command line>, line 1: unknown identifier CaesarCipher::rot13, at or near "CaesarCipher::rot13"
|
error in <command line>, line 1: unknown identifier Demo::rot13, at or near "Demo::rot13"
|
||||||
|
|
||||||
Once we install it, it works again::
|
Once we install it, it works again::
|
||||||
|
|
||||||
# make install
|
# make install
|
||||||
# bro -e 'print CaesarCipher::rot13("Hello")'
|
# bro -e 'print Demo::rot13("Hello")'
|
||||||
Uryyb
|
Uryyb
|
||||||
|
|
||||||
The installed version went into
|
The installed version went into
|
||||||
``<bro-install-prefix>/lib/bro/plugins/Demo_Rot13``.
|
``<bro-install-prefix>/lib/bro/plugins/Demo_Rot13``.
|
||||||
|
|
||||||
We can distribute the plugin in either source or binary form by using
|
One can distribute the plugin independently of Bro for others to use.
|
||||||
the Makefile's ``sdist`` and ``bdist`` target, respectively. Both
|
To distribute in source form, just remove the ``build/`` (``make
|
||||||
create corrsponding tarballs::
|
distclean`` does that) and then tar up the whole ``rot13-plugin/``
|
||||||
|
directory. Others then follow the same process as above after
|
||||||
|
unpacking. To distribute the plugin in binary form, the build process
|
||||||
|
conveniently creates a corresponding tarball in ``build/dist/``. In
|
||||||
|
this case, it's called ``Demo_Rot13-0.1.tar.gz``, with the version
|
||||||
|
number coming out of the ``VERSION`` file that ``init-plugin`` put
|
||||||
|
into place. The binary tarball has everything needed to run the
|
||||||
|
plugin, but no further source files. Optionally, one can include
|
||||||
|
further files by specifying them in the plugin's ``CMakeLists.txt``
|
||||||
|
through the ``bro_plugin_dist_files`` macro; the skeleton does that
|
||||||
|
for ``README``, ``VERSION``, ``CHANGES``, and ``COPYING``. To use the
|
||||||
|
plugin through the binary tarball, just unpack it and point
|
||||||
|
``BRO_PLUGIN_PATH`` there; or copy it into
|
||||||
|
``<bro-install-prefix>/lib/bro/plugins/`` directly.
|
||||||
|
|
||||||
# make sdist
|
Before distributing your plugin, you should edit some of the meta
|
||||||
[...]
|
files that ``init-plugin`` puts in place. Edit ``README`` and
|
||||||
Source distribution in build/sdist/Demo_Rot13.tar.gz
|
``VERSION``, and update ``CHANGES`` when you make changes. Also put a
|
||||||
|
license file in place as ``COPYING``; if BSD is fine, you find a
|
||||||
# make bdist
|
template in ``COPYING.edit-me``.
|
||||||
[...]
|
|
||||||
Binary distribution in build/Demo_Rot13-darwin-x86_64.tar.gz
|
|
||||||
|
|
||||||
The source archive will contain everything in the plugin directory
|
|
||||||
except any generated files. The binary archive will contain anything
|
|
||||||
needed to install and run the plugin, i.e., just what ``make install``
|
|
||||||
puts into place as well. As the binary distribution is
|
|
||||||
platform-dependent, its name includes the OS and architecture the
|
|
||||||
plugin was built on.
|
|
||||||
|
|
||||||
Plugin Directory Layout
|
Plugin Directory Layout
|
||||||
=======================
|
=======================
|
||||||
|
@ -179,7 +186,7 @@ A plugin's directory needs to follow a set of conventions so that Bro
|
||||||
(1) recognizes it as a plugin, and (2) knows what to load. While
|
(1) recognizes it as a plugin, and (2) knows what to load. While
|
||||||
``init-plugin`` takes care of most of this, the following is the full
|
``init-plugin`` takes care of most of this, the following is the full
|
||||||
story. We'll use ``<base>`` to represent a plugin's top-level
|
story. We'll use ``<base>`` to represent a plugin's top-level
|
||||||
directory.
|
directory. With the skeleton, ``<base>`` corresponds to ``build/``.
|
||||||
|
|
||||||
``<base>/__bro_plugin__``
|
``<base>/__bro_plugin__``
|
||||||
A file that marks a directory as containing a Bro plugin. The file
|
A file that marks a directory as containing a Bro plugin. The file
|
||||||
|
@ -205,6 +212,8 @@ directory.
|
||||||
Directory with auto-generated Bro scripts that declare the plugin's
|
Directory with auto-generated Bro scripts that declare the plugin's
|
||||||
bif elements. The files here are produced by ``bifcl``.
|
bif elements. The files here are produced by ``bifcl``.
|
||||||
|
|
||||||
|
Any other files in ``<base>`` are ignored by Bro.
|
||||||
|
|
||||||
By convention, a plugin should put its custom scripts into sub folders
|
By convention, a plugin should put its custom scripts into sub folders
|
||||||
of ``scripts/``, i.e., ``scripts/<script-namespace>/<script>.bro`` to
|
of ``scripts/``, i.e., ``scripts/<script-namespace>/<script>.bro`` to
|
||||||
avoid conflicts. As usual, you can then put a ``__load__.bro`` in
|
avoid conflicts. As usual, you can then put a ``__load__.bro`` in
|
||||||
|
@ -229,15 +238,19 @@ their source directory (after ``make`` and setting Bro's
|
||||||
install``).
|
install``).
|
||||||
|
|
||||||
``make install`` copies over the ``lib`` and ``scripts`` directories,
|
``make install`` copies over the ``lib`` and ``scripts`` directories,
|
||||||
as well as the ``__bro_plugin__`` magic file and the ``README`` (which
|
as well as the ``__bro_plugin__`` magic file and any further
|
||||||
you should customize). One can add further CMake ``install`` rules to
|
distribution files specified in ``CMakeLists.txt`` (e.g., README,
|
||||||
install additional files if needed.
|
VERSION). You can find a full list of files installed in
|
||||||
|
``build/MANIFEST``. Behind the scenes, ``make install`` really just
|
||||||
|
copies over the binary tarball in ``build/dist``.
|
||||||
|
|
||||||
``init-plugin`` will never overwrite existing files, so it's safe to
|
``init-plugin`` will never overwrite existing files. If its target
|
||||||
rerun in an existing plugin directory; it only put files in place that
|
directory already exists, it will be default decline to do anything.
|
||||||
don't exist yet. That also provides a convenient way to revert a file
|
You can run it with ``-u`` instead to update an existing plugin,
|
||||||
back to what ``init-plugin`` created originally: just delete it and
|
however it will never overwrite any existing files; it will only put
|
||||||
rerun.
|
in place files it doesn't find yet. To revert a file back to what
|
||||||
|
``init-plugin`` created originally, delete it first and then rerun
|
||||||
|
with ``-u``.
|
||||||
|
|
||||||
Activating a Plugin
|
Activating a Plugin
|
||||||
===================
|
===================
|
||||||
|
@ -355,7 +368,7 @@ let's get that in place::
|
||||||
% cat .diag
|
% cat .diag
|
||||||
== File ===============================
|
== File ===============================
|
||||||
Demo::Rot13 - Caesar cipher rotating a string's characters by 13 places. (dynamic, version 1.0)
|
Demo::Rot13 - Caesar cipher rotating a string's characters by 13 places. (dynamic, version 1.0)
|
||||||
[Function] CaesarCipher::rot13
|
[Function] Demo::rot13
|
||||||
|
|
||||||
== Error ===============================
|
== Error ===============================
|
||||||
test-diff: no baseline found.
|
test-diff: no baseline found.
|
||||||
|
@ -375,14 +388,14 @@ Now let's add a custom test that ensures that our bif works
|
||||||
correctly::
|
correctly::
|
||||||
|
|
||||||
# cd tests
|
# cd tests
|
||||||
# cat >plugin/rot13.bro
|
# cat >rot13/bif-rot13.bro
|
||||||
|
|
||||||
# @TEST-EXEC: bro %INPUT >output
|
# @TEST-EXEC: bro %INPUT >output
|
||||||
# @TEST-EXEC: btest-diff output
|
# @TEST-EXEC: btest-diff output
|
||||||
|
|
||||||
event bro_init()
|
event bro_init()
|
||||||
{
|
{
|
||||||
print CaesarCipher::rot13("Hello");
|
print Demo::rot13("Hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
Check the output::
|
Check the output::
|
||||||
|
@ -415,7 +428,7 @@ Debugging Plugins
|
||||||
=================
|
=================
|
||||||
|
|
||||||
If your plugin isn't loading as expected, Bro's debugging facilities
|
If your plugin isn't loading as expected, Bro's debugging facilities
|
||||||
can help to illuminate what's going on. To enable, recompile Bro
|
can help illuminate what's going on. To enable, recompile Bro
|
||||||
with debugging support (``./configure --enable-debug``), and
|
with debugging support (``./configure --enable-debug``), and
|
||||||
afterwards rebuild your plugin as well. If you then run Bro with ``-B
|
afterwards rebuild your plugin as well. If you then run Bro with ``-B
|
||||||
plugins``, it will produce a file ``debug.log`` that records details
|
plugins``, it will produce a file ``debug.log`` that records details
|
||||||
|
@ -435,7 +448,6 @@ replaced with a simple dash. Example: If the plugin is called
|
||||||
output will be recorded to ``debug.log`` if Bro's compiled in debug
|
output will be recorded to ``debug.log`` if Bro's compiled in debug
|
||||||
mode.
|
mode.
|
||||||
|
|
||||||
|
|
||||||
Documenting Plugins
|
Documenting Plugins
|
||||||
===================
|
===================
|
||||||
|
|
||||||
|
|
|
@ -408,6 +408,18 @@ add_dependencies(bro bif_loader_plugins)
|
||||||
# Install *.bif.bro.
|
# Install *.bif.bro.
|
||||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/scripts/base/bif DESTINATION ${BRO_SCRIPT_INSTALL_PATH}/base)
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/scripts/base/bif DESTINATION ${BRO_SCRIPT_INSTALL_PATH}/base)
|
||||||
|
|
||||||
|
# Create plugin directory at install time.
|
||||||
|
install(DIRECTORY DESTINATION ${BRO_PLUGIN_INSTALL_PATH})
|
||||||
|
|
||||||
# Make clean removes the bif directory.
|
# Make clean removes the bif directory.
|
||||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/scripts/base/bif)
|
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/scripts/base/bif)
|
||||||
|
|
||||||
|
# Remove some stale files and scripts that previous Bro versions put in
|
||||||
|
# place, yet make confuse us now. This makes upgrading easier.
|
||||||
|
install(CODE "
|
||||||
|
file(REMOVE_RECURSE
|
||||||
|
${BRO_SCRIPT_INSTALL_PATH}/base/frameworks/logging/writers/dataseries.bro
|
||||||
|
${BRO_SCRIPT_INSTALL_PATH}/base/frameworks/logging/writers/elasticsearch.bro
|
||||||
|
${BRO_SCRIPT_INSTALL_PATH}/policy/tuning/logs-to-elasticsearch.bro
|
||||||
|
)
|
||||||
|
")
|
||||||
|
|
|
@ -79,18 +79,19 @@ void Manager::SearchDynamicPlugins(const std::string& dir)
|
||||||
std::string name;
|
std::string name;
|
||||||
std::getline(in, name);
|
std::getline(in, name);
|
||||||
strstrip(name);
|
strstrip(name);
|
||||||
|
string lower_name = strtolower(name);
|
||||||
|
|
||||||
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(name) != dynamic_plugins.end() )
|
if ( dynamic_plugins.find(lower_name) != dynamic_plugins.end() )
|
||||||
{
|
{
|
||||||
DBG_LOG(DBG_PLUGINS, "Found already known plugin %s in %s, ignoring", name.c_str(), dir.c_str());
|
DBG_LOG(DBG_PLUGINS, "Found already known plugin %s in %s, ignoring", name.c_str(), dir.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record it, so that we can later activate it.
|
// Record it, so that we can later activate it.
|
||||||
dynamic_plugins.insert(std::make_pair(name, dir));
|
dynamic_plugins.insert(std::make_pair(lower_name, dir));
|
||||||
|
|
||||||
DBG_LOG(DBG_PLUGINS, "Found plugin %s in %s", name.c_str(), dir.c_str());
|
DBG_LOG(DBG_PLUGINS, "Found plugin %s in %s", name.c_str(), dir.c_str());
|
||||||
return;
|
return;
|
||||||
|
@ -135,7 +136,7 @@ void Manager::SearchDynamicPlugins(const std::string& dir)
|
||||||
|
|
||||||
bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_not_found)
|
bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_not_found)
|
||||||
{
|
{
|
||||||
dynamic_plugin_map::iterator m = dynamic_plugins.find(name);
|
dynamic_plugin_map::iterator m = dynamic_plugins.find(strtolower(name));
|
||||||
|
|
||||||
if ( m == dynamic_plugins.end() )
|
if ( m == dynamic_plugins.end() )
|
||||||
{
|
{
|
||||||
|
@ -230,7 +231,7 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
|
||||||
|
|
||||||
// Make sure the name the plugin reports is consistent with
|
// Make sure the name the plugin reports is consistent with
|
||||||
// what we expect from its magic file.
|
// what we expect from its magic file.
|
||||||
if ( string(current_plugin->Name()) != name )
|
if ( strtolower(current_plugin->Name()) != strtolower(name) )
|
||||||
reporter->FatalError("inconsistent plugin name: %s vs %s",
|
reporter->FatalError("inconsistent plugin name: %s vs %s",
|
||||||
current_plugin->Name().c_str(), name.c_str());
|
current_plugin->Name().c_str(), name.c_str());
|
||||||
|
|
||||||
|
@ -297,7 +298,7 @@ void Manager::UpdateInputFiles()
|
||||||
|
|
||||||
static bool plugin_cmp(const Plugin* a, const Plugin* b)
|
static bool plugin_cmp(const Plugin* a, const Plugin* b)
|
||||||
{
|
{
|
||||||
return a->Name() < b->Name();
|
return strtolower(a->Name()) < strtolower(b->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::RegisterPlugin(Plugin *plugin)
|
void Manager::RegisterPlugin(Plugin *plugin)
|
||||||
|
@ -318,10 +319,11 @@ void Manager::RegisterBifFile(const char* plugin, bif_init_func c)
|
||||||
{
|
{
|
||||||
bif_init_func_map* bifs = BifFilesInternal();
|
bif_init_func_map* bifs = BifFilesInternal();
|
||||||
|
|
||||||
bif_init_func_map::iterator i = bifs->find(plugin);
|
std::string lower_plugin = strtolower(plugin);
|
||||||
|
bif_init_func_map::iterator i = bifs->find(lower_plugin);
|
||||||
|
|
||||||
if ( i == bifs->end() )
|
if ( i == bifs->end() )
|
||||||
i = bifs->insert(std::make_pair(std::string(plugin), new bif_init_func_list())).first;
|
i = bifs->insert(std::make_pair(lower_plugin, new bif_init_func_list())).first;
|
||||||
|
|
||||||
i->second->push_back(c);
|
i->second->push_back(c);
|
||||||
}
|
}
|
||||||
|
@ -348,7 +350,7 @@ void Manager::InitBifs()
|
||||||
for ( plugin_list::iterator i = Manager::ActivePluginsInternal()->begin();
|
for ( plugin_list::iterator i = Manager::ActivePluginsInternal()->begin();
|
||||||
i != Manager::ActivePluginsInternal()->end(); i++ )
|
i != Manager::ActivePluginsInternal()->end(); i++ )
|
||||||
{
|
{
|
||||||
bif_init_func_map::const_iterator b = bifs->find((*i)->Name());
|
bif_init_func_map::const_iterator b = bifs->find(strtolower((*i)->Name()));
|
||||||
|
|
||||||
if ( b != bifs->end() )
|
if ( b != bifs->end() )
|
||||||
{
|
{
|
||||||
|
@ -397,7 +399,7 @@ Manager::inactive_plugin_list Manager::InactivePlugins() const
|
||||||
|
|
||||||
for ( plugin_list::const_iterator j = all->begin(); j != all->end(); j++ )
|
for ( plugin_list::const_iterator j = all->begin(); j != all->end(); j++ )
|
||||||
{
|
{
|
||||||
if ( (*i).first == (*j)->Name() )
|
if ( (*i).first == strtolower((*j)->Name()) )
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -434,7 +436,7 @@ Manager::bif_init_func_map* Manager::BifFilesInternal()
|
||||||
static bool hook_cmp(std::pair<int, Plugin*> a, std::pair<int, Plugin*> b)
|
static bool hook_cmp(std::pair<int, Plugin*> a, std::pair<int, Plugin*> b)
|
||||||
{
|
{
|
||||||
if ( a.first == b.first )
|
if ( a.first == b.first )
|
||||||
return a.second->Name() < a.second->Name();
|
return strtolower(a.second->Name()) < strtolower(a.second->Name());
|
||||||
|
|
||||||
// Reverse sort.
|
// Reverse sort.
|
||||||
return a.first > b.first;
|
return a.first > b.first;
|
||||||
|
|
|
@ -541,6 +541,13 @@ bool is_printable(const char* s, int len)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string strtolower(const std::string& s)
|
||||||
|
{
|
||||||
|
std::string t = s;
|
||||||
|
std::transform(t.begin(), t.end(), t.begin(), ::tolower);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
const char* fmt_bytes(const char* data, int len)
|
const char* fmt_bytes(const char* data, int len)
|
||||||
{
|
{
|
||||||
static char buf[1024];
|
static char buf[1024];
|
||||||
|
|
|
@ -159,6 +159,9 @@ int strstr_n(const int big_len, const unsigned char* big,
|
||||||
extern int fputs(int len, const char* s, FILE* fp);
|
extern int fputs(int len, const char* s, FILE* fp);
|
||||||
extern bool is_printable(const char* s, int len);
|
extern bool is_printable(const char* s, int len);
|
||||||
|
|
||||||
|
// Return a lower-cased version of the string.
|
||||||
|
extern std::string strtolower(const std::string& s);
|
||||||
|
|
||||||
extern const char* fmt_bytes(const char* data, int len);
|
extern const char* fmt_bytes(const char* data, int len);
|
||||||
|
|
||||||
// Note: returns a pointer into a shared buffer.
|
// Note: returns a pointer into a shared buffer.
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
fatal error in /home/robin/bro/master/scripts/base/init-bare.bro, line 1: plugin's API version does not match Bro (expected 2, got 42 in /home/robin/bro/master/testing/btest/.tmp/plugins.api-version-mismatch//lib/XXX)
|
fatal error in /home/robin/bro/plugins/scripts/base/init-bare.bro, line 1: plugin's API version does not match Bro (expected 2, got 42 in /home/robin/bro/plugins/testing/btest/.tmp/plugins.api-version-mismatch/build//lib/XXX)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Demo::Foo - <Insert description> (dynamic, version 1.0)
|
Demo::Foo - <Insert description> (dynamic, version 0.1)
|
||||||
[Function] hello_plugin_world
|
[Function] hello_plugin_world
|
||||||
[Event] plugin_event
|
[Event] plugin_event
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Demo::Foo - <Insert description> (dynamic, version 1.0)
|
Demo::Foo - <Insert description> (dynamic, version 0.1)
|
||||||
[Function] hello_plugin_world
|
[Function] hello_plugin_world
|
||||||
[Event] plugin_event
|
[Event] plugin_event
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
Demo::Foo - <Insert description> (dynamic, version 1.0)
|
Demo::Foo - <Insert description> (dynamic, version 0.1)
|
||||||
|
|
||||||
===
|
===
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
||||||
# @TEST-EXEC: bash %INPUT
|
# @TEST-EXEC: bash %INPUT
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||||
# @TEST-EXEC-FAIL: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >tmp 2>&1
|
# @TEST-EXEC-FAIL: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >tmp 2>&1
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
||||||
# @TEST-EXEC: bash %INPUT
|
# @TEST-EXEC: bash %INPUT
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} --install-root=`pwd`/test-install
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} --install-root=`pwd`/test-install
|
||||||
# @TEST-EXEC: make
|
# @TEST-EXEC: make
|
||||||
# @TEST-EXEC: make install
|
# @TEST-EXEC: make install
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd`/test-install bro -NN Demo::Foo >>output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd`/test-install bro -NN Demo::Foo >>output
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro demo/foo -r $TRACES/empty.trace >>output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd`/test-install bro demo/foo -r $TRACES/empty.trace >>output
|
||||||
# @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff output
|
# @TEST-EXEC: TEST_DIFF_CANONIFIER= btest-diff output
|
||||||
|
|
||||||
mkdir -p scripts/demo/foo/base/
|
mkdir -p scripts/demo/foo/base/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
||||||
# @TEST-EXEC: bash %INPUT
|
# @TEST-EXEC: bash %INPUT
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
||||||
# @TEST-EXEC: cp -r %DIR/file-plugin/* .
|
# @TEST-EXEC: cp -r %DIR/file-plugin/* .
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Hooks
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Hooks
|
||||||
# @TEST-EXEC: cp -r %DIR/hooks-plugin/* .
|
# @TEST-EXEC: cp -r %DIR/hooks-plugin/* .
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -r $TRACES/http/get.trace %INPUT 2>&1 | $SCRIPTS/diff-remove-abspath | sort | uniq >output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -r $TRACES/http/get.trace %INPUT 2>&1 | $SCRIPTS/diff-remove-abspath | sort | uniq >output
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
||||||
# @TEST-EXEC: echo === >>output
|
# @TEST-EXEC: echo === >>output
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
||||||
# @TEST-EXEC: cp -r %DIR/pktdumper-plugin/* .
|
# @TEST-EXEC: cp -r %DIR/pktdumper-plugin/* .
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
||||||
# @TEST-EXEC: cp -r %DIR/pktsrc-plugin/* .
|
# @TEST-EXEC: cp -r %DIR/pktsrc-plugin/* .
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
||||||
# @TEST-EXEC: cp -r %DIR/protocol-plugin/* .
|
# @TEST-EXEC: cp -r %DIR/protocol-plugin/* .
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
||||||
# @TEST-EXEC: cp -r %DIR/reader-plugin/* .
|
# @TEST-EXEC: cp -r %DIR/reader-plugin/* .
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin Demo Foo
|
# @TEST-EXEC: ${DIST}/aux/bro-aux/plugin-support/init-plugin -u . Demo Foo
|
||||||
# @TEST-EXEC: cp -r %DIR/writer-plugin/* .
|
# @TEST-EXEC: cp -r %DIR/writer-plugin/* .
|
||||||
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
# @TEST-EXEC: ./configure --bro-dist=${DIST} && make
|
||||||
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
# @TEST-EXEC: BRO_PLUGIN_PATH=`pwd` bro -NN Demo::Foo >>output
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue