Skip to content

Commit b89a1b9

Browse files
romain-filigranRomain GUIGNARD
and
Romain GUIGNARD
authored
Dev 1.1.5 (#26)
* udpate to version 1.1.5 * #25 * #24 --------- Co-authored-by: Romain GUIGNARD <[email protected]>
1 parent 60baaa7 commit b89a1b9

File tree

7 files changed

+80
-9
lines changed

7 files changed

+80
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ The app is installed
1818

1919
### Installing from file
2020

21-
1. Download latest version of the Splunk App: [TA-opencti-add-on-1.1.4.spl](https://github.com/OpenCTI-Platform/splunk-add-on/releases/download/1.1.4/TA-opencti-add-on-1.1.4.spl)
21+
1. Download latest version of the Splunk App: [TA-opencti-add-on-1.1.5.spl](https://github.com/OpenCTI-Platform/splunk-add-on/releases/download/1.1.5/TA-opencti-add-on-1.1.5.spl)
2222
2. Log in to the Splunk Web UI and navigate to "Apps" and click on "Manage Apps"
2323
3. Click "Install app from file"
24-
4. Choose file and select the "TA-opencti-add-on-1.1.4.spl" file
24+
4. Choose file and select the "TA-opencti-add-on-1.1.5.spl" file
2525
5. Click on Upload
2626
The app is installed
2727

TA-opencti-add-on/app.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"id": {
66
"group": null,
77
"name": "TA-opencti-add-on",
8-
"version": "1.1.4"
8+
"version": "1.1.5"
99
},
1010
"author": [
1111
{

TA-opencti-add-on/appserver/static/js/build/globalConfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"meta": {
33
"name": "TA-opencti-add-on",
44
"displayName": "OpenCTI Add-on",
5-
"version": "1.1.4",
5+
"version": "1.1.5",
66
"restRoot": "TA_opencti_add_on",
77
"_uccVersion": "5.39.0",
88
"schemaVersion": "0.0.3"

TA-opencti-add-on/appserver/static/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.0.0",
33
"info": {
44
"title": "TA-opencti-add-on",
5-
"version": "1.1.4",
5+
"version": "1.1.5",
66
"description": "OpenCTI Add-on",
77
"contact": {
88
"name": "Filigran"

TA-opencti-add-on/bin/ta_opencti_add_on/stix_converter.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
from stix_constants import CustomObservableUserAgent, CustomObservableText, CustomObjectCaseIncident
55
from utils import get_hash_type, is_ipv6, is_ipv4
6+
from utils import generate_incident_id, generate_identity_id, generate_relation_id, generate_case_incident_id
67

78

89
def _get_stix_marking_id(value):
910
if value == "tlp_clear":
10-
return stix2.TLP_CLEAR
11+
return stix2.TLP_WHITE
1112
if value == "tlp_green":
1213
return stix2.TLP_GREEN
1314
if value == "tlp_amber":
@@ -268,6 +269,7 @@ def convert_to_incident_response(alert_params, event):
268269

269270
# manage author
270271
stix_author = stix2.Identity(
272+
id=generate_identity_id(event.get("host", "Splunk"), "system"),
271273
name=event.get("host", "Splunk"),
272274
identity_class="system"
273275
)
@@ -296,6 +298,7 @@ def convert_to_incident_response(alert_params, event):
296298

297299
# create incident response case
298300
stix_case_incident = CustomObjectCaseIncident(
301+
id=generate_case_incident_id(alert_params.get("name"), event_date),
299302
name=alert_params.get("name"),
300303
description=alert_params.get("description"),
301304
severity=alert_params.get("severity"),
@@ -330,6 +333,7 @@ def convert_to_incident(alert_params, event):
330333

331334
# manage author
332335
stix_author = stix2.Identity(
336+
id=generate_identity_id(event.get("host", "Splunk"), "system"),
333337
name=event.get("host", "Splunk"),
334338
identity_class="system"
335339
)
@@ -341,21 +345,24 @@ def convert_to_incident(alert_params, event):
341345
observables = _extract_observables_from_cim_model(
342346
event=event,
343347
marking=marking_id,
344-
creator=stix_author)
348+
creator=stix_author
349+
)
345350
for observable in observables:
346351
bundle_objects.append(observable)
347352
observable_ref_ids.append(observable.id)
348353
if alert_params.get("observables_extraction") == "field_mapping":
349354
observables = _extract_observables_from_key_model(
350355
event=event,
351356
marking=marking_id,
352-
creator=stix_author)
357+
creator=stix_author
358+
)
353359
for observable in observables:
354360
bundle_objects.append(observable)
355361
observable_ref_ids.append(observable.id)
356362

357363
# create incident
358364
stix_incident = stix2.Incident(
365+
id=generate_incident_id(alert_params.get("name"), event_date),
359366
name=alert_params.get("name"),
360367
created=event_date,
361368
description=alert_params.get("description"),
@@ -375,6 +382,8 @@ def convert_to_incident(alert_params, event):
375382

376383
for observable_id in observable_ref_ids:
377384
stix_relation_account = stix2.Relationship(
385+
id=generate_relation_id(
386+
"related-to", observable_id, stix_incident.id),
378387
relationship_type="related-to",
379388
source_ref=observable_id,
380389
target_ref=stix_incident.id,

TA-opencti-add-on/bin/ta_opencti_add_on/utils.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import datetime
12
import ipaddress
23
import re
4+
import uuid
5+
6+
from stix2.canonicalization.Canonicalize import canonicalize
37

48
regex_sha512 = r"[0-9a-fA-F]{128}"
59
regex_sha256 = r"[0-9a-fA-F]{64}"
@@ -53,3 +57,61 @@ def get_hash_type(value):
5357
return "md5"
5458
else:
5559
return None
60+
61+
def generate_identity_id(name, identity_class):
62+
data = {"name": name.lower().strip(), "identity_class": identity_class.lower()}
63+
data = canonicalize(data, utf8=False)
64+
id = str(uuid.uuid5(uuid.UUID("00abedb4-aa42-466c-9c01-fed23315a9b7"), data))
65+
return "identity--" + id
66+
67+
def generate_incident_id(name, created):
68+
name = name.lower().strip()
69+
if isinstance(created, datetime.datetime):
70+
created = created.isoformat()
71+
data = {"name": name, "created": created}
72+
data = canonicalize(data, utf8=False)
73+
id = str(uuid.uuid5(uuid.UUID("00abedb4-aa42-466c-9c01-fed23315a9b7"), data))
74+
return "incident--" + id
75+
76+
77+
def generate_case_incident_id(name, created):
78+
name = name.lower().strip()
79+
if isinstance(created, datetime.datetime):
80+
created = created.isoformat()
81+
data = {"name": name, "created": created}
82+
data = canonicalize(data, utf8=False)
83+
id = str(uuid.uuid5(uuid.UUID("00abedb4-aa42-466c-9c01-fed23315a9b7"), data))
84+
return "case-incident--" + id
85+
86+
def generate_relation_id(
87+
relationship_type, source_ref, target_ref, start_time=None, stop_time=None
88+
):
89+
if isinstance(start_time, datetime.datetime):
90+
start_time = start_time.isoformat()
91+
if isinstance(stop_time, datetime.datetime):
92+
stop_time = stop_time.isoformat()
93+
94+
if start_time is not None and stop_time is not None:
95+
data = {
96+
"relationship_type": relationship_type,
97+
"source_ref": source_ref,
98+
"target_ref": target_ref,
99+
"start_time": start_time,
100+
"stop_time": stop_time,
101+
}
102+
elif start_time is not None:
103+
data = {
104+
"relationship_type": relationship_type,
105+
"source_ref": source_ref,
106+
"target_ref": target_ref,
107+
"start_time": start_time,
108+
}
109+
else:
110+
data = {
111+
"relationship_type": relationship_type,
112+
"source_ref": source_ref,
113+
"target_ref": target_ref,
114+
}
115+
data = canonicalize(data, utf8=False)
116+
id = str(uuid.uuid5(uuid.UUID("00abedb4-aa42-466c-9c01-fed23315a9b7"), data))
117+
return "relationship--" + id

TA-opencti-add-on/default/app.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build = 1
77

88
[launcher]
99
author = Filigran
10-
version = 1.1.4
10+
version = 1.1.5
1111
description = Add-on for OpenCTI
1212

1313
[ui]

0 commit comments

Comments
 (0)