33import json
44import uuid
55
6+ from requests_toolbelt .multipart .encoder import to_list
67from stix2 .canonicalization .Canonicalize import canonicalize
78
89from .indicator .opencti_indicator_properties import (
@@ -48,6 +49,7 @@ def list(self, **kwargs):
4849 :param list customAttributes: (optional) list of attributes keys to return
4950 :param bool getAll: (optional) switch to return all entries (be careful to use this without any other filters)
5051 :param bool withPagination: (optional) switch to use pagination
52+ :param bool toStix: (optional) get in STIX
5153
5254 :return: List of Indicators
5355 :rtype: list
@@ -63,21 +65,26 @@ def list(self, **kwargs):
6365 get_all = kwargs .get ("getAll" , False )
6466 with_pagination = kwargs .get ("withPagination" , False )
6567 with_files = kwargs .get ("withFiles" , False )
68+ to_stix = kwargs .get ("toStix" , False )
6669
6770 self .opencti .app_logger .info (
6871 "Listing Indicators with filters" , {"filters" : json .dumps (filters )}
6972 )
7073 query = (
7174 """
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) {
75+ query Indicators($filters: FilterGroup, $search: String, $first: Int, $after: ID, $orderBy: IndicatorsOrdering, $orderMode: OrderingMode, $toStix: Boolean ) {
76+ indicators(filters: $filters, search: $search, first: $first, after: $after, orderBy: $orderBy, orderMode: $orderMode, toStix: $toStix ) {
7477 edges {
7578 node {
7679 """
7780 + (
78- custom_attributes
79- if custom_attributes is not None
80- else (self .properties_with_files if with_files else self .properties )
81+ "toStix"
82+ if to_stix
83+ else (
84+ custom_attributes
85+ if custom_attributes is not None
86+ else (self .properties_with_files if with_files else self .properties )
87+ )
8188 )
8289 + """
8390 }
@@ -102,6 +109,7 @@ def list(self, **kwargs):
102109 "after" : after ,
103110 "orderBy" : order_by ,
104111 "orderMode" : order_mode ,
112+ "toStix" : to_stix ,
105113 },
106114 )
107115 if get_all :
0 commit comments