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

Commit 5fea4bd

Browse files
committed
[client] Fix formatting
1 parent 8ff0ed0 commit 5fea4bd

Some content is hidden

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

46 files changed

+204
-203
lines changed

pycti/connector/opencti_connector_helper.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@
3838

3939
def killProgramHook(etype, value, tb):
4040
"""Exception hook to terminate the program.
41-
41+
4242
:param etype: Exception type
43-
:param value: Exception value
43+
:param value: Exception value
4444
:param tb: Traceback object
4545
"""
4646
os.kill(os.getpid(), signal.SIGTERM)
4747

4848

4949
def start_loop(loop):
5050
"""Start an asyncio event loop.
51-
51+
5252
:param loop: The asyncio event loop to start
5353
:type loop: asyncio.AbstractEventLoop
5454
"""
@@ -105,7 +105,7 @@ def get_config_variable(
105105

106106
def is_memory_certificate(certificate):
107107
"""Check if a certificate is provided as a PEM string in memory.
108-
108+
109109
:param certificate: The certificate data to check
110110
:type certificate: str
111111
:return: True if the certificate is a PEM string, False otherwise
@@ -116,7 +116,7 @@ def is_memory_certificate(certificate):
116116

117117
def ssl_verify_locations(ssl_context, certdata):
118118
"""Load certificate verification locations into SSL context.
119-
119+
120120
:param ssl_context: The SSL context to configure
121121
:type ssl_context: ssl.SSLContext
122122
:param certdata: Certificate data (file path or PEM string)
@@ -133,10 +133,10 @@ def ssl_verify_locations(ssl_context, certdata):
133133

134134
def data_to_temp_file(data):
135135
"""Write data to a temporary file securely.
136-
136+
137137
Creates a temporary file in the most secure manner possible.
138138
The file is readable and writable only by the creating user ID.
139-
139+
140140
:param data: The data to write to the temporary file
141141
:type data: str
142142
:return: Path to the created temporary file
@@ -155,7 +155,7 @@ def data_to_temp_file(data):
155155

156156
def ssl_cert_chain(ssl_context, cert_data, key_data, passphrase):
157157
"""Load certificate chain into SSL context.
158-
158+
159159
:param ssl_context: The SSL context to configure
160160
:type ssl_context: ssl.SSLContext
161161
:param cert_data: Certificate data (file path or PEM string)
@@ -192,7 +192,7 @@ def ssl_cert_chain(ssl_context, cert_data, key_data, passphrase):
192192

193193
def create_callback_ssl_context(config) -> ssl.SSLContext:
194194
"""Create SSL context for API callback server.
195-
195+
196196
:param config: Configuration dictionary
197197
:type config: dict
198198
:return: Configured SSL context
@@ -228,7 +228,7 @@ def create_callback_ssl_context(config) -> ssl.SSLContext:
228228

229229
def create_mq_ssl_context(config) -> ssl.SSLContext:
230230
"""Create SSL context for message queue connections.
231-
231+
232232
:param config: Configuration dictionary
233233
:type config: dict
234234
:return: Configured SSL context for MQ connections
@@ -351,7 +351,7 @@ def _process_message(self, channel, method, properties, body) -> None:
351351

352352
def _set_draft_id(self, draft_id):
353353
"""Set the draft ID for the helper and API instances.
354-
354+
355355
:param draft_id: The draft ID to set
356356
:type draft_id: str
357357
"""
@@ -610,7 +610,7 @@ def run(self) -> None:
610610

611611
def stop(self):
612612
"""Stop the ListenQueue thread and close connections.
613-
613+
614614
This method sets the exit event, closes the RabbitMQ connection,
615615
and waits for the processing thread to complete.
616616
"""
@@ -863,7 +863,7 @@ def run(self) -> None: # pylint: disable=too-many-branches
863863

864864
def stop(self):
865865
"""Stop the ListenStream thread.
866-
866+
867867
This method sets the exit event to signal the stream listening thread to stop.
868868
"""
869869
self.helper.connector_logger.info("Preparing ListenStream for clean shutdown")
@@ -890,7 +890,7 @@ def __init__(
890890
@property
891891
def all_details(self):
892892
"""Get all connector information details as a dictionary.
893-
893+
894894
:return: Dictionary containing all connector status information
895895
:rtype: dict
896896
"""
@@ -910,7 +910,7 @@ def run_and_terminate(self) -> bool:
910910
@run_and_terminate.setter
911911
def run_and_terminate(self, value):
912912
"""Set the run_and_terminate flag.
913-
913+
914914
:param value: Whether the connector should run once and terminate
915915
:type value: bool
916916
"""
@@ -923,7 +923,7 @@ def buffering(self) -> bool:
923923
@buffering.setter
924924
def buffering(self, value):
925925
"""Set the buffering status.
926-
926+
927927
:param value: Whether the connector is currently buffering
928928
:type value: bool
929929
"""
@@ -936,7 +936,7 @@ def queue_threshold(self) -> float:
936936
@queue_threshold.setter
937937
def queue_threshold(self, value):
938938
"""Set the queue threshold value.
939-
939+
940940
:param value: The queue size threshold in MB
941941
:type value: float
942942
"""
@@ -949,7 +949,7 @@ def queue_messages_size(self) -> float:
949949
@queue_messages_size.setter
950950
def queue_messages_size(self, value):
951951
"""Set the current queue messages size.
952-
952+
953953
:param value: The current size of messages in the queue in MB
954954
:type value: float
955955
"""
@@ -962,7 +962,7 @@ def next_run_datetime(self) -> datetime:
962962
@next_run_datetime.setter
963963
def next_run_datetime(self, value):
964964
"""Set the next scheduled run datetime.
965-
965+
966966
:param value: The datetime for the next scheduled run
967967
:type value: datetime
968968
"""
@@ -975,7 +975,7 @@ def last_run_datetime(self) -> datetime:
975975
@last_run_datetime.setter
976976
def last_run_datetime(self, value):
977977
"""Set the last run datetime.
978-
978+
979979
:param value: The datetime of the last run
980980
:type value: datetime
981981
"""
@@ -1352,7 +1352,7 @@ def __init__(self, config: Dict, playbook_compatible=False) -> None:
13521352

13531353
def stop(self) -> None:
13541354
"""Stop the connector and clean up resources.
1355-
1355+
13561356
This method stops all running threads (listen queue, ping thread) and
13571357
unregisters the connector from OpenCTI.
13581358
"""
@@ -1366,15 +1366,15 @@ def stop(self) -> None:
13661366

13671367
def get_name(self) -> Optional[Union[bool, int, str]]:
13681368
"""Get the connector name.
1369-
1369+
13701370
:return: The name of the connector
13711371
:rtype: Optional[Union[bool, int, str]]
13721372
"""
13731373
return self.connect_name
13741374

13751375
def get_stream_collection(self):
13761376
"""Get the stream collection configuration.
1377-
1377+
13781378
:return: Stream collection configuration dictionary
13791379
:rtype: dict
13801380
:raises ValueError: If no stream is connected
@@ -1414,23 +1414,23 @@ def get_stream_collection(self):
14141414

14151415
def get_only_contextual(self) -> Optional[Union[bool, int, str]]:
14161416
"""Get the only_contextual configuration value.
1417-
1417+
14181418
:return: Whether the connector processes only contextual data
14191419
:rtype: Optional[Union[bool, int, str]]
14201420
"""
14211421
return self.connect_only_contextual
14221422

14231423
def get_run_and_terminate(self) -> Optional[Union[bool, int, str]]:
14241424
"""Get the run_and_terminate configuration value.
1425-
1425+
14261426
:return: Whether the connector should run once and terminate
14271427
:rtype: Optional[Union[bool, int, str]]
14281428
"""
14291429
return self.connect_run_and_terminate
14301430

14311431
def get_validate_before_import(self) -> Optional[Union[bool, int, str]]:
14321432
"""Get the validate_before_import configuration value.
1433-
1433+
14341434
:return: Whether to validate data before importing
14351435
:rtype: Optional[Union[bool, int, str]]
14361436
"""
@@ -1465,7 +1465,7 @@ def get_state(self) -> Optional[Dict]:
14651465

14661466
def force_ping(self):
14671467
"""Force a ping to the OpenCTI API to update connector state.
1468-
1468+
14691469
This method manually triggers a ping to synchronize the connector state
14701470
with the OpenCTI platform.
14711471
"""
@@ -1882,23 +1882,23 @@ def listen_stream(
18821882

18831883
def get_opencti_url(self) -> Optional[Union[bool, int, str]]:
18841884
"""Get the OpenCTI URL.
1885-
1885+
18861886
:return: The URL of the OpenCTI platform
18871887
:rtype: Optional[Union[bool, int, str]]
18881888
"""
18891889
return self.opencti_url
18901890

18911891
def get_opencti_token(self) -> Optional[Union[bool, int, str]]:
18921892
"""Get the OpenCTI API token.
1893-
1893+
18941894
:return: The API token for OpenCTI authentication
18951895
:rtype: Optional[Union[bool, int, str]]
18961896
"""
18971897
return self.opencti_token
18981898

18991899
def get_connector(self) -> OpenCTIConnector:
19001900
"""Get the OpenCTIConnector instance.
1901-
1901+
19021902
:return: The OpenCTIConnector instance
19031903
:rtype: OpenCTIConnector
19041904
"""
@@ -2452,7 +2452,7 @@ def get_attribute_in_mitre_extension(key, object) -> any:
24522452

24532453
def get_data_from_enrichment(self, data, standard_id, opencti_entity):
24542454
"""Extract STIX entity and objects from enrichment data.
2455-
2455+
24562456
:param data: The enrichment data containing a bundle
24572457
:type data: dict
24582458
:param standard_id: The STIX standard ID of the entity

pycti/entities/opencti_attack_pattern.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
class AttackPattern:
1010
"""Main AttackPattern class for OpenCTI
11-
11+
1212
:param opencti: instance of :py:class:`~pycti.api.opencti_api_client.OpenCTIApiClient`
1313
"""
14-
14+
1515
def __init__(self, opencti):
1616
self.opencti = opencti
1717
self.properties = """
@@ -244,7 +244,7 @@ def __init__(self, opencti):
244244
@staticmethod
245245
def generate_id(name, x_mitre_id=None):
246246
"""Generate a STIX ID for an Attack Pattern.
247-
247+
248248
:param name: The name of the attack pattern
249249
:type name: str
250250
:param x_mitre_id: Optional MITRE ATT&CK ID
@@ -263,7 +263,7 @@ def generate_id(name, x_mitre_id=None):
263263
@staticmethod
264264
def generate_id_from_data(data):
265265
"""Generate a STIX ID from attack pattern data.
266-
266+
267267
:param data: Dictionary containing 'name' and optionally 'x_mitre_id' keys
268268
:type data: dict
269269
:return: STIX ID for the attack pattern
@@ -274,7 +274,7 @@ def generate_id_from_data(data):
274274

275275
def list(self, **kwargs):
276276
"""List Attack Pattern objects.
277-
277+
278278
:param filters: the filters to apply
279279
:param search: the search keyword
280280
:param first: return the first n rows from the after ID (or the beginning if not set)

pycti/entities/opencti_campaign.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
class Campaign:
1010
"""Main Campaign class for OpenCTI
11-
11+
1212
:param opencti: instance of :py:class:`~pycti.api.opencti_api_client.OpenCTIApiClient`
1313
"""
14-
14+
1515
def __init__(self, opencti):
1616
self.opencti = opencti
1717
self.properties = """
@@ -232,7 +232,7 @@ def __init__(self, opencti):
232232
@staticmethod
233233
def generate_id(name):
234234
"""Generate a STIX ID for a Campaign.
235-
235+
236236
:param name: The name of the campaign
237237
:type name: str
238238
:return: STIX ID for the campaign
@@ -247,7 +247,7 @@ def generate_id(name):
247247
@staticmethod
248248
def generate_id_from_data(data):
249249
"""Generate a STIX ID from campaign data.
250-
250+
251251
:param data: Dictionary containing 'name' key
252252
:type data: dict
253253
:return: STIX ID for the campaign
@@ -257,7 +257,7 @@ def generate_id_from_data(data):
257257

258258
def list(self, **kwargs):
259259
"""List Campaign objects.
260-
260+
261261
:param filters: the filters to apply
262262
:param search: the search keyword
263263
:param first: return the first n rows from the after ID (or the beginning if not set)

pycti/entities/opencti_case_incident.py

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

99
class CaseIncident:
1010
"""Main CaseIncident class for OpenCTI
11-
11+
1212
Manages incident response cases in the OpenCTI platform.
13-
13+
1414
:param opencti: instance of :py:class:`~pycti.api.opencti_api_client.OpenCTIApiClient`
1515
"""
16-
16+
1717
def __init__(self, opencti):
1818
self.opencti = opencti
1919
self.properties = """

pycti/entities/opencti_case_rfi.py

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

99
class CaseRfi:
1010
"""Main CaseRfi (Request for Information) class for OpenCTI
11-
11+
1212
Manages RFI cases in the OpenCTI platform.
13-
13+
1414
:param opencti: instance of :py:class:`~pycti.api.opencti_api_client.OpenCTIApiClient`
1515
"""
16-
16+
1717
def __init__(self, opencti):
1818
self.opencti = opencti
1919
self.properties = """

pycti/entities/opencti_case_rft.py

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

99
class CaseRft:
1010
"""Main CaseRft (Request for Takedown) class for OpenCTI
11-
11+
1212
Manages RFT cases in the OpenCTI platform.
13-
13+
1414
:param opencti: instance of :py:class:`~pycti.api.opencti_api_client.OpenCTIApiClient`
1515
"""
16-
16+
1717
def __init__(self, opencti):
1818
self.opencti = opencti
1919
self.properties = """

0 commit comments

Comments
 (0)