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

Commit be81f1a

Browse files
committed
[client] Ensure backward compat for connectors
1 parent 102ade4 commit be81f1a

32 files changed

+63
-71
lines changed

pycti/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = "5.5.2"
2+
__version__ = "5.5.3"
33

44
from .api.opencti_api_client import OpenCTIApiClient
55
from .api.opencti_api_connector import OpenCTIApiConnector

pycti/api/opencti_api_client.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,23 @@ def fetch_opencti_file(self, fetch_uri, binary=False, serialize=False):
362362
return base64.b64encode(r.text).decode("utf-8")
363363
return r.text
364364

365+
def log(self, level, message):
366+
"""log a message with defined log level
367+
:param level: must be a valid logging log level (debug, info, warning, error)
368+
:type level: str
369+
:param message: the message to log
370+
:type message: str
371+
"""
372+
373+
if level == "debug":
374+
LOGGER.debug(message)
375+
elif level == "info":
376+
LOGGER.info(message)
377+
elif level == "warning":
378+
LOGGER.warning(message)
379+
elif level == "error":
380+
LOGGER.error(message)
381+
365382
def health_check(self):
366383
"""submit an example request to the OpenCTI API.
367384

pycti/connector/opencti_connector_helper.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,18 @@ def get_opencti_token(self) -> Optional[Union[bool, int, str]]:
788788
def get_connector(self) -> OpenCTIConnector:
789789
return self.connector
790790

791+
def log_error(self, msg: str) -> None:
792+
LOGGER.error(msg)
793+
794+
def log_info(self, msg: str) -> None:
795+
LOGGER.info(msg)
796+
797+
def log_debug(self, msg: str) -> None:
798+
LOGGER.debug(msg)
799+
800+
def log_warning(self, msg: str) -> None:
801+
LOGGER.warning(msg)
802+
791803
def date_now(self) -> str:
792804
"""get the current date (UTC)
793805
:return: current datetime for utc

pycti/entities/opencti_attack_pattern.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ def list(self, **kwargs):
181181
if get_all:
182182
first = 500
183183

184-
if LOGGER.isEnabledFor(logging.INFO):
185-
LOGGER.info("Listing Attack-Patterns with filters %s.", json.dumps(filters))
184+
LOGGER.info("Listing Attack-Patterns with filters %s.", json.dumps(filters))
186185
query = (
187186
"""
188187
query AttackPatterns($filters: [AttackPatternsFiltering], $search: String, $first: Int, $after: ID, $orderBy: AttackPatternsOrdering, $orderMode: OrderingMode) {

pycti/entities/opencti_campaign.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ def list(self, **kwargs):
163163
if get_all:
164164
first = 500
165165

166-
if LOGGER.isEnabledFor(logging.INFO):
167-
LOGGER.info("Listing Campaigns with filters %s.", json.dumps(filters))
166+
LOGGER.info("Listing Campaigns with filters %s.", json.dumps(filters))
168167
query = (
169168
"""
170169
query Campaigns($filters: [CampaignsFiltering], $search: String, $first: Int, $after: ID, $orderBy: CampaignsOrdering, $orderMode: OrderingMode) {

pycti/entities/opencti_channel.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ def list(self, **kwargs):
161161
if get_all:
162162
first = 100
163163

164-
if LOGGER.isEnabledFor(logging.INFO):
165-
LOGGER.info("Listing Channels with filters %s.", json.dumps(filters))
164+
LOGGER.info("Listing Channels with filters %s.", json.dumps(filters))
166165
query = (
167166
"""
168167
query Channels($filters: [ChannelsFiltering!], $search: String, $first: Int, $after: ID, $orderBy: ChannelsOrdering, $orderMode: OrderingMode) {

pycti/entities/opencti_course_of_action.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,7 @@ def list(self, **kwargs):
164164
if get_all:
165165
first = 500
166166

167-
if LOGGER.isEnabledFor(logging.INFO):
168-
LOGGER.info(
169-
"Listing Course-Of-Actions with filters %s.", json.dumps(filters)
170-
)
167+
LOGGER.info("Listing Course-Of-Actions with filters %s.", json.dumps(filters))
171168
query = (
172169
"""
173170
query CoursesOfAction($filters: [CoursesOfActionFiltering], $search: String, $first: Int, $after: ID, $orderBy: CoursesOfActionOrdering, $orderMode: OrderingMode) {

pycti/entities/opencti_event.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ def list(self, **kwargs):
163163
if get_all:
164164
first = 100
165165

166-
if LOGGER.isEnabledFor(logging.INFO):
167-
LOGGER.info("Listing Events with filters %s", json.dumps(filters))
166+
LOGGER.info("Listing Events with filters %s", json.dumps(filters))
168167
query = (
169168
"""
170169
query Events($filters: [EventsFiltering!], $search: String, $first: Int, $after: ID, $orderBy: EventsOrdering, $orderMode: OrderingMode) {

pycti/entities/opencti_external_reference.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ def list(self, **kwargs):
7777
if get_all:
7878
first = 500
7979

80-
if LOGGER.isEnabledFor(logging.INFO):
81-
LOGGER.info(
82-
"Listing External-Reference with filters %s.", json.dumps(filters)
83-
)
80+
LOGGER.info("Listing External-Reference with filters %s.", json.dumps(filters))
8481
query = (
8582
"""
8683
query ExternalReferences($filters: [ExternalReferencesFiltering], $first: Int, $after: ID, $orderBy: ExternalReferencesOrdering, $orderMode: OrderingMode) {

pycti/entities/opencti_grouping.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ def list(self, **kwargs):
254254
if get_all:
255255
first = 100
256256

257-
if LOGGER.isEnabledFor(logging.INFO):
258-
LOGGER.info("Listing Groupings with filters %s.", json.dumps(filters))
257+
LOGGER.info("Listing Groupings with filters %s.", json.dumps(filters))
259258
query = (
260259
"""
261260
query Groupings($filters: [GroupingsFiltering!], $search: String, $first: Int, $after: ID, $orderBy: GroupingsOrdering, $orderMode: OrderingMode) {

0 commit comments

Comments
 (0)