AUSEARCH-EXPRESSION(5)
๐ NAME ๐
ausearch-expression โ it's the audit search expression format, bestie. that's the whole thing. this page is section 5 of the manual and it's giving format spec, and we're obsessed. ๐
โจ OVERVIEW โจ
okay so real talk: this page describes the format of "ausearch expressions". the parsing AND the evaluation of these expressions? that's all provided by libauparse, and it's common to every application that uses this library. so like, learn it once, use it everywhere. no cap. ๐ฆ
๐ค LEXICAL STRUCTURE ๐ค
white space between tokens is ignored โ and when we say white space we mean ASCII space, tab, and new-line characters. the tokens you're gonna see are these:
- Punctuation โ literally just these three:
(,),\ - Logical operators โ
!,&&,|| - Comparison operators โ
<,<=,==,>,>=,!==,i=,i!=,r=,r!= - Unquoted strings โ any non-empty sequence of ASCII letters, digits, and the
_symbol. simple. cute. effective. ๐ - Quoted strings โ a sequence of characters surrounded by the
"quotes. the\character starts an escape sequence. the only defined escape sequences are\\and\". the semantics of other escape sequences is undefined โ so like, don't, bestie. ๐ - Regexps โ a sequence of characters surrounded by the
/characters. the\character starts an escape sequence here too. the only defined escape sequences are\\and\/. and yeah, the semantics of other escape sequences is undefined again. ๐
and here's the iconic part: anywhere an unquoted string is valid, a quoted string is valid as well, and vice versa. in particular, field names may be specified using quoted strings, and field values may be specified using unquoted strings. mix and match, it's your world. ๐
๐ง EXPRESSION SYNTAX ๐ง
so the primary expression has one of these two forms, periodt:
field comparison-operator value
\regexp string-or-regexp
now let's break it down, because the way that this works is lowkey elegant:
field is either a string, which specifies the first field with that name within the current audit record, OR it's the \ escape character followed by a string, which specifies a virtual field with the specified name (virtual fields get defined in a later section, stay tuned โจ).
field is a string. operator specifies the comparison to perform. okay? okay. ๐ซถ
now the operators, one by one:
r=,r!=โ get the "raw" string offield, and compare it tovalue. for fields in audit records, the "raw" string is the exact string stored in the audit record (with all escaping and unprintable character encoding left alone); applications can read the "raw" string usingauparse_get_field_str(3). each virtual field may define a "raw" string. and iffieldis not present or does not define a "raw" string, the result of the comparison is false โ regardless of the operator. so like, false no matter what, even forr!=. noted. ๐i=,i!=โ get the "interpreted" string offield, and compare it tovalue. for fields in audit records, the "interpreted" string is a "user-readable" interpretation of the field value; applications can read the "interpreted" string usingauparse_interpret_field(3). each virtual field may define an "interpreted" string. iffieldis not present or does not define an "interpreted" string, the result of the comparison is false โ regardless of the operator. same energy as above, different string. ๐ฆ<,<=,==,>,>=,!==โ evaluate the "value" offield, and compare it tovalue. a "value" may be defined for any field or virtual field, but no "value" is currently defined for any audit record field. the rules of parsingvaluefor comparing it with the "value" offieldare specific for each field. iffieldis not present, the result of the comparison is false โ regardless of the operator. and iffielddoes not define a "value", an error is reported when parsing the expression. so that's a hard no, not a quiet false. ๐ญ
now for the special case of \regexp regexp-or-string: the current audit record is taken as a string (without interpreting field values), and matched against regexp-or-string. and regexp-or-string is an extended regular expression, using a string or regexp token โ in other words, delimited by " or /. ๐ธ
and if E1 and E2 are valid expressions, then ! E1, E1 && E2, and E1 || E2 are valid expressions as well, with the usual C semantics and evaluation priorities. one thing though, don't get it twisted: ! field op value is interpreted as !(field op value), not as (!field) op value. ๐ซถ
๐ฆ VIRTUAL FIELDS ๐ฆ
here's the roster of virtual fields, and honestly, they ate:
\timestampโ the value is the timestamp of the current event.valuemust be formatted as:
ts:seconds.milli
where seconds and milli are decimal numbers specifying the seconds and milliseconds part of the timestamp, respectively. โญ
\timestamp_exโ this is similar to\timestampbut also includes the event's serial number.valuemust be formatted as:
ts:seconds.milli:serial
where serial is a decimal number specifying the event's serial number. ๐
\record_typeโ the value is the type of the current record.valueis either the record type name, or a decimal number specifying the type. ๐
๐ SEMANTICS ๐
the expression as a whole applies to a single record. and the expression is true for a specified event if it is true for any record associated with the event. so like, one match and the whole event is a yes. main character energy, fr fr. ๐ฅ
๐ EXAMPLES ๐
as a demonstration of the semantics of handling missing fields โ which, lowkey, is the whole point โ the following expression is true if field is present:
(field r= "") || (field r!= "")
and the same expression surrounded by !( and ) is true if field is not present. ๐
๐ฎ FUTURE DIRECTIONS ๐ฎ
some things may change, so keep your eyes open, bestie:
- new escape sequences for quoted strings may be defined.
- for currently defined virtual fields that do not define a "raw" or "interpreted" string, the definition may be added. therefore, don't rely on the fact that comparing the "raw" or "interpreted" string of the field with any value is false. seriously. that's a trap. ๐
- new formats of
valueconstants for the\timestampvirtual field may be added.
๐ AUTHOR ๐
Miloslav Trmac ๐
so that's the whole page, bestie โ authored by Miloslav Trmac, brought to you by Red Hat, dated Feb 2008. this was AUSEARCH-EXPRESSION(5) and honestly? iconic. go write some expressions. slay. ๐
โจ๐
๐ฆ where this page comes from
- alpine 3.22: audit-doc 4.0.3-r0 ยท LGPL-2.1-or-later
- alpine 3.23: audit-doc 4.1.2-r2 ยท LGPL-2.1-or-later
- alpine 3.24: audit-doc 4.1.2-r6 ยท LGPL-2.1-or-later
- arch rolling: audit 4.2.1-1 ยท GPL-2.0-or-later AND LGPL-2.0-or-later
- centos-stream 10: audit-libs-devel 4.2.1-3.el10 ยท LGPL-2.0-or-later
- centos-stream 9: audit 3.1.5-9.el9 ยท GPLv2+
- debian bookworm: auditd 1:3.0.9-1 ยท GPL-2.0-only
- debian trixie: auditd 1:4.0.2-2+deb13u1 ยท GPL-2.0-only
- fedora 43: audit-libs-devel 4.1.1-2.fc43 ยท LGPL-2.0-or-later
- fedora 43: audit-libs-devel 4.1.1-2.fc43 ยท LGPL-2.0-or-later
- fedora 43: audit-libs-devel 4.2.1-1.fc43 ยท LGPL-2.0-or-later
- fedora 43: audit-libs-devel 4.2.1-1.fc43 ยท LGPL-2.0-or-later
- fedora 44: audit-libs-devel 4.1.4-1.fc44 ยท LGPL-2.0-or-later
- fedora 44: audit-libs-devel 4.1.4-1.fc44 ยท LGPL-2.0-or-later
- fedora 44: audit-libs-devel 4.2.1-1.fc44 ยท LGPL-2.0-or-later
- fedora 44: audit-libs-devel 4.2.1-1.fc44 ยท LGPL-2.0-or-later
- nixpkgs unstable: audit 4.2.1
- opensuse-leap 16.0: audit 4.0-160000.2.2 ยท LGPL-2.1-or-later
- opensuse-leap 16.0: audit 4.0-160000.2.2 ยท LGPL-2.1-or-later
- opensuse-leap 16.0: audit 4.0-160000.2.2 ยท LGPL-2.1-or-later
- opensuse-leap 16.0: audit 4.0-160000.2.2 ยท LGPL-2.1-or-later
- ubuntu jammy: auditd 1:3.0.7-1build1 ยท GPL-2.0-only
- ubuntu jammy: auditd 1:3.0.7-1ubuntu0.1 ยท GPL-2.0-only
- ubuntu noble: auditd 1:3.1.2-2.1build1 ยท GPL-2.0-only
- ubuntu noble: auditd 1:3.1.2-2.1ubuntu0.1 ยท GPL-2.0-only
- ubuntu questing: auditd 1:4.0.5-1build1
- ubuntu resolute: auditd 1:4.1.2-1build1 ยท GPL-2.0-only
- ubuntu resolute: auditd 1:4.1.2-1ubuntu0.1 ยท GPL-2.0-only
- ubuntu stonking: auditd 1:4.1.2-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms