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

Commit 412c266

Browse files
committed
Merge branch 'master' into release/current
2 parents 826d85f + dd77813 commit 412c266

File tree

6 files changed

+29
-23
lines changed

6 files changed

+29
-23
lines changed

.drone.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ steps:
5757

5858
services:
5959
- name: redis
60-
image: redis:7.4.2
60+
image: redis:7.4.3
6161
- name: elastic
62-
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.0
62+
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.1
6363
environment:
6464
discovery.type: single-node
6565
xpack.security.enabled: false
@@ -71,7 +71,7 @@ services:
7171
MINIO_ROOT_PASSWORD: ChangeMe
7272
command: [ server, /data ]
7373
- name: rabbitmq
74-
image: rabbitmq:4.0-management
74+
image: rabbitmq:4.1-management
7575
- name: opencti
7676
image: nikolaik/python-nodejs:python3.10-nodejs18-alpine
7777
environment:

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
autoapi==2.0.1
22
sphinx==8.2.3
3-
sphinx-autodoc-typehints==3.1.0
3+
sphinx-autodoc-typehints==3.2.0
44
sphinx_rtd_theme==3.0.2

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__ = "6.6.12"
2+
__version__ = "6.6.13"
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: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,15 @@ def set_retry_number(self, retry_number):
266266
"" if retry_number is None else str(retry_number)
267267
)
268268

269-
def query(self, query, variables=None):
269+
def query(self, query, variables=None, disable_impersonate=False):
270270
"""submit a query to the OpenCTI GraphQL API
271271
272272
:param query: GraphQL query string
273273
:type query: str
274274
:param variables: GraphQL query variables, defaults to {}
275275
:type variables: dict, optional
276+
:param disable_impersonate: removes impersonate header if set to True, defaults to False
277+
:type disable_impersonate: bool, optional
276278
:return: returns the response json content
277279
:rtype: Any
278280
"""
@@ -297,6 +299,9 @@ def query(self, query, variables=None):
297299
else:
298300
query_var[key] = val
299301

302+
query_headers = self.request_headers.copy()
303+
if disable_impersonate and "opencti-applicant-id" in query_headers:
304+
del query_headers["opencti-applicant-id"]
300305
# If yes, transform variable (file to null) and create multipart query
301306
if len(files_vars) > 0:
302307
multipart_data = {
@@ -363,7 +368,7 @@ def query(self, query, variables=None):
363368
self.api_url,
364369
data=multipart_data,
365370
files=multipart_files,
366-
headers=self.request_headers,
371+
headers=query_headers,
367372
verify=self.ssl_verify,
368373
cert=self.cert,
369374
proxies=self.proxies,
@@ -374,7 +379,7 @@ def query(self, query, variables=None):
374379
r = self.session.post(
375380
self.api_url,
376381
json={"query": query, "variables": variables},
377-
headers=self.request_headers,
382+
headers=query_headers,
378383
verify=self.ssl_verify,
379384
cert=self.cert,
380385
proxies=self.proxies,

pycti/api/opencti_api_work.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def to_received(self, work_id: str, message: str):
2020
}
2121
}
2222
"""
23-
self.api.query(query, {"id": work_id, "message": message})
23+
self.api.query(query, {"id": work_id, "message": message}, True)
2424

2525
def to_processed(self, work_id: str, message: str, in_error: bool = False):
2626
if self.api.bundle_send_to_queue:
@@ -35,7 +35,7 @@ def to_processed(self, work_id: str, message: str, in_error: bool = False):
3535
}
3636
"""
3737
self.api.query(
38-
query, {"id": work_id, "message": message, "inError": in_error}
38+
query, {"id": work_id, "message": message, "inError": in_error}, True
3939
)
4040

4141
def ping(self, work_id: str):
@@ -60,7 +60,7 @@ def report_expectation(self, work_id: str, error):
6060
}
6161
"""
6262
try:
63-
self.api.query(query, {"id": work_id, "error": error})
63+
self.api.query(query, {"id": work_id, "error": error}, True)
6464
except:
6565
self.api.app_logger.error("Cannot report expectation")
6666

@@ -78,7 +78,9 @@ def add_expectations(self, work_id: str, expectations: int):
7878
}
7979
"""
8080
try:
81-
self.api.query(query, {"id": work_id, "expectations": expectations})
81+
self.api.query(
82+
query, {"id": work_id, "expectations": expectations}, True
83+
)
8284
except:
8385
self.api.app_logger.error("Cannot report expectation")
8486

@@ -96,7 +98,9 @@ def add_draft_context(self, work_id: str, draft_context: str):
9698
}
9799
"""
98100
try:
99-
self.api.query(query, {"id": work_id, "draftContext": draft_context})
101+
self.api.query(
102+
query, {"id": work_id, "draftContext": draft_context}, True
103+
)
100104
except:
101105
self.api.app_logger.error("Cannot report draft context")
102106

@@ -111,7 +115,9 @@ def initiate_work(self, connector_id: str, friendly_name: str) -> str:
111115
}
112116
"""
113117
work = self.api.query(
114-
query, {"connectorId": connector_id, "friendlyName": friendly_name}
118+
query,
119+
{"connectorId": connector_id, "friendlyName": friendly_name},
120+
True,
115121
)
116122
return work["data"]["workAdd"]["id"]
117123

@@ -122,10 +128,7 @@ def delete_work(self, work_id: str):
122128
delete
123129
}
124130
}"""
125-
work = self.api.query(
126-
query,
127-
{"workId": work_id},
128-
)
131+
work = self.api.query(query, {"workId": work_id}, True)
129132
return work["data"]
130133

131134
def wait_for_work_to_finish(self, work_id: str):
@@ -179,10 +182,7 @@ def get_work(self, work_id: str) -> Dict:
179182
}
180183
}
181184
"""
182-
result = self.api.query(
183-
query,
184-
{"id": work_id},
185-
)
185+
result = self.api.query(query, {"id": work_id}, True)
186186
return result["data"]["work"]
187187

188188
def get_connector_works(self, connector_id: str) -> List[Dict]:
@@ -243,6 +243,7 @@ def get_connector_works(self, connector_id: str) -> List[Dict]:
243243
"filterGroups": [],
244244
},
245245
},
246+
True,
246247
)
247248
result = result["data"]["works"]["edges"]
248249
return_value = []

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ dev =
7070
wheel~=0.45.1
7171
doc =
7272
autoapi~=2.0.1
73-
sphinx-autodoc-typehints~=3.1.0
73+
sphinx-autodoc-typehints~=3.2.0
7474
sphinx-rtd-theme~=3.0.2

0 commit comments

Comments
 (0)