Skip to content

Commit 792b262

Browse files
Dev 1.1.0 (#14)
* update to version 1.0.2 * update to version 1.0.2 * #9 * update permissions * #4 * #10 * various update * #12
1 parent 4910b82 commit 792b262

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1369
-1100
lines changed

README.md

Lines changed: 3 additions & 3 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.0.1.spl](https://github.com/OpenCTI-Platform/splunk-add-on/releases/download/1.0.1/TA-opencti-add-on-1.0.1.spl)
21+
1. Download latest version of the Splunk App: [TA-opencti-add-on-1.1.0.spl](https://github.com/OpenCTI-Platform/splunk-add-on/releases/download/1.1.0/TA-opencti-add-on-1.1.0.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.0.1.spl" file
24+
4. Choose file and select the "TA-opencti-add-on-1.1.0.spl" file
2525
5. Click on Upload
2626
The app is installed
2727

@@ -68,7 +68,7 @@ If a proxy configuration is required to connect to OpenCTI platform, you can con
6868
## OpenCTI Indicators Inputs Configuration
6969

7070
The “OpenCTI Add-On for Splunk” enables Splunk to be feed with indicators exposed through a live stream. To do this, the add-on implements and manages Splunk modular inputs.
71-
Indicators are stored in a dedicated kvstore named “opencti_iocs”.
71+
Indicators are stored in a dedicated kvstore named “opencti_indicators”.
7272
A default lookup definition named "opencti_lookup" is also implemented to facilitate indicator management.
7373

7474
Proceed as follows to enable the ingestion of indicators:

TA-opencti-add-on/app.manifest

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
22
"schemaVersion": "2.0.0",
33
"info": {
4-
"title": "OpenCTI Add-on",
4+
"title": "OpenCTI Add-on for Splunk",
55
"id": {
66
"group": null,
77
"name": "TA-opencti-add-on",
8-
"version": "1.0.1"
8+
"version": "1.1.0"
99
},
1010
"author": [
1111
{
1212
"name": "Filigran",
13-
"email": null,
14-
"company": null
13+
"email": "[email protected]",
14+
"company": "Filigran"
1515
}
1616
],
1717
"releaseDate": null,
18-
"description": "",
18+
"description": "Add-on for OpenCTI",
1919
"classification": {
2020
"intendedAudience": null,
2121
"categories": [],
@@ -34,26 +34,18 @@
3434
},
3535
"releaseNotes": {
3636
"name": null,
37-
"text": null,
37+
"text": "./README.txt",
3838
"uri": null
3939
}
4040
},
41-
"dependencies": {
42-
},
43-
"tasks": [],
44-
"inputGroups": {
45-
},
46-
"incompatibleApps": {
47-
},
48-
"platformRequirements": {
49-
"splunk": {
50-
"Enterprise": "*"
51-
}
52-
},
41+
"dependencies": null,
42+
"tasks": null,
43+
"inputGroups": null,
44+
"incompatibleApps": null,
45+
"platformRequirements": null,
5346
"supportedDeployments": [
54-
"*"
47+
"_standalone",
48+
"_distributed"
5549
],
56-
"targetWorkloads": [
57-
"*"
58-
]
50+
"targetWorkloads": null
5951
}

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.0.1",
5+
"version": "1.1.0",
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.0.1",
5+
"version": "1.1.0",
66
"description": "OpenCTI Add-on",
77
"contact": {
88
"name": "Filigran"

TA-opencti-add-on/bin/input_module_opencti_indicators.py

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# encoding = utf-8
2-
from datetime import datetime, timezone, timedelta
32
import json
3+
import sys
4+
from datetime import datetime, timezone, timedelta
5+
6+
import six
47
import splunklib.client as client
58
from filigran_sseclient import SSEClient
69
from stix2patterns.v21.pattern import Pattern
7-
import six
10+
11+
from ta_opencti_add_on.constants import VERIFY_SSL, INDICATORS_KVSTORE_NAME
812
from ta_opencti_add_on.utils import get_proxy_config
9-
import sys
1013

1114
'''
1215
IMPORTANT
@@ -36,6 +39,7 @@ def use_single_instance_mode():
3639

3740
IDENTITY_DEFs = {}
3841

42+
3943
def date_now_z():
4044
"""get the current date (UTC)
4145
:return: current datetime for utc
@@ -48,6 +52,7 @@ def date_now_z():
4852
.replace("+00:00", "Z")
4953
)
5054

55+
5156
def validate_input(helper, definition):
5257
"""Implement your own validation logic to validate the input stanza configurations"""
5358
# This example accesses the modular input variable
@@ -56,13 +61,19 @@ def validate_input(helper, definition):
5661

5762

5863
def exist_in_kvstore(kv_store, key_id):
64+
"""
65+
:param kv_store:
66+
:param key_id:
67+
:return:
68+
"""
5969
try:
6070
kv_store.query_by_id(key_id)
6171
exist = True
6272
except:
6373
exist = False
6474
return exist
6575

76+
6677
def sanitize_key(key):
6778
"""Sanitize key name for Splunk usage
6879
@@ -78,7 +89,12 @@ def sanitize_key(key):
7889
"""
7990
return key.replace(".", ":").replace("'", "")
8091

92+
8193
def parse_stix_pattern(stix_pattern):
94+
"""
95+
:param stix_pattern:
96+
:return:
97+
"""
8298
parsed_pattern = Pattern(stix_pattern)
8399
for observable_type, comparisons in six.iteritems(
84100
parsed_pattern.inspect().comparisons
@@ -93,9 +109,14 @@ def parse_stix_pattern(stix_pattern):
93109
"value": obj_value.strip("'")
94110
}
95111

96-
def enrich_payload(splunk_helper, payload):
97112

98-
# add stream id and input name #TODO: check if it's usefull
113+
def enrich_payload(splunk_helper, payload):
114+
"""
115+
:param splunk_helper:
116+
:param payload:
117+
:return:
118+
"""
119+
# add stream id and input name #TODO: check if it's useful
99120
payload["stream_id"] = splunk_helper.get_arg('stream_id')
100121
payload["input_name"] = splunk_helper.get_input_stanza_names()
101122

@@ -244,12 +265,14 @@ def collect_events(helper, ew):
244265
raise Exception("Unable to initialize connection with Splunk, Splunk client is None")
245266

246267
# manage kvstore
268+
"""
247269
indicators_kvstore = "opencti_indicators"
248270
try:
249271
# Create KV Store if it doesn't exist
250272
splunk.kvstore.create(indicators_kvstore)
251273
except Exception as ex:
252274
helper.log_info(f"An exception occurred while creating kv_store, {ex}")
275+
"""
253276

254277
# get proxy setting configuration
255278
proxies = get_proxy_config(helper)
@@ -263,15 +286,15 @@ def collect_events(helper, ew):
263286
helper.log_info(f"going to fetch data of OpenCTI stream.id: {stream_id}")
264287

265288
# load kvstore
266-
kv_store = splunk.kvstore[indicators_kvstore].data
289+
kv_store = splunk.kvstore[INDICATORS_KVSTORE_NAME].data
267290

268291
# get stream state
269292
state = helper.get_check_point(input_name)
270293
helper.log_info(f"checkpoint State: {state}")
271294
if state is None:
272295
helper.log_info("No state, going to initialize it")
273296
import_from = helper.get_arg('import_from')
274-
recover_until = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
297+
recover_until = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
275298
start_date = datetime.utcnow() - timedelta(days=int(import_from))
276299
start_date_timestamp = int(datetime.timestamp(start_date)) * 1000
277300
state = {"start_from": str(start_date_timestamp)+"-0", "recover_until": recover_until}
@@ -281,7 +304,7 @@ def collect_events(helper, ew):
281304
helper.log_info(f"State: {state}")
282305

283306
if "recover_until" in state:
284-
live_stream_url = opencti_url+"/stream/"+stream_id+ "?recover=" + state.get("recover_until")
307+
live_stream_url = opencti_url+"/stream/"+stream_id + "?recover=" + state.get("recover_until")
285308
else:
286309
live_stream_url = opencti_url+"/stream/"+stream_id
287310

@@ -296,7 +319,7 @@ def collect_events(helper, ew):
296319
"no-dependencies": "true",
297320
"with-inferences": "true",
298321
},
299-
verify=True,
322+
verify=VERIFY_SSL,
300323
proxies=proxies
301324
)
302325

@@ -308,7 +331,8 @@ def collect_events(helper, ew):
308331
if parsed_stix is None:
309332
helper.log_error(f"Unable to process indicator: {data['name']} - {data['pattern']}")
310333
continue
311-
helper.log_info("processing msg: "+ msg.event +" - "+ msg.id +" - "+parsed_stix['name']+" - "+parsed_stix['pattern'])
334+
helper.log_info("processing msg: " + msg.event + " - " + msg.id + " - " + parsed_stix['name']
335+
+ " - " + parsed_stix['pattern'])
312336
if msg.event == "create" or msg.event == "update":
313337
exist = exist_in_kvstore(kv_store, parsed_stix["_key"])
314338
if exist:
@@ -322,13 +346,15 @@ def collect_events(helper, ew):
322346
kv_store.delete_by_id(parsed_stix["_key"])
323347

324348
if data['type'] == "marking-definition":
325-
helper.log_info("processing msg: "+ msg.event +" - "+ msg.id +" - "+data['name']+" - "+data['id'])
349+
helper.log_info("processing msg: " + msg.event + " - " + msg.id +" - "
350+
+ data['name'] + " - " + data['id'])
326351
if msg.event == "create" or msg.event == "update":
327352
if data['id'] not in MARKING_DEFs:
328353
MARKING_DEFs[data['id']] = data['name']
329354

330355
if data['type'] == "identity":
331-
helper.log_info("processing msg: "+ msg.event +" - "+ msg.id +" - "+data['name']+" - "+data['id'])
356+
helper.log_info("processing msg: " + msg.event + " - " + msg.id + " - "
357+
+ data['name'] + " - " + data['id'])
332358
if msg.event == "create" or msg.event == "update":
333359
if data['id'] not in IDENTITY_DEFs:
334360
IDENTITY_DEFs[data['id']] = data['name']

TA-opencti-add-on/bin/ta_opencti_add_on/aob_py3/splunk_sdk-1.6.18.dist-info/INSTALLER

Lines changed: 0 additions & 1 deletion
This file was deleted.

TA-opencti-add-on/bin/ta_opencti_add_on/aob_py3/splunk_sdk-1.6.18.dist-info/METADATA

Lines changed: 0 additions & 20 deletions
This file was deleted.

TA-opencti-add-on/bin/ta_opencti_add_on/aob_py3/splunk_sdk-1.6.18.dist-info/RECORD

Lines changed: 0 additions & 33 deletions
This file was deleted.

TA-opencti-add-on/bin/ta_opencti_add_on/aob_py3/splunk_sdk-1.6.18.dist-info/REQUESTED

Whitespace-only changes.

TA-opencti-add-on/bin/ta_opencti_add_on/aob_py3/splunk_sdk-1.6.18.dist-info/WHEEL

Lines changed: 0 additions & 5 deletions
This file was deleted.

TA-opencti-add-on/bin/ta_opencti_add_on/aob_py3/splunk_sdk-1.6.18.dist-info/top_level.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

TA-opencti-add-on/bin/ta_opencti_add_on/aob_py3/splunklib/__init__.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2011-2015 Splunk, Inc.
1+
# Copyright © 2011-2024 Splunk, Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License"): you may
44
# not use this file except in compliance with the License. You may obtain
@@ -14,7 +14,21 @@
1414

1515
"""Python library for Splunk."""
1616

17-
from __future__ import absolute_import
18-
from splunklib.six.moves import map
19-
__version_info__ = (1, 6, 18)
17+
import logging
18+
19+
DEFAULT_LOG_FORMAT = '%(asctime)s, Level=%(levelname)s, Pid=%(process)s, Logger=%(name)s, File=%(filename)s, ' \
20+
'Line=%(lineno)s, %(message)s'
21+
DEFAULT_DATE_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
22+
23+
24+
# To set the logging level of splunklib
25+
# ex. To enable debug logs, call this method with parameter 'logging.DEBUG'
26+
# default logging level is set to 'WARNING'
27+
def setup_logging(level, log_format=DEFAULT_LOG_FORMAT, date_format=DEFAULT_DATE_FORMAT):
28+
logging.basicConfig(level=level,
29+
format=log_format,
30+
datefmt=date_format)
31+
32+
33+
__version_info__ = (2, 1, 0)
2034
__version__ = ".".join(map(str, __version_info__))

0 commit comments

Comments
 (0)