|
5 | 5 |
|
6 | 6 | from stix2.canonicalization.Canonicalize import canonicalize
|
7 | 7 |
|
| 8 | +from pycti.entities import LOGGER |
| 9 | + |
8 | 10 |
|
9 | 11 | class DataComponent:
|
10 | 12 | def __init__(self, opencti):
|
@@ -173,12 +175,9 @@ def list(self, **kwargs):
|
173 | 175 | get_all = kwargs.get("getAll", False)
|
174 | 176 | with_pagination = kwargs.get("withPagination", False)
|
175 | 177 | if get_all:
|
176 |
| - first = 500 |
| 178 | + first = 100 |
177 | 179 |
|
178 |
| - self.opencti.log( |
179 |
| - "info", |
180 |
| - "Listing Data-Components with filters " + json.dumps(filters) + ".", |
181 |
| - ) |
| 180 | + LOGGER.info("Listing Data-Components with filters " + json.dumps(filters) + ".") |
182 | 181 | query = (
|
183 | 182 | """
|
184 | 183 | query DataComponents($filters: [DataComponentsFiltering!], $search: String, $first: Int, $after: ID, $orderBy: DataComponentsOrdering, $orderMode: OrderingMode) {
|
@@ -212,10 +211,31 @@ def list(self, **kwargs):
|
212 | 211 | "orderMode": order_mode,
|
213 | 212 | },
|
214 | 213 | )
|
215 |
| - # TODO: get_all ? |
216 |
| - return self.opencti.process_multiple( |
217 |
| - result["data"]["dataComponents"], with_pagination |
218 |
| - ) |
| 214 | + if get_all: |
| 215 | + final_data = [] |
| 216 | + data = self.opencti.process_multiple(result["data"]["dataComponents"]) |
| 217 | + final_data = final_data + data |
| 218 | + while result["data"]["dataComponents"]["pageInfo"]["hasNextPage"]: |
| 219 | + after = result["data"]["dataComponents"]["pageInfo"]["endCursor"] |
| 220 | + LOGGER.info("Listing Data-Components after " + after) |
| 221 | + result = self.opencti.query( |
| 222 | + query, |
| 223 | + { |
| 224 | + "filters": filters, |
| 225 | + "search": search, |
| 226 | + "first": first, |
| 227 | + "after": after, |
| 228 | + "orderBy": order_by, |
| 229 | + "orderMode": order_mode, |
| 230 | + }, |
| 231 | + ) |
| 232 | + data = self.opencti.process_multiple(result["data"]["dataComponents"]) |
| 233 | + final_data = final_data + data |
| 234 | + return final_data |
| 235 | + else: |
| 236 | + return self.opencti.process_multiple( |
| 237 | + result["data"]["dataComponents"], with_pagination |
| 238 | + ) |
219 | 239 |
|
220 | 240 | """
|
221 | 241 | Read a Data-Component object
|
|
0 commit comments