Blame rulebases/syntax.txt

Packit 1422b7
WARNING
Packit 1422b7
=======
Packit 1422b7
Packit 1422b7
This file is somewhat obsolete, for current information look at doc/
Packit 1422b7
directory.
Packit 1422b7
Packit 1422b7
Basic syntax
Packit 1422b7
============
Packit 1422b7
Packit 1422b7
Each line in rulebase file is evaluated separately.
Packit 1422b7
Lines starting with '#' are commentaries.
Packit 1422b7
Empty lines are just skipped, they can be inserted for readability.
Packit 1422b7
If the line starts with 'rule=', then it contains a rule. This line has
Packit 1422b7
following format:
Packit 1422b7
Packit 1422b7
	rule=[<tag1>[,<tag2>...]]:<match description>
Packit 1422b7
	
Packit 1422b7
Everything before a colon is treated as comma-separated list of tags, which
Packit 1422b7
will be attached to a match. After the colon, match description should be
Packit 1422b7
given. It consists of string literals and field selectors. String literals
Packit 1422b7
should match exactly. Field selector has this format:
Packit 1422b7
Packit 1422b7
	%<field name>:<field type>[:<extra data>]%
Packit 1422b7
Packit 1422b7
Percent sign is used to enclose field selector. If you need to match literal
Packit 1422b7
'%', it can be written as '%%' or '\x25'.
Packit 1422b7
Packit 1422b7
Behaviour of field selector depends on its type, which is decribed below.
Packit 1422b7
Packit 1422b7
If field name is set to '-', this field is matched but not saved.
Packit 1422b7
Packit 1422b7
Several rules can have a common prefix. You can set it once with this syntax:
Packit 1422b7
Packit 1422b7
	prefix=<prefix match description>
Packit 1422b7
	
Packit 1422b7
Every following rule will be treated as an addition to this prefix.
Packit 1422b7
Packit 1422b7
Prefix can be reset to default (empty value) by the line:
Packit 1422b7
Packit 1422b7
	prefix=
Packit 1422b7
Packit 1422b7
Tags of the matched rule are attached to the message and can be used to
Packit 1422b7
annotate it. Annotation allows to add fixed fields to the message.
Packit 1422b7
Syntax is as following:
Packit 1422b7
Packit 1422b7
	annotate=<tag>:+<field name>="<field value>"
Packit 1422b7
Packit 1422b7
Field value should always be enclosed in double quote marks.
Packit 1422b7
Packit 1422b7
There can be multiple annotations for the same tag.
Packit 1422b7
Packit 1422b7
Field types
Packit 1422b7
===========
Packit 1422b7
Packit 1422b7
Field type:		'number'
Packit 1422b7
Matches:		One or more decimal digits.
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field_name:number%
Packit 1422b7
Packit 1422b7
Field type:		'word'
Packit 1422b7
Matches:		One or more characters, up to the next space (\x20), or
Packit 1422b7
				up to end of line.
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field_name:word%
Packit 1422b7
Packit 1422b7
Field type:		'alpha'
Packit 1422b7
Matches:		One or more alphabetic characters, up to the next
Packit 1422b7
				whitespace, punctuation, decimal digit or ctrl.
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field_name:alpha%
Packit 1422b7
Packit 1422b7
Field type:		'char-to'
Packit 1422b7
Matches:		One or more characters, up to the next character given in
Packit 1422b7
				extra data.
Packit 1422b7
Extra data:		One character (can be escaped)
Packit 1422b7
Example:		%field_name:char-to:,%
Packit 1422b7
				%field_name:char-to:\x25%
Packit 1422b7
Packit 1422b7
Field type:		'char-sep'
Packit 1422b7
Matches:		Zero or more characters, up to the next character given in
Packit 1422b7
				extra data, or up to end of line.
Packit 1422b7
Extra data:		One character (can be escaped)
Packit 1422b7
Example:		%field_name:char-sep:,%
Packit 1422b7
				%field_name:char-sep:\x25%
Packit 1422b7
Packit 1422b7
Field type:		'rest'
Packit 1422b7
Matches:		Zero or more characters till end of line.
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field_name:rest%
Packit 1422b7
Notes:			Should be always at end of the rule.
Packit 1422b7
Packit 1422b7
Field type:		'quoted-string'
Packit 1422b7
Matches:		Zero or more characters, surrounded by double quote marks.
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field_name:quoted-string%
Packit 1422b7
Notes:			Quote marks are stripped from the match.
Packit 1422b7
Packit 1422b7
Field type:		'date-iso'
Packit 1422b7
Matches:		Date of format 'YYYY-MM-DD'.
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field-name:date-iso%
Packit 1422b7
Packit 1422b7
Field type:		'time-24hr'
Packit 1422b7
Matches:		Time of format 'HH:MM:SS', where HH is 00..23.
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field_name:time-24hr%
Packit 1422b7
Packit 1422b7
Field type:		'time-12hr'
Packit 1422b7
Matches:		Time of format 'HH:MM:SS', where HH is 00..12.
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field_name:time-12hr%
Packit 1422b7
Packit 1422b7
Field type:		'ipv4'
Packit 1422b7
Matches:		IPv4 address, in dot-decimal notation (AAA.BBB.CCC.DDD).
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field_name:ipv4%
Packit 1422b7
Packit 1422b7
Field type:		'date-rfc3164'
Packit 1422b7
Matches:		Valid date/time in RFC3164 format, i.e.: 'Oct 29 09:47:08'
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field_name:date-rfc3164%
Packit 1422b7
Notes:			This parser implements several quirks to match malformed
Packit 1422b7
				timestamps from some devices.
Packit 1422b7
Packit 1422b7
Field type:		'date-rfc5424'
Packit 1422b7
Matches:		Valid date/time in RFC5424 format, i.e.:
Packit 1422b7
				'1985-04-12T19:20:50.52-04:00'
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%field_name:date-rfc5424%
Packit 1422b7
Notes:			Slightly different formats are allowed.
Packit 1422b7
Packit 1422b7
Field type:		'iptables'
Packit 1422b7
Matches:		Name=value pairs, separated by spaces, as in Netfilter log
Packit 1422b7
				messages.
Packit 1422b7
Extra data:		Not used
Packit 1422b7
Example:		%-:iptables%
Packit 1422b7
Notes:			Name of the selector is not used; names from the line are 
Packit 1422b7
				used instead. This selector always matches everything till 
Packit 1422b7
				end of the line. Cannot match zero characters.
Packit 1422b7
Packit 1422b7
Examples
Packit 1422b7
========
Packit 1422b7
Packit 1422b7
Look at sample.rulebase for example rules and matching lines.