Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit c769f2c

Browse files
author
Samuel Hassine
committed
[connector] Add entities types in the message to the workers
1 parent 29fec30 commit c769f2c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

examples/stix2/import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
config = yaml.load(open(os.path.dirname(__file__) + '/../config.yml'))
1010

1111
# File to import
12-
file_to_import = '/home/oxid/Dropbox/Developpement/Associations/Luatix/Produits/OpenCTI/cti/enterprise-attack/enterprise-attack.json'
12+
file_to_import = './enterprise-attack.json'
1313

1414
# OpenCTI initialization
1515
opencti_api_client = OpenCTIApiClient(config['opencti']['url'], config['opencti']['token'])

pycti/opencti_connector_helper.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,24 @@ def _reconnect(self):
7171
self.connection = self._connect()
7272
self.channel = self._create_channel()
7373

74-
def send_stix2_bundle(self, bundle):
74+
def send_stix2_bundle(self, bundle, entities_types=[]):
7575
"""
7676
This method send a STIX2 bundle to RabbitMQ to be consumed by workers
7777
:param bundle: A valid STIX2 bundle
78+
:param entities_types: Entities types to ingest
7879
"""
7980
if not self.channel.is_open:
8081
self._reconnect()
8182

8283
# Validate the STIX 2 bundle
83-
#validation = validate_string(bundle)
84-
#if not validation.is_valid:
85-
#raise ValueError('The bundle is not a valid STIX2 JSON:' + bundle)
84+
# validation = validate_string(bundle)
85+
# if not validation.is_valid:
86+
# raise ValueError('The bundle is not a valid STIX2 JSON:' + bundle)
8687

8788
# Prepare the message
8889
message = {
8990
'type': 'stix2-bundle',
91+
'entities_types': entities_types,
9092
'content': base64.b64encode(bundle.encode('utf-8')).decode('utf-8')
9193
}
9294

0 commit comments

Comments
 (0)