I want to write a pipeline rule checks two conditions and sets a field.
Example
// function to detect bad things
rule "lets detect bad stuff"
when
// To save CPU cycles, only run on this field in stream
has_field("sysmon_event_id") AND
then
set_field("BadDetected", "true");
end
The logic in the when condition is something similar to below
If sysmon_eventid=11 and granted-access=0x100 then set field
Both sysmon_event_id and granted access are fields and can be searched on inn the search bar with this
// function to detect bad things
rule "lets detect bad stuff"
when
// sets check for the presence of both fields
has_field("sysmon_event_id") && has_field("GrantedAccess")
then
contains(to_string($message.sysmon_event_id","11") && (to_string($message.GrantedAccess","0x100");
set_field("BadDetected", "true");
end
// function to detect bad things
rule “lets detect bad stuff”
when
// sets check for the presence of both fields
has_field(“sysmon_event_id”) AND
has_field(“GrantedAccess”) AND
contains(to_string($message.sysmon_event_id,“11”) AND
contains(to_string($message.GrantedAccess,“0x100”)
then
set_field(“BadDetected”, “true”);
end
actually I just wrote the rule direct in the Forum - not in the editor. That is just missing ) and wrong " and I missed the order of contains (first value then the string)
rule "lets detect bad stuff"
when
// sets check for the presence of both fields
has_field("sysmon_event_id") AND
has_field("GrantedAccess") AND
contains("11",to_string($message.sysmon_event_id)) AND
contains("0x100", to_string($message.GrantedAccess))
then
set_field("BadDetected", "true");
end