Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect: requires keyword (7.0.x backport) #10206

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 47 additions & 0 deletions doc/userguide/rules/meta.rst
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,50 @@ The format is::
If the value is src_ip then the source IP in the generated event (src_ip
field in JSON) is the target of the attack. If target is set to dest_ip
then the target is the destination IP in the generated event.

requires
--------

The ``requires`` keyword allows a rule to require specific Suricata
features to be enabled, or the Suricata version to match an
expression. Rules that do not meet the requirements will by ignored,
and Suricata will not treat them as errors.

When parsing rules, the parser attempts to process the ``requires``
keywords before others. This allows it to occur after keywords that
may only be present in specific versions of Suricata, as specified by
the ``requires`` statement. However, the keywords preceding it must
still adhere to the basic known formats of Suricata rules.

The format is::

requires: feature geoip, version >= 7.0.0

To require multiple features, the feature sub-keyword must be
specified multiple times::

requires: feature geoip, feature lua

Alternatively, *and* expressions may be expressed like::

requires: version >= 7.0.4 < 8

and *or* expressions may expressed with ``|`` like::

requires: version >= 7.0.4 < 8 | >= 8.0.3

to express that a rules requires version 7.0.4 or greater, but less
than 8, **OR** greater than or equal to 8.0.3. Which could be useful
if a keyword wasn't added until 7.0.4 and the 8.0.3 patch releases, as
it would not exist in 8.0.1.

This can be extended to multiple release branches::

requires: version >= 7.0.10 < 8 | >= 8.0.5 < 9 | >= 9.0.3

If no *minor* or *patch* version component is provided, it will
default to 0.

The ``version`` may only be specified once, if specified more than
once the rule will log an error and not be loaded.

3 changes: 3 additions & 0 deletions etc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4851,6 +4851,9 @@
},
"rules_failed": {
"type": "integer"
},
"rules_skipped": {
"type": "integer"
}
},
"additionalProperties": false
Expand Down
1 change: 1 addition & 0 deletions rust/src/detect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ pub mod parser;
pub mod stream_size;
pub mod uint;
pub mod uri;
pub mod requires;