Repository navigation
Predicate Search
Brandon Dalton edited this page Dec 1, 2026
·
4 revisions
- Filtering on event type and process path only goes so far. Eventually the question we want answered is about one field of the record. For example, "which
osascriptexecs asked for a password?". Predicate search lets you ask that question directly. - A predicate is an
NSPredicateevaluated on each event's record. That's the same JSON Export Telemetry writes, so every key in the telemetry schema can be used.
- Predicate Editor (View > Predicate Editor, ⌥⌘F): sits beside the event tables or pops out into its own window. It colors syntax, completes key paths as you type, and flags keys the schema doesn't name. Apply (⌘↩) filters the tables. Predicates you save are kept under Saved, and the ones you apply under Recent.
- Search field (⌘F): filters by each event's context as you type. With a predicate applied, it narrows that predicate's matches.
-
Command line:
sudo macmonitor stream --predicate '...'uses the same engine. Repeating--predicateANDs them together. - Telemetry Schema window: lists every key a record has.
es_event_type == "ES_EVENT_TYPE_NOTIFY_EXEC" AND event.exec.target.executable.name == "osascript"
(event.exec.script_content CONTAINS[c] "display dialog" AND event.exec.script_content CONTAINS[c] "password")
OR (event.exec.command_line CONTAINS[c] "display dialog" AND event.exec.command_line CONTAINS[c] "password")
es_event_type == "ES_EVENT_TYPE_NOTIFY_DELETEEXTATTR" AND event.deleteextattr.extattr ENDSWITH "apple.quarantine"
event.exec.target.is_adhoc_signed AND event.exec.target.euid == 0
- A boolean key path can stand on its own, as
is_adhoc_signeddoes above. It reads as== YES. -
event.exec != nilnames an event's type by its payload, ases_event_type == "ES_EVENT_TYPE_NOTIFY_EXEC"does. A network flow's record has noes_event_type, soevent.new_flow != nilandevent.flow_closed != nilname its type.
In Mac Monitor's window, a SUBQUERY can compare an event with other events in the trace. Inside it, $e. is the related event and a plain key path is the event being searched:
SUBQUERY(process_group, $e, $e.es_event_type == "ES_EVENT_TYPE_NOTIFY_CREATE").@count > 0
- This matches an event whose process group created a file.
- Relations:
events,process_group,session_group,correlated(the process anEXECorFORKcreated), andprocess_events. -
macmonitor streamand indicators look at one event at a time, so neither takes aSUBQUERY.
A longer example: an adhoc signed process maps an Open Scripting Architecture component, then connects to mDNSResponder's socket. That connection is a DNS lookup, which usually comes right before a network connection.
target_path ENDSWITH "/mDNSResponder" AND process.is_adhoc_signed
AND SUBQUERY(process_events, $e, $e.target_path CONTAINS "Script.component" AND $e.mach_time < mach_time).@count > 0
- It matches the
UIPC_CONNECT, one event per lookup.Script.componentcovers bothAppleScript.componentandJavaScript.component.process_eventsgoes through the other events of the same process, and$e.mach_time < mach_timekeeps only the mappings that came before the connection.
-
macmonitorruns as root, so predicates are data-only.FUNCTION,CAST, and any key the schema doesn't name are refused when the predicate is parsed.NSPredicate's own arithmetic, string, and aggregate functions are allowed. -
MATCHESgives up on a value after 0.5 seconds, so a regular expression that backtracks without end can't stall a stream or a search. - An indicator's predicate runs in the Security Extension, which takes less. See Indicators.