Skip to content

Commit 4923d25

Browse files
authored
[eset] FIX: Add x_opencti_main_observable_type when missing from atomic indicators (#3237)
1 parent e20265a commit 4923d25

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

external-import/eset/src/eset.py

+23
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import datetime
33
import json
44
import os
5+
import re
56
import sys
67
import time
78

@@ -21,6 +22,15 @@
2122

2223
TMP_DIR = "TMP"
2324

25+
OBSERVABLE_TYPES_MAP = {
26+
"url:value": "Url",
27+
"domain-name:value": "Domain-Name",
28+
"ipv4-addr:value": "IPv4-Addr",
29+
"file:hashes.MD5": "MD5",
30+
"file:hashes.'SHA-1'": "SHA-1",
31+
"file:hashes.'SHA-256'": "SHA-256",
32+
}
33+
2434

2535
class Eset:
2636
def __init__(self):
@@ -164,6 +174,7 @@ def _import_collection(self, collection, work_id, start_epoch):
164174
client.set_auth(username=self.eset_username, password=self.eset_password)
165175
no_more_result = False
166176
end_epoch = start_epoch + 3600
177+
atomic_ind_pattern = re.compile(r"\[(\S+) = '[^']+'\]")
167178
while no_more_result is False:
168179
self.helper.log_info(
169180
"Iterating with collection="
@@ -249,10 +260,22 @@ def _import_collection(self, collection, work_id, start_epoch):
249260
else:
250261
id_remaps[object["id"]] = new_id
251262
object["id"] = new_id
263+
264+
# Attempt to fill in x_opencti_main_observable_type
265+
atomic_match = atomic_ind_pattern.fullmatch(
266+
object["pattern"]
267+
)
268+
if atomic_match:
269+
pattern_field_name = atomic_match.group(1)
270+
if pattern_field_name in OBSERVABLE_TYPES_MAP:
271+
object["x_opencti_main_observable_type"] = (
272+
OBSERVABLE_TYPES_MAP[pattern_field_name]
273+
)
252274
if self.eset_create_observables:
253275
object["x_opencti_create_observables"] = (
254276
self.eset_create_observables
255277
)
278+
object["where_sighted_refs"] = []
256279
objects.append(object)
257280
parsed_content["objects"] = objects
258281
self.helper.send_stix2_bundle(

0 commit comments

Comments
 (0)