|
2 | 2 | import datetime
|
3 | 3 | import json
|
4 | 4 | import os
|
| 5 | +import re |
5 | 6 | import sys
|
6 | 7 | import time
|
7 | 8 |
|
|
21 | 22 |
|
22 | 23 | TMP_DIR = "TMP"
|
23 | 24 |
|
| 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 | + |
24 | 34 |
|
25 | 35 | class Eset:
|
26 | 36 | def __init__(self):
|
@@ -164,6 +174,7 @@ def _import_collection(self, collection, work_id, start_epoch):
|
164 | 174 | client.set_auth(username=self.eset_username, password=self.eset_password)
|
165 | 175 | no_more_result = False
|
166 | 176 | end_epoch = start_epoch + 3600
|
| 177 | + atomic_ind_pattern = re.compile(r"\[(\S+) = '[^']+'\]") |
167 | 178 | while no_more_result is False:
|
168 | 179 | self.helper.log_info(
|
169 | 180 | "Iterating with collection="
|
@@ -249,10 +260,22 @@ def _import_collection(self, collection, work_id, start_epoch):
|
249 | 260 | else:
|
250 | 261 | id_remaps[object["id"]] = new_id
|
251 | 262 | 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 | + ) |
252 | 274 | if self.eset_create_observables:
|
253 | 275 | object["x_opencti_create_observables"] = (
|
254 | 276 | self.eset_create_observables
|
255 | 277 | )
|
| 278 | + object["where_sighted_refs"] = [] |
256 | 279 | objects.append(object)
|
257 | 280 | parsed_content["objects"] = objects
|
258 | 281 | self.helper.send_stix2_bundle(
|
|
0 commit comments