Skip to content

Commit 34c7d48

Browse files
committed
Update
1 parent 0707cae commit 34c7d48

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

docs/cse/rules/before-writing-custom-rule.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Now that we understand the mapping in Cloud SIEM, we can see we will want to be
5151

5252
In this step, we’ll create the query that will serve as the rule expression when we create the rule.
5353

54-
1. Using the attributes we discovered from looking at the log mapping, we’ll run the following query, which returns the usernames that have successfully logged on over the last week, counted by `user_username`.
54+
1. Using the attributes we discovered from looking at the log mapping, we’ll run the following query, which returns the usernames that have successfully logged on over the last week, counted by `user_username`:
5555

5656
```sql
5757
_index=sec_record_*
@@ -63,10 +63,10 @@ In this step, we’ll create the query that will serve as the rule expression wh
6363

6464
The results show two of our standard username patterns: 
6565

66-
* The username for regular user accounts are a plain string, with no special characters, like specops and jask.
66+
* The username for regular user accounts are a plain string, with no special characters, like `specops` and `jask`.
6767
* Machine usernames are a string, followed by a dash character, followed by a string, followed by a dollar sign, like `win10-admin$` and `win10-client$`.
6868

69-
1. Now, we can refine our search to return usernames that do not comply with either of our standard patterns.
69+
1. Now, we can refine our search to return usernames that do not comply with either of our standard patterns:
7070

7171
```sql
7272
_index=sec_record_*
@@ -76,7 +76,7 @@ In this step, we’ll create the query that will serve as the rule expression wh
7676

7777
<img src={useBaseUrl('img/cse/non-matching-patterns.png')} alt="Non-matching patterns" width="800"/>
7878

79-
1. Usernames returned include “anonymous logon”. A little [research](https://social.technet.microsoft.com/Forums/ie/en-US/dbcbb9f1-c6a7-43ea-94b8-ba72a89e2221/nt-authorityanonymous-logon?forum=winservergen) indicates that this is typically no cause for alarm, so we’ll refine our search again to exclude “anonymous logon”.
79+
1. Usernames returned include “anonymous logon”. A little [research](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-special-identities-groups) indicates that this is typically no cause for alarm, so we’ll refine our search again to exclude “anonymous logon”:
8080

8181
```sql
8282
_index=sec_record_*
@@ -89,17 +89,25 @@ In this step, we’ll create the query that will serve as the rule expression wh
8989

9090
<img src={useBaseUrl('img/cse/messages-tab.png')} alt="Messages tab" width="800"/>
9191

92-
We update the query to parse out `EventData.ProcessName`, naming it `process_name`, and filtering to only fire on `.exe` files. 
92+
We update the query to parse out `EventData.ProcessName`, naming it `process_name`, and filtering to only fire on `.exe` files: 
9393

9494
```sql
9595
_index=sec_record_*
96-
| json field=_raw "$['EventData.ProcessName']" as process_name
97-
| where metadata_vendor = "Microsoft" and metadata_product = "Windows" and metadata_deviceEventId = "Security-4624" and !(user_username matches /^[a-zA-Z]*$/ or user_username matches "*-*$") and user_username != "anonymous logon" and process_name matches "*.exe"
96+
| where metadata_vendor = "Microsoft" and metadata_product = "Windows" and metadata_deviceEventId = "Security-4624" and !(user_username matches /^[a-zA-Z]*$/ or user_username matches "*-*$") and user_username != "anonymous logon" and fields["EventData.ProcessName"] matches "*.exe"
9897
```
9998

100-
1. Now we have a query we can use as the basis of an expression for our rule. Note that when you paste it into the rules editor you should remove the first portion of the query, which is only necessary when you are querying records in Sumo Logic: `_index=sec_record_*`
99+
1. Now we have a query we can use as the basis of an expression for our rule. Note that when you paste it into the rules editor, you should remove the first portion of the query (`_index=sec_record_*` and `| where`), which is only necessary when you are querying records in Sumo Logic. The expression is then as follows:
101100

102-
You should also ensure that the syntax of the expression matches what is needed by the [Cloud SIEM rules syntax](/docs/cse/rules/cse-rules-syntax/).
101+
```sql
102+
metadata_vendor = "Microsoft"
103+
and metadata_product = "Windows"
104+
and metadata_deviceEventId = "Security-4624"
105+
and !(user_username matches /^[a-zA-Z]*$/ or user_username matches "*-*$")
106+
and user_username != "anonymous logon"
107+
and fields["EventData.ProcessName"] matches "*.exe"
108+
```
109+
110+
Also ensure that the syntax of the expression matches what is needed by the [Cloud SIEM rules syntax](/docs/cse/rules/cse-rules-syntax/). Once you are satisfied that the expression is ready, click **Test Rule Expression** to verify that the expression returns expected results.
103111

104112
You can use an expression like this example in any rule type. Here is an example Match rule with the expression, shown in the rules editor.
105113

98.6 KB
Loading

0 commit comments

Comments
 (0)