Skip to content

Commit

Permalink
devguide: explain example-rule container usage
Browse files Browse the repository at this point in the history
Have these options documented, so that whoever writes rule-related
documentation can easily know what they could use to make the doc look
better.
  • Loading branch information
jufajardini authored and victorjulien committed Jan 4, 2024
1 parent d321838 commit a37fa62
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion doc/userguide/devguide/contributing/contribution-process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ Documentation Style
For documenting *code*, please follow Rust documentation and/or Doxygen
guidelines, according to what your contribution is using (Rust or C).

If you are writing or updating *documentation pages*, please:
When writing or updating *documentation pages*, please:

* wrap up lines at 79 (80 at most) characters;
* when adding diagrams or images, we prefer alternatives that can be generated
Expand All @@ -208,6 +208,67 @@ If you are writing or updating *documentation pages*, please:
/docs.suricata.io/en/latest/#suricata-user-guide>`_ and can also be
built to pdf, so it is important that it looks good in such formats.

Rule examples
-------------

.. role:: example-rule-action
.. role:: example-rule-header
.. role:: example-rule-options
.. role:: example-rule-emphasis

For rule documentation, we have a special container::

example-rule

This will present the rule in a box with an easier to read font size, and also
allows highlighting specific elements in the signature, as the names indicate
- action, header, options, or emphasize custom portions:

- example-rule-action
- example-rule-header
- example-rule-options
- example-rule-emphasis

When using these, indicate the portion to be highlighted by surrounding it with
` . Before using them, one has to invoke the specific role, like so::

.. role:: example-rule-role

It is only necessary to invoke the role once per document. One can see these
being invoked in our introduction to the rule language (see `Rules intro
<https://raw.githubusercontent.com/OISF/suricata/master/doc/userguide/rules/intro.rst>`_).

A rule example like::

.. container:: example-rule

:example-rule-action:`alert` :example-rule-header:`http $HOME_NET any ->
$EXTERNAL_NET any` :example-rule-options:`(msg:"HTTP GET Request Containing
Rule in URI"; flow:established,to_server; http.method; content:"GET"; http.uri;
content:"rule"; fast_pattern; classtype:bad-unknown; sid:123; rev:1;)`

Results in:

.. container:: example-rule

:example-rule-action:`alert` :example-rule-header:`http $HOME_NET any ->
$EXTERNAL_NET any` :example-rule-options:`(msg:"HTTP GET Request Containing
Rule in URI"; flow:established,to_server; http.method; content:"GET"; http.uri;
content:"rule"; fast_pattern; classtype:bad-unknown; sid:123; rev:1;)`

Example - emphasis::

.. container:: example-rule

alert ssh any any -> any any (msg:"match SSH protocol version";
:example-rule-emphasis:`ssh.proto;` content:"2.0"; sid:1000010;)

Renders as:

.. container:: example-rule

alert ssh any any -> any any (msg:"match SSH protocol version";
:example-rule-emphasis:`ssh.proto;` content:"2.0"; sid:1000010;)

Commit History matters
======================
Expand Down

0 comments on commit a37fa62

Please sign in to comment.