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

Commit ea941a9

Browse files
committed
[client] Add toStix options for indicators
1 parent 0adc357 commit ea941a9

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

pycti/api/opencti_api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def query(self, query, variables=None):
280280
if is_multiple_files:
281281
# [(var_name + "." + i)] if is_multiple_files else
282282
for _ in file_var_item["file"]:
283-
file_vars[str(map_index)] = [(var_name + "." + str(map_index))]
283+
file_vars[str(map_index)] = [var_name + "." + str(map_index)]
284284
map_index += 1
285285
else:
286286
file_vars[str(map_index)] = [var_name]

pycti/entities/opencti_indicator.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def list(self, **kwargs):
4848
:param list customAttributes: (optional) list of attributes keys to return
4949
:param bool getAll: (optional) switch to return all entries (be careful to use this without any other filters)
5050
:param bool withPagination: (optional) switch to use pagination
51+
:param bool toStix: (optional) get in STIX
5152
5253
:return: List of Indicators
5354
:rtype: list
@@ -63,21 +64,26 @@ def list(self, **kwargs):
6364
get_all = kwargs.get("getAll", False)
6465
with_pagination = kwargs.get("withPagination", False)
6566
with_files = kwargs.get("withFiles", False)
67+
to_stix = kwargs.get("toStix", False)
6668

6769
self.opencti.app_logger.info(
6870
"Listing Indicators with filters", {"filters": json.dumps(filters)}
6971
)
7072
query = (
7173
"""
72-
query Indicators($filters: FilterGroup, $search: String, $first: Int, $after: ID, $orderBy: IndicatorsOrdering, $orderMode: OrderingMode) {
73-
indicators(filters: $filters, search: $search, first: $first, after: $after, orderBy: $orderBy, orderMode: $orderMode) {
74+
query Indicators($filters: FilterGroup, $search: String, $first: Int, $after: ID, $orderBy: IndicatorsOrdering, $orderMode: OrderingMode, $toStix: Boolean) {
75+
indicators(filters: $filters, search: $search, first: $first, after: $after, orderBy: $orderBy, orderMode: $orderMode, toStix: $toStix) {
7476
edges {
7577
node {
7678
"""
7779
+ (
78-
custom_attributes
79-
if custom_attributes is not None
80-
else (self.properties_with_files if with_files else self.properties)
80+
"toStix"
81+
if to_stix
82+
else (
83+
custom_attributes
84+
if custom_attributes is not None
85+
else (self.properties_with_files if with_files else self.properties)
86+
)
8187
)
8288
+ """
8389
}
@@ -102,6 +108,7 @@ def list(self, **kwargs):
102108
"after": after,
103109
"orderBy": order_by,
104110
"orderMode": order_mode,
111+
"toStix": to_stix,
105112
},
106113
)
107114
if get_all:

pycti/utils/constants.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""These are the custom STIX properties and observation types used internally by OpenCTI.
2-
3-
"""
1+
"""These are the custom STIX properties and observation types used internally by OpenCTI."""
42

53
from enum import Enum
64

0 commit comments

Comments
 (0)