From 36ec2b8b1b556d0058d72495f0720c1242400ea3 Mon Sep 17 00:00:00 2001 From: OB Date: Sat, 12 Oct 2024 21:33:47 -0700 Subject: [PATCH 1/5] Fix types for parameters that are passed to requests library. Add str type hint for url, token --- pycti/api/opencti_api_client.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pycti/api/opencti_api_client.py b/pycti/api/opencti_api_client.py index ffdc0eb9..6f6d2cbc 100644 --- a/pycti/api/opencti_api_client.py +++ b/pycti/api/opencti_api_client.py @@ -83,13 +83,13 @@ class OpenCTIApiClient: :param log_level: log level for the client :type log_level: str, optional :param ssl_verify: Requiring the requests to verify the TLS certificate at the server. - :type ssl_verify: bool, optional + :type ssl_verify: bool, str, optional :param proxies: :type proxies: dict, optional, The proxy configuration, would have `http` and `https` attributes. Defaults to {} ``` proxies: { - "http: "http://my_proxy:8080" - "https: "http://my_proxy:8080" + "http": "http://my_proxy:8080" + "https": "http://my_proxy:8080" } ``` :param json_logging: format the logs as json if set to True @@ -102,14 +102,14 @@ class OpenCTIApiClient: def __init__( self, - url, - token, + url: str, + token: str, log_level="info", - ssl_verify=False, - proxies=None, + ssl_verify: bool | str = False, + proxies: dict[str,str] | None = None, json_logging=False, bundle_send_to_queue=True, - cert=None, + cert: str | tuple[str, str] |None = None, auth=None, perform_health_check=True, ): From 479004643a9e150f78da13b6c3616ceaced541af Mon Sep 17 00:00:00 2001 From: OB Date: Sat, 12 Oct 2024 21:44:27 -0700 Subject: [PATCH 2/5] Lint --- pycti/api/opencti_api_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycti/api/opencti_api_client.py b/pycti/api/opencti_api_client.py index 6f6d2cbc..1eddf2c3 100644 --- a/pycti/api/opencti_api_client.py +++ b/pycti/api/opencti_api_client.py @@ -109,7 +109,7 @@ def __init__( proxies: dict[str,str] | None = None, json_logging=False, bundle_send_to_queue=True, - cert: str | tuple[str, str] |None = None, + cert: str | tuple[str, str] | None = None, auth=None, perform_health_check=True, ): From 33aa1945784e58fac11b8969e63c16cc6cc5d209 Mon Sep 17 00:00:00 2001 From: OB Date: Mon, 14 Oct 2024 22:16:10 -0700 Subject: [PATCH 3/5] lint --- pycti/api/opencti_api_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pycti/api/opencti_api_client.py b/pycti/api/opencti_api_client.py index 1eddf2c3..fffe260a 100644 --- a/pycti/api/opencti_api_client.py +++ b/pycti/api/opencti_api_client.py @@ -105,11 +105,11 @@ def __init__( url: str, token: str, log_level="info", - ssl_verify: bool | str = False, - proxies: dict[str,str] | None = None, + ssl_verify: Union[bool, str] = False, + proxies: Union[dict[str, str], None] = None, json_logging=False, bundle_send_to_queue=True, - cert: str | tuple[str, str] | None = None, + cert: Union[str, tuple[str, str], None] = None, auth=None, perform_health_check=True, ): From 187142af3b5eef88503e354fb0118e970e32f7d5 Mon Sep 17 00:00:00 2001 From: OB Date: Mon, 14 Oct 2024 22:21:10 -0700 Subject: [PATCH 4/5] fix ci --- pycti/api/opencti_api_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pycti/api/opencti_api_client.py b/pycti/api/opencti_api_client.py index fffe260a..01d2df9b 100644 --- a/pycti/api/opencti_api_client.py +++ b/pycti/api/opencti_api_client.py @@ -3,7 +3,7 @@ import datetime import io import json -from typing import Union +from typing import Union, Dict, Tuple import magic import requests @@ -106,10 +106,10 @@ def __init__( token: str, log_level="info", ssl_verify: Union[bool, str] = False, - proxies: Union[dict[str, str], None] = None, + proxies: Union[Dict[str, str], None] = None, json_logging=False, bundle_send_to_queue=True, - cert: Union[str, tuple[str, str], None] = None, + cert: Union[str, Tuple[str, str], None] = None, auth=None, perform_health_check=True, ): From cb9c6a182e4b5eef79f30f5d0445f14aeb2b10d1 Mon Sep 17 00:00:00 2001 From: OB Date: Mon, 14 Oct 2024 22:23:15 -0700 Subject: [PATCH 5/5] isort --- pycti/api/opencti_api_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycti/api/opencti_api_client.py b/pycti/api/opencti_api_client.py index 01d2df9b..365e34cb 100644 --- a/pycti/api/opencti_api_client.py +++ b/pycti/api/opencti_api_client.py @@ -3,7 +3,7 @@ import datetime import io import json -from typing import Union, Dict, Tuple +from typing import Dict, Tuple, Union import magic import requests