Skip to content

Commit

Permalink
Documentation updates for un-deprecation of Spicy's port.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmmr committed Aug 19, 2024
1 parent 2f14aee commit f06db5c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
32 changes: 32 additions & 0 deletions devel/spicy/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,38 @@ properties are supported:
``SPICY_UNIT`` may define (as long as the attribute's
direction is not ``originator``).

.. note::

.. _zeek_init_instead_of_port:

While using ``port`` (or ``%port``) can be convinient, for
production analyzers we recommended to instead register
their well-known ports from inside a Zeek script, using a
snippet like this:

.. code-block:: zeek
module MyAnalyzer;
export {
const ports = { 12345/tcp } &redef;
}
redef likely_server_ports += { ports };
event zeek_init() &priority=5
{
Analyzer::register_for_ports(Analyzer::ANALYZER_MY_ANALYZER, ports);
}
This follows the idiomatic Zeek pattern for defining
well-known ports that allows users to customize them
through their own site-specific scripts (e.g., ``redef
MyAnalyzer::port += { 12346/tcp };``). The :ref:`package
template <zkg_create_package>` includes such code instead
of defining ports inside the EVT file.


``replaces ANALYZER_NAME``
Replaces a built-in analyzer that Zeek already provides with a
new Spicy version by internally disabling the existing
Expand Down
8 changes: 8 additions & 0 deletions devel/spicy/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ analyzer for all sessions on UDP port 69 (i.e., TFTP's well known
port). See :ref:`spicy_evt_analyzer_setup` for more details on defining
such a ``protocol analyzer`` section.

.. note::

We use the ``port`` attribute in the ``protocol analyzer`` section
mainly for convenience; it's not the only way to define the
well-known ports. For a production analyzer, it's more idiomatic
to use the a Zeek script instead; see :ref:`this note
<zeek_init_instead_of_port>` for more information.

With this in place, we can already employ the analyzer inside Zeek. It
will not generate any events yet, but we can at least see the output of
the ``on %done { print self; }`` hook that still remains part of the
Expand Down

0 comments on commit f06db5c

Please sign in to comment.