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

Commit d3e0833

Browse files
author
Samuel Hassine
committed
[client] Change the API
1 parent 3e41805 commit d3e0833

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

pycti/entities/opencti_stix_core_relationship.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ def __init__(self, opencti):
274274
"""
275275

276276
def list(self, **kwargs):
277+
element_id = kwargs.get("elementId", None)
277278
from_id = kwargs.get("fromId", None)
278279
from_types = kwargs.get("fromTypes", None)
279280
to_id = kwargs.get("toId", None)
@@ -305,8 +306,8 @@ def list(self, **kwargs):
305306
)
306307
query = (
307308
"""
308-
query StixCoreRelationships($fromId: String, $fromTypes: [String], $toId: String, $toTypes: [String], $relationship_type: String, $startTimeStart: DateTime, $startTimeStop: DateTime, $stopTimeStart: DateTime, $stopTimeStop: DateTime, $filters: [StixCoreRelationshipsFiltering], $first: Int, $after: ID, $orderBy: StixCoreRelationshipsOrdering, $orderMode: OrderingMode) {
309-
stixCoreRelationships(fromId: $fromId, fromTypes: $fromTypes, toId: $toId, toTypes: $toTypes, relationship_type: $relationship_type, startTimeStart: $startTimeStart, startTimeStop: $startTimeStop, stopTimeStart: $stopTimeStart, stopTimeStop: $stopTimeStop, filters: $filters, first: $first, after: $after, orderBy: $orderBy, orderMode: $orderMode) {
309+
query StixCoreRelationships($elementId: String, $fromId: String, $fromTypes: [String], $toId: String, $toTypes: [String], $relationship_type: String, $startTimeStart: DateTime, $startTimeStop: DateTime, $stopTimeStart: DateTime, $stopTimeStop: DateTime, $filters: [StixCoreRelationshipsFiltering], $first: Int, $after: ID, $orderBy: StixCoreRelationshipsOrdering, $orderMode: OrderingMode) {
310+
stixCoreRelationships(elementId: $elementId, fromId: $fromId, fromTypes: $fromTypes, toId: $toId, toTypes: $toTypes, relationship_type: $relationship_type, startTimeStart: $startTimeStart, startTimeStop: $startTimeStop, stopTimeStart: $stopTimeStart, stopTimeStop: $stopTimeStop, filters: $filters, first: $first, after: $after, orderBy: $orderBy, orderMode: $orderMode) {
310311
edges {
311312
node {
312313
"""
@@ -328,6 +329,7 @@ def list(self, **kwargs):
328329
result = self.opencti.query(
329330
query,
330331
{
332+
"element_id": element_id,
331333
"fromId": from_id,
332334
"fromTypes": from_types,
333335
"toId": to_id,
@@ -352,6 +354,7 @@ def list(self, **kwargs):
352354
Read a stix_core_relationship object
353355
354356
:param id: the id of the stix_core_relationship
357+
:param elementId: the id of the entity of the relation
355358
:param fromId: the id of the source entity of the relation
356359
:param toId: the id of the target entity of the relation
357360
:param relationship_type: the relation type
@@ -364,6 +367,7 @@ def list(self, **kwargs):
364367

365368
def read(self, **kwargs):
366369
id = kwargs.get("id", None)
370+
element_id = kwargs.get("elementId", None)
367371
from_id = kwargs.get("fromId", None)
368372
to_id = kwargs.get("toId", None)
369373
relationship_type = kwargs.get("relationship_type", None)
@@ -395,6 +399,7 @@ def read(self, **kwargs):
395399
)
396400
elif from_id is not None and to_id is not None:
397401
result = self.list(
402+
elementId=element_id,
398403
fromId=from_id,
399404
toId=to_id,
400405
relationship_type=relationship_type,

pycti/entities/opencti_stix_cyber_observable.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,6 @@ def create(self, **kwargs):
712712
elif type == "StixFile":
713713
input_variables["StixFile"] = {
714714
"hashes": hashes if len(hashes) > 0 else None,
715-
"extensions": observable_data["extensions"]
716-
if "extensions" in observable_data
717-
else None,
718715
"size": observable_data["size"]
719716
if "size" in observable_data
720717
else None,
@@ -814,9 +811,6 @@ def create(self, **kwargs):
814811
}
815812
elif type == "Network-Traffic":
816813
input_variables["NetworkTraffic"] = {
817-
"extensions": observable_data["extensions"]
818-
if "extensions" in observable_data
819-
else None,
820814
"start": observable_data["start"]
821815
if "start" in observable_data
822816
else None,
@@ -848,9 +842,6 @@ def create(self, **kwargs):
848842
}
849843
elif type == "Process":
850844
input_variables["Process"] = {
851-
"extensions": observable_data["extensions"]
852-
if "extensions" in observable_data
853-
else None,
854845
"is_hidden": observable_data["is_hidden"]
855846
if "is_hidden" in observable_data
856847
else None,
@@ -893,9 +884,6 @@ def create(self, **kwargs):
893884
}
894885
elif type == "User-Account":
895886
input_variables["UserAccount"] = {
896-
"extensions": observable_data["extensions"]
897-
if "extensions" in observable_data
898-
else None,
899887
"user_id": observable_data["user_id"]
900888
if "user_id" in observable_data
901889
else None,

pycti/utils/opencti_stix2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ def prepare_export(
11281128
uuids.append(x["id"])
11291129
# Get extra relations (from)
11301130
stix_core_relationships = self.opencti.stix_core_relationship.list(
1131-
fromId=entity["x_opencti_id"]
1131+
elementId=entity["x_opencti_id"]
11321132
)
11331133
for stix_core_relationship in stix_core_relationships:
11341134
if self.check_max_marking_definition(
@@ -1163,7 +1163,7 @@ def prepare_export(
11631163
)
11641164
# Get sighting
11651165
stix_sighting_relationships = self.opencti.stix_sighting_relationship.list(
1166-
fromId=entity["x_opencti_id"]
1166+
elementId=entity["x_opencti_id"]
11671167
)
11681168
for stix_sighting_relationship in stix_sighting_relationships:
11691169
if self.check_max_marking_definition(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from setuptools import setup
66
from setuptools.command.install import install
77

8-
VERSION = "4.1.2"
8+
VERSION = "4.2.0"
99

1010
with open("README.md", "r") as fh:
1111
long_description = fh.read()

0 commit comments

Comments
 (0)