Conditions¶
Summary
Conditions decide whether a rule matches. They check processes, windows, the time or the result of a command and can be combined with and, or and not.
Example¶
rules:
# Match on weekends while no backup process is running
- name: "Weekend without backup"
conditions:
and:
- datetime:
weekday:
- "Saturday"
- "Sunday"
- process:
name: "backup" #(1)!
exists: false
actions:
- run: "echo Weekend without backup"
- Consider using
containsorregexmatching for different platforms.
Every rule has exactly one conditions entry. To check several things, combine them with a logical condition.
Condition types¶
| Condition | Matches when | Notes |
|---|---|---|
process |
a process with the given name exists or does not exist | |
window |
a window with the given title exists or does not exist | Availability depends on the platform |
datetime |
the current date, time, weekday or month fits | Uses the local time of the computer |
command |
the exit code and the output of a command fit | Also runs with --dry-run |
and, or, not |
the combination of other conditions fits |
process, window and command compare text with match types: exact, regular expression or contains.
Details¶
- Conditions are evaluated on every evaluation of the policy.
andandorstop at the first decisive result, so the remaining conditions might not run.- If a condition cannot be evaluated (e.g. a command exceeds its timeout or window conditions are not available on the platform), the evaluation stops.
Related¶
-
Continuous evaluation and
--dry-run. -
Run commands when a rule matches.
-
Detect modifications of policies and scripts.