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

Commit 38110e8

Browse files
authored
[client-python] Add max_marking support to all exports (#opencti/issue/5797)
1 parent c72f2f0 commit 38110e8

File tree

2 files changed

+312
-71
lines changed

2 files changed

+312
-71
lines changed

pycti/entities/opencti_stix_object_or_stix_relationship.py

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import json
2+
3+
14
class StixObjectOrStixRelationship:
25
def __init__(self, opencti):
36
self.opencti = opencti
@@ -329,11 +332,15 @@ def __init__(self, opencti):
329332
}
330333
... on Case {
331334
name
332-
}
335+
}
333336
... on StixCyberObservable {
334337
observable_value
335338
}
336339
... on StixCoreRelationship {
340+
id
341+
standard_id
342+
entity_type
343+
parent_types
337344
createdBy {
338345
... on Identity {
339346
id
@@ -396,6 +403,10 @@ def __init__(self, opencti):
396403
stop_time
397404
}
398405
... on StixSightingRelationship {
406+
id
407+
standard_id
408+
entity_type
409+
parent_types
399410
createdBy {
400411
... on Identity {
401412
id
@@ -476,9 +487,9 @@ def read(self, **kwargs):
476487
)
477488
query = (
478489
"""
479-
query StixObjectOrStixRelationship($id: String!) {
480-
stixObjectOrStixRelationship(id: $id) {
481-
"""
490+
query StixObjectOrStixRelationship($id: String!) {
491+
stixObjectOrStixRelationship(id: $id) {
492+
"""
482493
+ (
483494
custom_attributes
484495
if custom_attributes is not None
@@ -496,3 +507,51 @@ def read(self, **kwargs):
496507
else:
497508
self.opencti.app_logger.error("Missing parameters: id")
498509
return None
510+
511+
def list(self, **kwargs):
512+
filters = kwargs.get("filters", None)
513+
search = kwargs.get("search", None)
514+
first = kwargs.get("first", 100)
515+
after = kwargs.get("after", None)
516+
with_pagination = kwargs.get("with_pagination", False)
517+
custom_attributes = kwargs.get("customAttributes", None)
518+
519+
self.opencti.app_logger.info(
520+
"Listing StixObjectOrStixRelationships with filters",
521+
{"filters": json.dumps(filters)},
522+
)
523+
query = (
524+
"""
525+
query StixObjectOrStixRelationships($filters: FilterGroup, $search: String, $first: Int, $after: ID) {
526+
stixObjectOrStixRelationships(filters: $filters, search: $search, first: $first, after: $after) {
527+
edges {
528+
node {
529+
"""
530+
+ (custom_attributes if custom_attributes is not None else self.properties)
531+
+ """
532+
}
533+
}
534+
pageInfo {
535+
startCursor
536+
endCursor
537+
hasNextPage
538+
hasPreviousPage
539+
globalCount
540+
}
541+
}
542+
}
543+
"""
544+
)
545+
result = self.opencti.query(
546+
query,
547+
{
548+
"filters": filters,
549+
"search": search,
550+
"first": first,
551+
"after": after,
552+
},
553+
)
554+
555+
return self.opencti.process_multiple(
556+
result["data"]["stixObjectOrStixRelationships"], with_pagination
557+
)

0 commit comments

Comments
 (0)