suricata_check.utils.rule¶
Module replacing idstools.rule and providing limited but similar functionality.
This module is inspired by and mostly uses the same interface Python idstools package. (https://github.com/jasonish/py-idstools)
Exceptions¶
Raised when a rule cannot be parsed by suricata-check. |
Classes¶
Class representing a rule. |
|
Class representing a rule option. |
Functions¶
|
Parse a rule stringand return a wrapped Rule instance. |
Module Contents¶
- exception suricata_check.utils.rule.ParsingError(message: str)[source]¶
Bases:
RuntimeErrorRaised when a rule cannot be parsed by suricata-check.
Most likely, such a rule is also an invalid Suricata rule.
Initializes the ParsingError with the raw rule as message.
- class suricata_check.utils.rule.Rule(*args: tuple, **kwargs: dict)[source]¶
Class representing a rule.
Private Init function.
Use suricata_check.utils.rule.parse() instead to create Rule instances.
- add_metadata_options(values: collections.abc.Sequence[str]) None[source]¶
Adds metadata options in the rule’s metadata list.
- add_reference_option(value: str) None[source]¶
Adds a reference option in the rule’s references list.
- options: tuple[RuleOption, Ellipsis] = ()¶
- class suricata_check.utils.rule.RuleOption[source]¶
Class representing a rule option.
- suricata_check.utils.rule.parse(buffer: str) Rule | None[source]¶
Parse a rule stringand return a wrapped Rule instance.
Returns None when the text could not be parsed as a rule.
- Parameters:
buffer – A string containing a single Suricata-like rule
- Returns:
An instance of of Rule representing the parsed rule