You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/examples/alert.md
+17-15Lines changed: 17 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Here's an example that demonstrates how to create the most simplistic alert poss
18
18
19
19
## An advanced alert
20
20
21
-
In the previous example we really kept things simple and only specified the required alert fields inline in the create method call.
21
+
The previous example was as simple as it gets and only specified the required alert fields inline in the create method call.
22
22
With a more advanced example this can become complicated and hard to read.
23
23
Fortunately we can use `thehive4py`'s type hints to the rescue and specify more complex input alerts outside of the method call.
24
24
@@ -37,11 +37,13 @@ Finally after the creation of the alert we saved the response in the `output_ale
37
37
38
38
## Alert observables
39
39
40
-
TheHive API provides multiple ways to add observables to alerts, let them be textual or file based observables.
40
+
In TheHive an observable is a piece of data or evidence (e.g., an IP address, domain, etc.) associated with a security incident, used to provide context and aid in the investigation and response process.
41
+
42
+
Let's take a look at different ways of populating alerts with observables, let them be textual or file based observables.
41
43
42
44
### Add observables during alert creation
43
45
44
-
We can add observables already during alert creation. This is a great way to combine alert and observable creation in a simple and atomic way:
46
+
We can add observables already during alert creation. This is a great way to combine alert and observable creation in an atomic way:
45
47
46
48
Let's create an alert with an `ip` and a `domain` observable:
47
49
@@ -51,7 +53,7 @@ Let's create an alert with an `ip` and a `domain` observable:
51
53
52
54
### Add observables to an existing alert
53
55
54
-
While it's probably the most convenient way to combine alert and observable creation in a single call, sometimes we don't have all the observables at hand during alert creation time.
56
+
While it's probably the most convenient way to combine alert and observable creation in a single call, sometimes we don't have all the observables at hand during alert creation time or we have such a large number of observables that we cannot send them all in one single request.
55
57
56
58
Fortunately TheHive API supports alert observable creation on already existing alerts. Let's repeat the previous example, but this time add the two observables to an existing alert using the [alert.create_observable][thehive4py.endpoints.alert.AlertEndpoint.create_observable] method:
57
59
@@ -62,7 +64,7 @@ Fortunately TheHive API supports alert observable creation on already existing a
62
64
63
65
### Add file based observables
64
66
65
-
In the previous examples we've seen how to handle simple observables without attachments. Next we will create a temporary directory with a dummy file and some dummy content that will represent our file based observable and add it to an alert:
67
+
In the previous examples we've seen how to handle observables without attachments. However sometimes we also want to add attachments to an observable not only textual data. Fortunately that is supported by TheHive. So in the next example let's create a temporary directory with a dummy file and some dummy content that will represent our file based observable and add it to an alert:
66
68
67
69
68
70
```python
@@ -77,21 +79,21 @@ In our example `attachment_key` is used to specify the relationship between the
77
79
78
80
## Update single and bulk
79
81
80
-
Sometimes an existing alert needs to be updated. `thehive4py` offers multiple ways to accomplish this task either with a single alert or multiple ones.
82
+
Creating alerts is fun but sometimes an existing alert also needs to be updated. As expected `thehive4py` offers multiple ways to accomplish this task either on a single alert or multiple ones.
81
83
82
84
### Update single
83
85
84
-
A single alert can be updated using [alert.update][thehive4py.endpoints.alert.AlertEndpoint.update] method. The method requires the `alert_id` of the alert to be updated and the `fields` to update.
86
+
A single alert can be updated using the [alert.update][thehive4py.endpoints.alert.AlertEndpoint.update] method. The method requires the `alert_id` of the alert to be updated and the `fields` to update.
85
87
86
88
```python
87
89
--8<--"examples/alert/update_single.py"
88
90
```
89
91
90
92
In the above example we've updated the `title` and the `tags` fields.
91
93
92
-
Be mindful though, `thehive4py` is a lightweight wrapper around TheHive API and offers no object relationship mapping functionalities, meaning that the original `original_alert` won't reflect the changes of the update.
94
+
Be mindful though, `thehive4py` is a lightweight wrapper around TheHive API and offers no object relationship mapping functionalities, meaning that the `original_alert` won't reflect the changes of the update.
93
95
94
-
To work with the updated alert we fetched the latest version using the [alert.get][thehive4py.endpoints.alert.AlertEndpoint.get] method and stored it in the `updated_alert` variable.
96
+
In order to work with the updated alert we had to fetch the latest version using the [alert.get][thehive4py.endpoints.alert.AlertEndpoint.get] method and store it in the `updated_alert` variable.
95
97
96
98
Now the content of `updated_alert` should reflect the changes we made with our update request.
97
99
@@ -100,8 +102,8 @@ Now the content of `updated_alert` should reflect the changes we made with our u
100
102
101
103
### Update bulk
102
104
103
-
To update the **same fields** with the **same values** on multiple alerts at the same time, one can use [alert.bulk_update][thehive4py.endpoints.alert.AlertEndpoint.bulk_update] method.
104
-
The method accepts the same `fields` dictionary with an additional `ids` field on it, which should contain the list of ids of the alerts to be bulk updated.
105
+
It is also possible to update many alerts at the same time, however there's a constraint: the content of the `fields` property will be applied to all the specified alerts uniformly. With all that said one can use [alert.bulk_update][thehive4py.endpoints.alert.AlertEndpoint.bulk_update] method for bulk updates.
106
+
The method accepts the same `fields` dictionary as before but with an additional `ids` field on it, which should contain the list of ids of the alerts to be bulk updated.
105
107
106
108
```python
107
109
--8<--"examples/alert/update_bulk.py"
@@ -112,7 +114,7 @@ Then we update the fields `title` and `tags` on both alerts using the bulk updat
112
114
113
115
## Get and find
114
116
115
-
There are multiple ways to retrieve already existing alerts:
117
+
There are multiple ways to retrieve already existing alerts, we can fetch them one by one or many at once!
116
118
117
119
### Get a single alert
118
120
@@ -128,7 +130,7 @@ To fetch multiple alerts based on arbitrary conditions one can use the [alert.fi
128
130
129
131
In the next example we will create two alerts with different tags. The first alert will get the `antivirus` tag while the second one will get the `phishing` tag.
130
132
131
-
Then we will construct a query filter that will look for alerts with these tags on them:
133
+
Then we will construct query filters in different ways to look for alerts with these tags on them:
132
134
133
135
```python
134
136
--8<--"examples/alert/fetch_with_find.py"
@@ -175,7 +177,7 @@ Oftentimes new alerts correspond to an already existing case. Fortunately we hav
175
177
--8<--"examples/alert/case_merge.py"
176
178
```
177
179
178
-
In the above example we prepared a `parent_case` to which we merge the `new_alert` using their ids and finally save the updated case in the `updated_parent_case` variable.
180
+
In the above example we prepared a `parent_case` to which we merge the `new_alert` using its id and finally save the updated case in the `updated_parent_case` variable.
179
181
180
182
!!! tip
181
183
It can happen that multiple new alerts belong to the same parent case. In such situation we can use the [alert.bulk_merge_into_case][thehive4py.endpoints.alert.AlertEndpoint.bulk_merge_into_case] method for a more convenient merge process.
@@ -205,4 +207,4 @@ To delete multiple alerts via a single request one can use the [alert.bulk_delet
205
207
--8<--"examples/alert/delete_bulk.py"
206
208
```
207
209
208
-
In the above example we created two alerts and saved their ids in the `alert_ids_to_delete` variable just to pass it in the bulk deletion method.
210
+
In the above example we created two alerts and saved their ids in the `alert_ids_to_delete` variable just to pass it to the bulk deletion method.
0 commit comments