Skip to content

Host Posture: Rule Language Reference

This page is the complete reference for lc-posture/v1, the language of Host Posture rules. For a walkthrough, start with Writing rules. For complete, tested rules to copy, see Rule examples.

Two programs read your rule, and this page states the behaviour of both:

  • The hive check runs when you save the rule into the host_posture_rule hive. It checks the document and runs the rule's tests against mocked probe results. It never touches a host.
  • The evaluator runs on the host, inside the sensor, at each scan. It performs the reads (the probes) and evaluates your conditions against what it read.

Where the two differ, this page says so. A rule can pass its tests at save time and still behave differently on a host if it relies on one of those differences, so read the notes marked On the host.

Sensor and evaluator versions

Item Value
Language apiVersion: lc-posture/v1. The only version.
Evaluator in sensor 5.4.4 and later 1.2
Highest requires.evaluator the hive's tests can run "1.1"

Rules you write need sensor 5.4.4 or later:

  • Sensor 5.4.2 runs only rules sealed by an earlier design and reports every rule from the hive as unsupported.
  • Sensor 5.4.3 runs every rule, but for a rule whose id does not start with lc. it ignores absent_is_pass and tolerate_unreadable. Such a rule can report error or not_applicable where 5.4.4 reports pass.
  • Sensors older than 5.4.2 have no posture scan. Host Posture does not count them as passing.

Set requires.evaluator: "1.1" in every rule. The hive refuses registry_values and state: windows.av.health without it. Do not set "1.2": the hive's test runner implements 1.1, so with "1.2" every test reports unsupported and the hive refuses a rule that has tests.

Sensors in containers

The evaluator reads the filesystem that the sensor process sees. A sensor that runs in a container evaluates the container's files, packages and /proc, not the node's. On sensor 5.4.4, a sensor in a container that lacks the DAC_READ_SEARCH capability (the default for Docker and Kubernetes) reports every rule as error with the reason evaluator_unavailable. Grant the capability (--cap-add DAC_READ_SEARCH, or securityContext.capabilities.add: ["DAC_READ_SEARCH"]). Sensor releases after 5.4.4 run without it, and report only the rules whose files they cannot read, as unreadable:<probe>:no_cap_dac_read_search.

The document

A rule is one YAML document (JSON in the API). Top-level fields not listed here are refused at save, so a misspelled top-level field cannot be silently ignored. Keys inside a probe are not checked: see Probes.

Field Required Rules
apiVersion Yes lc-posture/v1.
kind Yes Signature.
id Yes Matches ^[a-z0-9][a-z0-9_-]*(\.[a-z0-9][a-z0-9_-]*)+$: lowercase, at least two dot-separated parts, at most 256 bytes. Must equal the hive record name. Any prefix is allowed. Use your own, such as acme., and keep lc. for LimaCharlie's default pack.
version Yes An integer, 1 or more. Raise it whenever probes or conditions change.
title Yes One line, at most 256 bytes. Shown in results and findings.
severity Yes critical, high, medium, low or info.
platforms Yes A non-empty list of linux, windows, macos. The rule is sent only to sensors of these platforms.
probes Yes A map of probe name to probe. At most 16.
violation Yes A condition. A bool, or a list(string) of instances.
applies_when No A condition returning bool. When false, the result is not_applicable. Defaults to true.
evidence No A map of label to condition. Evaluated only on fail. See Evidence.
absent_is_pass No A list of probe names. See Absence.
tolerate_unreadable No A list of probe names. See Unreadable probes.
requires No evaluator: "<major>.<minor>". Set "1.1".
description No What is wrong and why it matters. Shown in findings.
remediation No text (the manual fix, shown in findings), and optionally action and args naming a remediation.
limitations No What the rule cannot see.
standards No A map of framework to control ids, such as cis: ["5.1.16"]. Findings turn cce, cis, stig, nist and pcidss into references, and Host Posture reports results per standard. At most 32 ids per framework, 128 bytes each.
threat_refs No cves (list), kev (bool), links (list).
tags No Labels for the rule itself, such as baseline:sshd. These are not sensor tags: to target sensors, use the record's scope.
tests No Test cases, run at save. See Tests.

Only the fields that evaluation needs travel to the sensor: apiVersion, kind, id, version, platforms, requires, probes, applies_when, violation, evidence, tolerate_unreadable and absent_is_pass. The rest stays in the cloud.

A config_finding event carries title, description, severity, remediation.text, standards and the references made from them. threat_refs, tags, limitations and remediation.action are kept with the rule but are not copied into events.

Probe names

A probe name is the variable your conditions use.

  • It must match ^[a-z_][a-z0-9_]*$. The hive also accepts uppercase letters, but sensors report a rule with an uppercase probe name unsupported on every host.
  • It cannot be a CEL reserved word (in, if, true, null, package and the rest), nor now, instance, size, string, or the name of a helper.

Probes

A probe is one read on the host. A probe spec is a map with exactly one probe type key, plus optional optional: true. The hive checks that key, but not the keys inside it:

probes:
  ps:   { state: linux.sysctl.kernel.yama.ptrace_scope }
  sshd: { file: { path: /etc/ssh/sshd_config } }
Type Platforms Reads
state all A catalog item.
sysctl Linux One sysctl.
registry Windows One registry value.
registry_values Windows Every value of one registry key.
file all File metadata.
config all Selected keys of configuration files.
modules Linux Kernel modules and modprobe rules.
packages Linux, macOS Installed packages.
certs all Certificates in the trust stores.
yara none yet Accepted by the hive, not evaluated by sensors.

Misspelled keys inside a probe

A misspelled key inside a probe saves without complaint. On the host it is ignored: a config probe written with path: instead of paths:, or selector: instead of selectors:, reads no file at all, and the rule can pass on a host that has the problem. An unknown format, or a discover entry without dir or file_regex, saves and then reports unsupported on every host. Copy probe specs from this page or from the examples, and give every rule a test with a file entry status: ok and a found match.

Off its platform, registry, registry_values, packages on Windows and a catalog item of another platform read as unsupported, which makes the rule unsupported. But sysctl, modules and the linux.sysctl.* catalog items read as unreadable with reason: mount_missing on Windows and macOS, which makes the rule error. List each rule's real platforms in platforms, so that it is only sent where it can run.

Status

Every probe result, and every file entry inside a config result, has a status:

status Meaning Value fields
ok It was read. Present.
absent It does not exist: no such sysctl, file, registry value or key. None.
unreadable It exists, or should, but could not be read: permissions, I/O error, a missing mount, the time budget. None. Some results add a reason.
invalid It was read but is not what it must be: a file that does not parse, a refused path, a bad key. None. Some results add a reason, refusal or parse_status.
unsupported The evaluator cannot run this probe on this host. None.

Value fields exist only when the status is ok. Reading p.value on an absent probe is an error, and an error never becomes pass. Test the status first with the status helpers: !absent(p) && p.value == "0".

Everything read from host content is a string: sysctl and registry values, config values, package versions, file modes. Compare numbers with num(p.value) >= 2, never p.value >= 2 or p.value == 2.

optional

optional: true marks a probe used only by evidence. When it cannot run, the rule is still evaluated. applies_when and violation may not read an optional probe; the hive refuses that.

state

lock: { state: linux.lsm.lockdown }

Reads one catalog item. Result: {status, value, source} when ok. value is a string. source says where it was read (a file path, a registry path or an API name). An item the evaluator does not know reads as unsupported. The hive does not check item names, so check them against the catalog.

sysctl

fwd: { sysctl: net.ipv4.ip_forward }

Reads /proc/sys/<key with dots as slashes>. Result: {status, value, source}, where value is the text as read, trimmed.

  • The key must start with kernel., fs., net., user., vm. or dev.. Any other key reads as invalid with reason: prefix_not_allowed. The hive does not check this.
  • A missing key is absent.
  • When /proc is not a mounted procfs, the probe is unreadable with reason: mount_missing. It is never absent in that case, so a container without procfs cannot make a rule pass.

registry

nla:
  registry:
    key: 'HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'
    value: UserAuthentication

Reads one value. Result: {status, value, source}.

  • key must start with HKLM\ (or HKEY_LOCAL_MACHINE\) followed by one of SYSTEM\CurrentControlSet\, SOFTWARE\Policies\, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\, SOFTWARE\Microsoft\Windows NT\CurrentVersion\ or SOFTWARE\Microsoft\Windows Defender\, compared case-insensitively. Any other key reads as invalid with reason: registry_root. The hive does not check this.
  • Encodings: a DWORD or QWORD is decimal text ("1"), a string is as stored and not expanded, a multi-string is its strings joined with \n, anything else is lowercase hex. Data over 64 KiB, or that does not fit its type, is invalid.
  • A missing value or key is absent. A key that exists but cannot be opened is unreadable.
  • Use single quotes around key in YAML so backslashes stay literal.

registry_values

asr:
  registry_values:
    key: 'HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Windows Defender Exploit Guard\ASR\Rules'

Reads every value of one key, for lists whose entries are value names (Defender exclusions, ASR rules). Needs requires.evaluator: "1.1". Same key rules as registry.

Result: {status, source, truncated, values: [{name, value}]}. At most 1,024 values. A value whose data is over 64 KiB or does not fit its type has no value field, so test it with has(v.value). More than 1,024 values, or a value over 64 KiB, sets truncated, so the rule cannot pass on that host. A missing key is absent. A key or value name that is not ASCII is invalid with reason: registry_name.

file

tab: { file: { path: /etc/crontab } }

Reads metadata, never content. Result when ok:

Field Type Notes
type string regular, directory, symlink or other. A final symlink is not followed.
size int Bytes.
mode string Four octal digits, such as "0644". Not on Windows.
uid, gid int Not on Windows.
mtime timestamp Modification time. Use with days_until().

A missing file, or a missing parent directory, is absent.

Since mode is text, test permission bits with a regular expression on its digits. tab.mode.matches("[2367].$|[2367]$") is true when the group or others digit has the write bit.

config

sshd:
  config:
    format: sshd
    paths: [/etc/ssh/sshd_config]
    discover:
      - { dir: /etc/ssh/sshd_config.d, file_regex: '\.conf$', max: 16 }
    vars:
      ver: ["8.2", "8.3"]
    selectors: [PermitRootLogin]

Parses configuration files and returns only the keys you select.

Field Rules
format sshd, ini, json, yaml, nginx or raw.
paths Absolute paths. * and ? match within one path segment, case-sensitively. No **, braces or character classes. ${name} expands from vars.
discover Up to 8 entries {dir, file_regex, depth, max}. dir and file_regex are required. file_regex matches the path relative to dir. depth is 1 to 3 (default 1). max is 1 to 256 (default 32). Each entry visits at most 64 directories. More matching files than max, or more than 64 directories, marks the probe truncated, so set max above the number of files a real host has.
vars A map of name to list of strings, expanded as a cross product in paths.
selectors The keys to report. Their syntax depends on the format, below.

On the host, a config probe reads at most 32 files (literal paths, glob matches and discovered files together, in that order). Further files are dropped and the probe is marked truncated, which turns a would-be pass into an error. The hive accepts up to 256 expanded paths and max up to 256, but only 32 files are read.

Selectors by format:

Format Selector Match context
sshd A keyword, matched case-insensitively. Every occurrence is reported. context: the enclosing Match line as written, such as "Match User backup". No context field outside a Match block.
ini A key name, matched case-sensitively. Lines starting with ; or # are comments. A comment after a value is part of the value (On ; note reads as "On ; note"). Values are trimmed, and double quotes around them removed. context: the section header, such as "[PHP]". No context for keys before any section.
json, yaml A dotted path with [n] indexes, such as authentication.anonymous.enabled or spec.containers[0].command. * is allowed in a non-final segment. A path that ends at a list of scalars gives one match per element, each with its resolved key (hosts[1]). YAML scalars are kept as written: yes reads as "yes", null as "null". For YAML, no context in the first document of a stream, then context: "document 1" for the second, "document 2" for the third, and so on.
nginx A dotted directive path (http.server.listen), or a bare directive name (autoindex) that matches at any depth. blocks: the enclosing blocks, outermost first, each {name, args}. For a server block, args is its server_name. nginx.conf is read at the top level. Files directly in /etc/nginx/conf.d, sites-enabled, sites-available, http.d and vhosts.d (and the Homebrew and /usr/local equivalents) are placed inside http, as nginx includes them, and files in /etc/nginx/default.d inside http and server "_". A file anywhere else (/etc/nginx/snippets/, a subdirectory of conf.d) has context: "unplaced" and blocks relative to the file.
raw content: the whole file as one match, value cut at 4 KB. A file over 4 KB is therefore truncated, and a raw rule cannot pass over it. None.

include and Include lines are reported as ordinary keys and never followed. Use discover or globs to read included files.

Result:

status: ok
truncated: false
discovered:                      # one entry per discover entry; globs add none
  - { dir: /etc/ssh/sshd_config.d, status: ok, count: 1 }
files:
  - path: /etc/ssh/sshd_config
    status: ok
    parse_status: ok
    matches:
      - { selector: MaxAuthTries, found: false, line: 0 }
  - path: /etc/ssh/sshd_config.d/50-hardening.conf
    status: ok
    parse_status: ok
    matches:
      - { selector: MaxAuthTries, found: true, key: MaxAuthTries, value: "3", kind: scalar, line: 1, value_truncated: false }
  • Probe status. ok when every path was tried and every discovery directory listed, whatever each file's own status. A host without the software gives ok with every file absent. A discovery directory or glob directory that exists but cannot be listed makes the whole probe unreadable.
  • discovered. status is ok, absent (the directory does not exist, which contributes no files) or unreadable. count is the number of files selected.
  • File entries. absent: the file or a parent directory does not exist. unreadable: permission or I/O error, or reason: mount_missing. invalid with a refusal (symlink, directory, not_regular, too_large, path_not_canonical, prefix_not_allowed) or a parse_status (syntax_error, too_deep, binary, invalid_encoding). An entry that is not ok has no matches field, so reading it is an error.
  • Matches. One per selector occurrence. A selector with no occurrence gives one match with found: false and line: 0, and no other fields. A found match has key, kind (scalar, mapping, sequence or alias), line, value_truncated, value (only for a scalar; JSON true reads as "true"), and context or blocks where the table above says so.
  • Symlinks. A symlinked file is read when its target stays inside the first two components of the declared path (for /etc/nginx/sites-enabled/x, inside /etc/nginx). Otherwise the entry is invalid with refusal: symlink. Directory symlinks are not walked by discover or by globs. A discover dir that is itself a symlink is followed.
  • Caps. Files up to 10 MB (else refusal: too_large). Values cut at 4 KB with value_truncated: true. At most 1,024 matches per file. JSON and YAML at most 64 levels deep and 65,536 nodes per selector step. A cut value or a full match budget marks the probe truncated.
  • Order. Files follow paths in the order written (the matches of a glob sorted by name), then the files of each discover entry, sorted. A file found twice is read once. Do not rely on order to decide which file wins: compare f.path.

modules

mods: { modules: {} }

Linux only. Result when ok:

Field Type Contents
loaded list(string) Modules in /proc/modules.
available list(string) Modules installed for the running kernel (from modules.dep), with - normalized to _.
builtin list(string) Modules compiled into the kernel (from modules.builtin).
rules list The modprobe rules of every modprobe.d directory, in the order modprobe reads them: {module, kind: "blacklist" or "install", source, line}, plus command on install rules.
truncated bool A cap was hit.

Read the lists with the helpers loaded(), blacklisted() and blocked() rather than by hand. They treat - and _ alike and handle built-in modules. A missing modules.dep or modules.builtin (a kernel whose package was removed) makes the probe unreadable with reason: modules_dep. Caps: 4,096 loaded modules and 1,024 rules.

On the host, a modprobe.d file the sensor cannot read is skipped, and the probe stays ok. A rule that passes only when it finds a blocking install line can therefore fail a host whose block is in an unreadable file. Say so in the rule's limitations.

packages

pkg: { packages: { name_regex: '^google-chrome-(stable|beta)$' } }

Lists installed packages whose name matches name_regex. Result: {status, truncated, packages: [{name, version, scheme, source}]}.

  • Linux: dpkg and RPM (scheme dpkg or rpm), and snap (scheme: generic). source is dpkg, rpm or snap. RPM is read by running rpm -qa from the sensor. A database that exists but cannot be read makes the probe unreadable, with a reason such as dpkg, snap or rpm_timeout. A host with Flatpak applications installed reads as unreadable with reason: flatpak_reader_not_implemented.
  • macOS: applications and Homebrew (source app or homebrew), with scheme: generic.
  • Windows: not available. The probe reads as unsupported with reason: no_provider, so a Windows rule with a required packages probe is unsupported.
  • A host with none of the known package managers (Alpine, Arch) reads as unsupported, never as an empty list.
  • ok with packages: [] means every package database was read and nothing matched. That is evidence, not absence.
  • At most 4,096 matching packages.

Distributions backport security fixes without changing the upstream version number. Compare versions only for packages whose version follows upstream (a vendor's own repository), and leave distribution packages to vulnerability management.

certs

roots: { certs: {} }               # every store
ca:    { certs: { store: ROOT } }  # stores whose name contains "ROOT", case-insensitive

Result: {status, truncated, certificates: [...]}, each certificate:

Field Type Notes
store string A file path on Linux, such as /etc/ssl/certs/ca-certificates.crt. LocalMachine\ROOT, LocalMachine\Disallowed and others on Windows. SystemRoots, TrustSettings.Admin and others on macOS.
sha256, sha1 string Lowercase hex of the stored bytes. Always present.
trusted bool Computed by the evaluator: in a trust store and in no distrust store. Use this rather than testing store names.
parse_error bool The bytes did not parse. All fields below are then missing.
subject, issuer string Such as "C=US, O=Example, CN=Example Root". Match certificates by sha256, not by subject text.
serial string Lowercase hex.
not_before, not_after timestamp Use with days_until().
is_ca, is_self_signed bool is_self_signed means the subject equals the issuer; the signature is not checked.

A store that cannot be read makes the probe unreadable (reason: store_unreadable). A certificate with parse_error: true makes the probe unreadable for the decision, so a rule never passes over a certificate it could not parse. A host with no known store reads as unsupported. At most 4,096 certificates and 16 MB.

yara

The hive accepts yara probes (targets with paths, crawl or processes, rules, version_string), but sensors do not evaluate them yet: a yara probe reads as unsupported, and a rule that needs one is unsupported on every host. The default pack leaves out its YARA rules for this reason.

Catalog

Items for the state probe. Values are strings.

Linux

Item Value
linux.sysctl.kernel.unprivileged_userns_clone, linux.sysctl.user.max_user_namespaces, linux.sysctl.kernel.yama.ptrace_scope, linux.sysctl.kernel.unprivileged_bpf_disabled, linux.sysctl.kernel.io_uring_disabled, linux.sysctl.fs.protected_hardlinks, linux.sysctl.fs.protected_symlinks, linux.sysctl.kernel.kptr_restrict, linux.sysctl.kernel.dmesg_restrict, linux.sysctl.kernel.modules_disabled, linux.sysctl.kernel.kexec_load_disabled, linux.sysctl.kernel.perf_event_paranoid, linux.sysctl.kernel.randomize_va_space The sysctl as read. The sysctl probe reads the same keys and any other allowed one.
linux.kernel.cmdline, linux.kernel.release The text of /proc/cmdline and the kernel release.
linux.lsm.list, linux.lsm.lockdown The active LSMs, and the lockdown file, where the active mode is in brackets: "none [integrity] confidentiality".
linux.selinux.enforce, linux.apparmor.enabled "1" or "0", "Y" or "N" as the kernel writes them.
linux.apparmor.profiles_enforce, linux.apparmor.profiles_complain Decimal counts.
linux.efi.present "1" on UEFI, "0" on BIOS.
linux.efi.secure_boot, linux.efi.setup_mode, linux.efi.mok_sb_state The EFI variable's data byte, "1" for on. absent on a BIOS host.
linux.kvm.dev_mode, linux.kvm.dev_owner /dev/kvm mode (four octal digits) and uid:gid.
linux.modules.count Number of loaded modules.

Windows

Item Value
windows.secureboot.enabled, windows.secureboot.uefica2023status, windows.secureboot.uefica2023error, windows.secureboot.available_updates Secure Boot registry values.
windows.deviceguard.enable_vbs, windows.deviceguard.require_platform_security_features, windows.deviceguard.hvci_enabled, windows.deviceguard.credential_guard_enabled Configured Device Guard settings (registry).
windows.vbs.running, windows.vbs.hvci_running, windows.vbs.credential_guard_running Running state, "1" or "0".
windows.ci.enabled, windows.ci.testsigning, windows.ci.debugmode, windows.ci.flightsigning Code integrity running state, "1" or "0".
windows.ci.um_policy_enforcement_status "0" none, "1" audit, "2" enforced.
windows.ci.vulnerable_driver_blocklist, windows.ci.smart_app_control Registry values.
windows.lsa.runasppl, windows.lsa.lsacfgflags, windows.wdigest.uselogoncredential Registry values.
windows.lsa.runasppl_boot Whether LSASS runs protected now, "1" or "0".
windows.smb1.server, windows.smb1.client_start Registry values.
windows.smb1.feature "1" when the SMBv1 server driver is installed.
windows.av.health good, not_monitored, poor or snooze. absent without Security Center (Windows Server). Needs requires.evaluator: "1.1".
windows.bitlocker.volumes Encryptable volumes as lowercase drive letters, comma-separated.
windows.bitlocker.os_protection_status "0" off, "1" on, "2" unknown, for the OS volume.
windows.bitlocker.<letter>.protection_status, windows.bitlocker.<letter>.volume_type Per volume, as WMI reports them.

macOS

Item Value
macos.sip.enabled "1", or "0" when SIP is off or any relaxing flag is set.
macos.sip.config The raw flags as 0x%08x.
macos.gatekeeper.prefs_enabled, macos.gatekeeper.managed_enable_assessment As stored: "yes" or "no", "true" or "false".
macos.firewall.globalstate "0" off, "1" on, "2" block all.
macos.firewall.managed_enable "true" or "false".
macos.filevault.enabled, macos.mdm.enrolled "1" or "0".
macos.mdm.dep_activation_record "1" or "0", or absent.
macos.mdm.profiles_installed "1", or absent when none is installed.

The BitLocker, FileVault, firewall global state and MDM enrollment items are read by the sensor through a fixed system command or WMI query, only when a rule of the scan names them. A failure there reads as unreadable with a reason.

Conditions

applies_when, violation and each evidence entry are CEL expressions over a fixed subset of the language. Each probe is a variable named after it. Write multi-line expressions with YAML's > block style.

What the language provides

  • Literals: integers (decimal and 0x hex), strings in single, double or triple quotes, true, false, null, lists [...] and maps {"key": value}.
  • Operators: !, -, *, /, %, +, ==, !=, <, <=, >, >=, in, &&, || and ? :. Field access a.b and indexing a[0], a["key"].
  • Functions: size(x), string(x), has(a.b).
  • Methods on strings: contains, startsWith, endsWith, matches, lowerAscii, upperAscii, split, trim, size.
  • Macros on lists: exists, all, exists_one, filter and map, in their two-argument form (list.filter(x, cond)).
  • The helpers and the variable now.

Anything else is refused at save, including int(), double, uint and bytes literals, timestamp(), duration(), type(), dyn, optional syntax (?.) and three-argument map.

Rules for the operators:

  • + adds two ints, or concatenates two strings or two lists. Nothing else.
  • <, <=, >, >= compare two ints, two strings (by byte order) or two timestamps.
  • == between different types is false, not an error. So p.value == 1 is always false: write p.value == "1" or num(p.value) == 1.
  • Relations do not chain: write 0 < n && n < 5.
  • Integer overflow is an error.

Rules for literals and patterns:

  • The pattern of matches must be a string literal, in RE2 syntax. A backslash inside a CEL string is written twice, as CEL escapes require: 'p.value.matches("^\\d+$")'. A raw string avoids that: 'p.value.matches(r"^\d+$")'. On the host \d and \w also match non-ASCII digits and letters; in tests they match ASCII only. Write [0-9] when it matters.
  • split() needs a non-empty string literal. The hive refuses only split(""): a separator computed from an expression saves, and the rule is unsupported on every host.
  • A probe may be indexed only with a literal (p.files[0]), never with an expression.
  • A macro variable may not be named like a probe, a helper, now, instance, size or string.
  • At most 4 KB of source, 32 levels of brackets and 3 nested macros per expression.

No type checking

Probes are untyped at save. A misspelled field, such as p.valeu, is not caught when you save the rule. On a host it is the error no such key: valeu, and the rule reports error everywhere the probe is readable. Your tests are the only place such a mistake shows up before the rule runs, so give every field your conditions read a test where it is present.

On the host, a field that is not in the result is an error. The hive's test runner fills in some missing fields, so a test can pass where the host fails:

  • In mocks, a missing truncated, found, value_truncated, parse_error, trusted, is_ca or is_self_signed reads as false, and a missing files, discovered, matches, certificates, values, packages, loaded, builtin or rules reads as [].
  • On the host, truncated is missing from state, sysctl and file results and appears on a registry result only when true, value_truncated is missing from a match with found: false, value is missing from a match that is not a scalar, context and blocks are missing at the top level of a file, args is missing from an nginx block without arguments, command is missing from blacklist rules, and mode, uid and gid are missing on Windows.

Never read truncated or value_truncated in a condition. The evaluator already turns truncation into error where it matters. For a field that is sometimes missing, test it with has() first: has(m.context), has(v.value). has() on null is an error on the host, so guard a helper that can return null: innermost(m) != null && has(innermost(m).args).

Errors

An error in an expression propagates, with these exceptions:

  • false && <error> is false, and true || <error> is true, in either order.
  • exists is true when any element is true, even if another element errors. all is false when any element is false.
  • exists_one, filter and map need every element, so an error in any element makes the whole expression an error.
  • Field access on null is an error.

An error in applies_when or violation makes the result error. An error in an evidence entry drops that entry.

Helpers

Helper Returns Notes
ok(x), absent(x), unreadable(x), invalid(x) bool The status of a probe result or of anything with a status: a config file entry, a discovered directory. On anything without a status (ok(p.value), ok(first(f, "x"))), the host raises an error, while tests return false.
num(s) int The integer in a string, trimmed: ^-?[0-9]+$ or ^0x[0-9a-fA-F]+$. Anything else is an error.
loaded(mods, name) bool The module is loaded or built in. - and _ are the same.
blacklisted(mods, name) bool A blacklist rule exists. That stops automatic loading only, not modprobe. False for a built-in module.
blocked(mods, name) bool The first install rule for the module runs /bin/false, /bin/true, /usr/bin/false or /usr/bin/true, so the module cannot load. False for a built-in module. Write the command alone (install usb-storage /bin/false): with extra arguments, the host counts it as blocking but tests do not.
found(f, "sel") bool A config file entry has a found match for the selector. f must be one file entry (p.files[...], or a macro variable over p.files), and ok.
first(f, "sel"), last(f, "sel") match or null The first or last found match in file order. Use last where the last value wins (php.ini, apt).
global_first(f, "sel") match or null The first found match with no context and no blocks: sshd's "first value wins" outside Match blocks. On the host a match after Match all also counts as global; in tests it does not, so do not rely on it. nginx matches in an unplaced file are skipped.
innermost(m) {name, args} or null The innermost nginx block of a match. null at the top level. args is missing for a block without arguments.
version_cmp(a, b, scheme) int -1, 0 or 1. Schemes: dpkg, rpm, semver, generic. An unparsable version is an error.
fixed_in_branch(v, {"1.30": "1.30.6", "1.31": "1.31.7"}, scheme) bool For software that ships fixes per release branch. True when v is at or above the fixed version of its branch, or newer than every branch. False when it is older than every branch or between branches. For dpkg and rpm the epoch and the revision are stripped first; semver keeps a pre-release (1.30.6-rc1 is below 1.30.6). An error when v does not start with a digit, or has fewer components than the keys.
days_until(ts) int Whole days from now to ts, rounded down. Negative when ts is past: days_until(f.mtime) < -7 means "not modified for over a week".
yara_hit(p, "rule"), yara_paths(p, "rule") bool, list For yara probes, which sensors do not evaluate yet.
now timestamp The evaluation time. In tests, the test's now.

The selector argument of found, first, last and global_first must be a string literal listed in some config probe's selectors. The hive refuses anything else, so a typo cannot become a silent false.

generic versions split at ., -, _, +, ~, : and at each digit/letter boundary. Numbers compare as integers and sort before letters, and a longer version sorts after its prefix, so 1.0-rc1 is newer than 1.0 under generic. Use the package's own scheme (version_cmp(p.version, "1.2.3", p.scheme)) when you compare distribution packages.

How a result is decided

Every rule on every host ends in one result:

Result Meaning
pass Everything the deciding conditions read was readable and complete, and violation is false or an empty list.
fail violation is true or a non-empty list.
not_applicable applies_when is false, and everything it read was readable and complete.
error The rule could not be decided. Carries a reason.
unsupported The host cannot run the rule. Carries a reason.

The evaluator applies these steps in order:

  1. If the host's platform is not in platforms: unsupported (platform). If requires.evaluator is above the evaluator's version: unsupported (evaluator_version). If a required probe reads as unsupported: unsupported (probe_unsupported).
  2. Evaluate applies_when. An error gives error. If it is false and every probe it read is readable and not truncated, the result is not_applicable. Otherwise error.
  3. Evaluate violation. An error gives error. True, or a non-empty list, gives fail, even when some other input was unreadable: a hit is a hit.
  4. violation is false or empty. If every probe that applies_when and violation read is readable and not truncated, the result is pass. Otherwise error.

A probe is readable when its status is ok or absent, and also, for config, every file entry is ok or absent and no discovered directory is unreadable, and for certs, no certificate has parse_error. "The probes an expression reads" is decided by reading the expression, not by what ran, so how you write a guard does not change the outcome: ok(p) && p.value == "0" on an unreadable p is still an error, never a pass.

This is the most important property of the language: a pass has to be proven. An unreadable or truncated input never produces pass or not_applicable.

ok(f) or !absent(f)

When you iterate over the files of a config probe, the guard decides what an unreadable file does:

  • To find violations (a list of instances, or "some file sets X"), select files with ok(f). An unreadable file is skipped, so it cannot turn a real hit elsewhere into an error.
  • To prove a fix ("no file sets the safe value", written as !p.files.exists(...)), select with !absent(f). An unreadable file then makes the expression an error, so the rule reports error instead of claiming a violation it could not see.

Writing rules shows this mistake and its fix.

Absence

absent usually does not mean "safe". A missing configuration file may mean the software is not installed, or that it runs on a default that is the problem. So the evaluator does not let an absent item close a finding unless you say it may.

After deciding pass or not_applicable, the evaluator checks whether an absent item decided it: it re-evaluates with every absent item replaced by a value on which any access is an error. If the result changes, the absence was decisive, and the result is reported as not_applicable by absence. It closes no finding. Open failures move to "subject not found" and keep their history, until a later scan proves the problem gone.

Absent items are: a whole state, sysctl, registry, registry_values or file probe, a config file entry, and a discover directory.

List a probe in absent_is_pass to claim that its absence really means "not exposed", for example "no sshd_config means sshd is not installed". Its absences then count as evidence, and the pass or not_applicable they decide closes findings. Make the claim deliberately. Deleting a configuration file must not close a finding about a setting whose default is unsafe. The pack's kubelet rule leaves its config file undeclared for that reason: with no config file, the kubelet allows anonymous access.

An empty packages list or certs list from a complete read is evidence, not absence, and needs no declaration. The same is true of a glob that matches no file.

Unreadable probes

List a probe in tolerate_unreadable when the rule is decided correctly even if that probe cannot be read. The probe then counts as readable for the decision, so the rule can pass. A truncated probe still cannot prove a pass. A fail that read a tolerated, unreadable probe still lists it in incomplete: open instances are not closed by that evaluation, and the rule's error finding opens for that host.

Instances

When violation returns a list of strings, each distinct string is one instance, and each instance is its own finding on the host: one per file, per listener, per certificate. A true violation has the single instance "".

  • At most 64 instances. A longer list is cut and nothing closes on that evaluation.
  • Each at most 512 bytes. A longer one is cut to 480 bytes plus …# and 16 hex digits of its SHA-256, so its identity stays stable.
  • An instance that disappears from the list closes only when every probe the conditions read was readable and complete. A shorter list from an incomplete read closes nothing.
  • An instance that starts with / is also reported as the finding's config_path.

Choose instance strings that stay the same across scans (a path, a store and hash) and do not include values that change.

Evidence

evidence maps a label to an expression, evaluated only when the result is fail. Evidence, instance strings and expression error messages are the only host content that leaves the host. Use it for what the person fixing the host needs: the value found, the file it is in.

  • An expression that references instance is evaluated once per instance, and its value is a map from instance to value.
  • An expression that errors is dropped.
  • Keep evidence small. A rule result is sent as one line of at most 64 KiB, and a result over that is rejected together with every other result of the same scan (evaluator_protocol). Do not put whole lists of files or certificates into evidence.

The deny list

Some paths and registry values hold secrets. A rule may read them to decide, but nothing read from them leaves the host:

  • Evidence that reads a probe marked deny_listed becomes "withheld: read from a deny-listed path".
  • When applies_when or violation reads such a probe, the instances become ["withheld"], evidence that uses instance is withheld, and an expression error message becomes withheld.
  • The marking is per probe: one deny-listed file in a multi-file config probe withholds evidence for the whole probe. Only config file entries and registry and registry_values results are marked.

The list covers, among others: /etc/shadow, /etc/gshadow, SSH host keys, *.pem, *.key, *.p12, *.pfx, /root/**, users' .ssh, .gnupg, .aws, .azure, .kube/config, .docker/config.json, .env, .netrc, .pgpass, .my.cnf, wp-config.php, /etc/redis/redis.conf, /etc/kubernetes/pki/**, /var/lib/docker/**, /proc/** (except sysctls), Windows System32\config, NTDS, DPAPI keys and browser credential stores, and registry values under Winlogon named DefaultUserName or containing Password, and values whose name contains Password, Secret, Credential or Key under HKLM\SYSTEM\CurrentControlSet\Services and the policy keys.

file metadata is never withheld, so a rule can report the mode of /etc/shadow. The result itself (pass or fail) is still reported, so a rule over a secret file tells its readers one bit about the file. Write such rules with that in mind.

Error reasons

An error result carries one reason:

Reason Meaning
unreadable:<probe> The probe could not be read, or one of its file entries is unreadable or invalid, a discovered directory is unreadable, or a certificate did not parse.
unreadable:<probe>:<cause> With a cause: mount_missing, no_module_support, modules_dep, not_collected, store_unreadable, dpkg, snap, flatpak_reader_not_implemented, rpm_*, no_cap_dac_read_search (sensor releases after 5.4.4, in a container without DAC_READ_SEARCH), or a reason of a sensor-read item such as timeout or wmi_error.
invalid:<probe> The probe as a whole is invalid: a sysctl outside the allowed prefixes, a registry key outside the allowed roots, a bad name_regex. A file that does not parse gives unreadable:<probe> or an expression error instead.
truncated:<probe> The probe hit a cap, so a negative could not be proven.
expression:<stage>:<message> applies_when or violation failed. When the probe is ok but the expression touched a file entry that is not, the message says so: probe is unreadable or probe is invalid (from a helper such as global_first), or no such key: matches (from reading f.matches directly). Otherwise it is the expression's own error, such as no such key: valeu for a misspelled field or no such overload: string < int. <stage>:type means it returned the wrong type.
evaluator_timeout The scan used up its time or CPU budget before this rule.
evaluator_crashed, evaluator_protocol, evaluator_unverified, evaluator_unavailable The evaluator process failed, produced output the sensor rejected, could not be verified, or could not start.
reply_truncated The scan's reply reached its 1 MB cap before this result.
over_capacity Set by the extension: the rule is past the organization's cap of 2,000 enabled rules, or a host's rules need more than 16 requests.

An unsupported result carries platform, evaluator_version, probe_unsupported or language_version <version>. A rule the sensor cannot parse at all (a misspelled format, a discover entry without file_regex, a non-literal split()) is reported unsupported with the parse message.

Tests

tests is a list. The hive runs every test when you save the rule and refuses the rule if any fails.

tests:
  - name: set to 10
    probes:
      sshd:
        status: ok
        discovered: [{ dir: /etc/ssh/sshd_config.d, status: absent, count: 0 }]
        files:
          - path: /etc/ssh/sshd_config
            status: ok
            parse_status: ok
            matches: [{ selector: MaxAuthTries, found: true, key: MaxAuthTries, value: "10", kind: scalar, line: 40 }]
    expect: fail
    evidence: { set_to: ["/etc/ssh/sshd_config: 10"] }
Field Required Checked
name Yes Names the test in error messages.
probes Yes Mocked results, keyed by probe name, in the shapes of Probes.
expect Yes pass, fail, error, not_applicable or unsupported.
instances No The exact set of instances.
evidence No Only the labels listed, compared exactly ("1" is not 1).
by_absence No true states that the result is not_applicable by absence, and goes with expect: not_applicable. false is checked too.
incomplete No The probes a fail lists as unreadable or truncated. Give probe names (incomplete: [sshd]): the full reason strings differ between tests and hosts.
error_finding No Avoid it. The test runner does not count tolerated probes here, but in Host Posture the error finding opens whenever incomplete is not empty.
now No The evaluation time, RFC 3339. Defaults to 2026-01-01T00:00:00Z. Set it in every test of a rule that uses now or days_until.

Mock rules:

  • A probe left out of a test reads as unsupported, which makes the rule unsupported (an optional probe excepted). Mock every probe in every test.
  • Values, keys, paths, names and versions must be strings. Quote them: value: "1", value: "yes", version: "1.30.0-1". line must be an integer.
  • Timestamps (mtime, not_before, not_after) are RFC 3339 strings.
  • An ok config mock must have a file entry for every literal path in paths (paths with ${...} or globs excepted), and a discovered entry for every discover directory. Glob matches and discovered files are yours to list.
  • A file entry that is not ok must not have matches.
  • A test whose pass or not_applicable was decided by an absent item not listed in absent_is_pass is refused, unless it says by_absence: true.

The hive does not require tests, and it does not check that they cover every case. Write at least one fail, one pass and one error test, a not_applicable test when there is an applies_when, and a test that checks instances when violation returns a list. The error test, with a probe unreadable, is the one that catches a rule that would wrongly fail or pass on a host it could not read.

Limits

Limit At save On the host
Rule document 128 KiB as compact JSON, 32 levels deep, 50,000 values
id, title 256 bytes each
platforms at most 5 entries
standards 32 ids per framework, 128 bytes each
Probes per rule 16
config files per probe 256 expanded paths; max up to 256 32 files read; more marks the probe truncated
discover 8 entries, depth up to 3 64 directories visited
Config file 10 MB; values cut at 4 KB; 1,024 matches per file
Expression 4 KB, 32 bracket levels, 3 nested macros, 10,000 cost units per evaluation in tests
Tests all tests of a rule within 200,000 work units
certs 4,096 certificates, 16 MB
packages 4,096 matching packages
registry_values 1,024 values, 64 KiB per value
Instances 64 per rule per host, 512 bytes each
One result 64 KiB, evidence included
One scan's reply 1 MB; later results become error, reply_truncated
One scan 300 s of wall clock, 60 s of CPU, 256 MB of memory (Linux and Windows), one scan at a time, at most 4 scans per hour
Rules per organization 2,000 enabled rules run, in record-name order, applied by the extension when it builds a scan
Requests per host 16 requests of at most 256 rules and 512 KB

A rule past the organization's cap of 2,000 enabled rules, or that a host's 16 requests cannot hold, is reported as error with the reason over_capacity on every host affected. The extension splits a host's rules into requests of at most 256 rules and 512 KB, and sends each one at least 15 minutes after the previous one was answered.

See Also