“事件”部分语法

支持的平台:

在规则中,events 部分必须紧跟在 meta 部分之后。它定义了查询应检查哪些事件,以及这些事件必须具备哪些特定属性才能被视为与潜在检测相关。

events 部分对于规则是必需的,但对于搜索和信息中心是可选的。

使用 events 部分列出谓词以指定以下内容:

  • 变量声明
  • 事件变量过滤条件
  • 事件变量联接

“定义事件”部分

仅关注一种事件类型的规则和查询可以包含单个事件变量,例如:

events:
  $e.metadata.event_type = "USER_LOGIN" // 'e' is the common convention for a single event

如果规则和查询需要关联两种或更多种不同类型的事件(例如用户登录后进行文件修改),则需要为每种类型的事件提供一个变量:

events:
  $login.metadata.event_type = "USER_LOGIN" // Event 1: User Login
  $file_op.metadata.event_type = "FILE_MODIFICATION" // Event 2: File Modification

声明事件变量后,您可以使用该变量作为前缀来访问相应事件类型的特定字段。例如,以下 event 部分会过滤来自 Okta 的登录失败事件:

events:
   $e.metadata.vendor_name = "Okta"
   $e.metadata.event_type = "USER_LOGIN"
   $e.security_result.action = "FAIL"

变量声明

对于变量声明,请使用以下语法:

  • <EVENT_FIELD> = <VAR>
  • <VAR> = <EVENT_FIELD>

这两个示例是等效的,如以下示例所示:

  • $e.source.hostname = $hostname
  • $userid = $e.principal.user.userid

此声明表明此变量表示事件变量的指定字段。当事件字段是重复字段时,match 变量可以表示数组中的任何值。您还可以将多个事件字段分配给单个匹配或占位符变量。这是一个传递性联接条件。

例如,以下方法:

  • $e1.source.ip = $ip
  • $e2.target.ip = $ip

等效于:

  • $e1.source.ip = $ip
  • $e1.source.ip = $e2.target.ip

使用变量时,必须通过变量声明来声明该变量。如果使用变量时未做任何声明,则会触发编译错误。

如需详细了解变量,请参阅表达式、运算符和其他结构

事件变量过滤条件

对单个事件变量起作用的布尔表达式被视为过滤条件。

事件变量联接

规则中使用的所有事件变量必须采用以下任一方式与所有其他事件变量联接:

  • 通过两个联接事件变量的事件字段之间的相等比较直接联接,例如:$e1.field = $e2.field。表达式不得包含算术运算(例如 $\text{+, -, *, /}$)。

  • 通过仅涉及一个事件字段的传递联接间接联接(请参阅变量声明中的“传递联接”定义)。表达式不得包含算术运算。

例如,假设规则中使用了 $e1$e2$e3,以下 events 部分有效:

events:
  $e1.principal.hostname = $e2.src.hostname // $e1 joins with $e2
  $e2.principal.ip = $e3.src.ip // $e2 joins with $e3
events:
  // $e1 joins with $e2 using function to event comparison
  re.capture($e1.src.hostname, ".*") = $e2.target.hostname
events:
  // $e1 joins with $e2 using an `or` expression
  $e1.principal.hostname = $e2.src.hostname
  or $e1.principal.hostname = $e2.target.hostname
  or $e1.principal.hostname = $e2.principal.hostname
events:
  // all of $e1, $e2 and $e3 are transitively joined using the placeholder variable $ip
  $e1.src.ip = $ip
  $e2.target.ip = $ip
  $e3.about.ip = $ip
events:
  // $e1 and $e2 are transitively joined using function to event comparison
  re.capture($e2.principal.application, ".*") = $app
  $e1.principal.hostname = $app

不过,以下示例展示了无效的 events 部分。

events:
  // Event to arithmetic comparison is an invalid join condition for $e1 and $e2.
  $e1.principal.port = $e2.src.port + 1
events:
  $e1.src.ip = $ip
  $e2.target.ip = $ip
  $e3.about.ip = "192.1.2.0" //$e3 is not joined with $e1 or $e2.
events:
  $e1.src.port = $port

  // Arithmetic to placeholder comparison is an invalid transitive join condition.
  $e2.principal.port + 800 = $port

后续步骤

其他信息

需要更多帮助?获得社区成员和 Google SecOps 专业人士的解答。