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

Commit 62128da

Browse files
author
Samuel Hassine
committed
[client] Remove the possibility to not split the bundles
1 parent a524eb9 commit 62128da

File tree

1 file changed

+19
-32
lines changed

1 file changed

+19
-32
lines changed

pycti/connector/opencti_connector_helper.py

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -490,50 +490,37 @@ def send_stix2_bundle(self, bundle, **kwargs) -> list:
490490
:param update: whether to updated data in the database, defaults to False
491491
:type update: bool, optional
492492
:param split: whether to split the stix bundle before processing, defaults to True
493-
:type split: bool, optional
494493
:raises ValueError: if the bundle is empty
495494
:return: list of bundles
496495
:rtype: list
497496
"""
498497
work_id = kwargs.get("work_id", self.work_id)
499498
entities_types = kwargs.get("entities_types", None)
500499
update = kwargs.get("update", False)
501-
split = kwargs.get("split", True)
502500

503501
if entities_types is None:
504502
entities_types = []
505-
if split:
506-
stix2_splitter = OpenCTIStix2Splitter()
507-
bundles = stix2_splitter.split_bundle(bundle)
508-
if len(bundles) == 0:
509-
raise ValueError("Nothing to import")
510-
if work_id is not None:
511-
self.api.work.add_expectations(work_id, len(bundles))
512-
pika_connection = pika.BlockingConnection(
513-
pika.URLParameters(self.config["uri"])
514-
)
515-
channel = pika_connection.channel()
516-
for sequence, bundle in enumerate(bundles, start=1):
517-
self._send_bundle(
518-
channel,
519-
bundle,
520-
work_id=work_id,
521-
entities_types=entities_types,
522-
sequence=sequence,
523-
update=update,
524-
)
525-
channel.close()
526-
return bundles
527-
else:
528-
pika_connection = pika.BlockingConnection(
529-
pika.URLParameters(self.config["uri"])
530-
)
531-
channel = pika_connection.channel()
503+
stix2_splitter = OpenCTIStix2Splitter()
504+
bundles = stix2_splitter.split_bundle(bundle)
505+
if len(bundles) == 0:
506+
raise ValueError("Nothing to import")
507+
if work_id is not None:
508+
self.api.work.add_expectations(work_id, len(bundles))
509+
pika_connection = pika.BlockingConnection(
510+
pika.URLParameters(self.config["uri"])
511+
)
512+
channel = pika_connection.channel()
513+
for sequence, bundle in enumerate(bundles, start=1):
532514
self._send_bundle(
533-
channel, bundle, entities_types=entities_types, update=update
515+
channel,
516+
bundle,
517+
work_id=work_id,
518+
entities_types=entities_types,
519+
sequence=sequence,
520+
update=update,
534521
)
535-
channel.close()
536-
return [bundle]
522+
channel.close()
523+
return bundles
537524

538525
def _send_bundle(self, channel, bundle, **kwargs) -> None:
539526
"""send a STIX2 bundle to RabbitMQ to be consumed by workers

0 commit comments

Comments
 (0)