Skip to content

Commit a6f6802

Browse files
committed
Merge branch 'master' into release/current
2 parents 95e9901 + 021ac23 commit a6f6802

File tree

8 files changed

+64
-7
lines changed

8 files changed

+64
-7
lines changed

pycti/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = "6.7.15"
2+
__version__ = "6.7.17"
33

44
from .api.opencti_api_client import OpenCTIApiClient
55
from .api.opencti_api_connector import OpenCTIApiConnector

pycti/entities/opencti_case_rfi.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ def create(self, **kwargs):
701701
created = kwargs.get("created", None)
702702
modified = kwargs.get("modified", None)
703703
name = kwargs.get("name", None)
704+
content = kwargs.get("content", None)
704705
description = kwargs.get("description", None)
705706
x_opencti_stix_ids = kwargs.get("x_opencti_stix_ids", None)
706707
granted_refs = kwargs.get("objectOrganization", None)
@@ -742,6 +743,7 @@ def create(self, **kwargs):
742743
"modified": modified,
743744
"name": name,
744745
"description": description,
746+
"content": content,
745747
"x_opencti_stix_ids": x_opencti_stix_ids,
746748
"x_opencti_workflow_id": x_opencti_workflow_id,
747749
"update": update,
@@ -874,6 +876,13 @@ def import_from_stix2(self, **kwargs):
874876
stix_object["x_opencti_assignee_ids"] = (
875877
self.opencti.get_attribute_in_extension("assignee_ids", stix_object)
876878
)
879+
if "x_opencti_content" not in stix_object or "content" not in stix_object:
880+
stix_object["content"] = self.opencti.get_attribute_in_extension(
881+
"content", stix_object
882+
)
883+
if "x_opencti_content" in stix_object:
884+
stix_object["content"] = stix_object["x_opencti_content"]
885+
877886
if "x_opencti_participant_ids" not in stix_object:
878887
stix_object["x_opencti_participant_ids"] = (
879888
self.opencti.get_attribute_in_extension(
@@ -900,6 +909,11 @@ def import_from_stix2(self, **kwargs):
900909
if "external_references_ids" in extras
901910
else None
902911
),
912+
content=(
913+
self.opencti.stix2.convert_markdown(stix_object["content"])
914+
if "content" in stix_object
915+
else None
916+
),
903917
revoked=stix_object["revoked"] if "revoked" in stix_object else None,
904918
severity=stix_object["severity"] if "severity" in stix_object else None,
905919
priority=stix_object["priority"] if "priority" in stix_object else None,

pycti/entities/opencti_case_rft.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,7 @@ def create(self, **kwargs):
697697
priority = kwargs.get("priority", None)
698698
confidence = kwargs.get("confidence", None)
699699
lang = kwargs.get("lang", None)
700+
content = kwargs.get("content", None)
700701
created = kwargs.get("created", None)
701702
modified = kwargs.get("modified", None)
702703
name = kwargs.get("name", None)
@@ -735,6 +736,7 @@ def create(self, **kwargs):
735736
"revoked": revoked,
736737
"severity": severity,
737738
"priority": priority,
739+
"content": content,
738740
"confidence": confidence,
739741
"lang": lang,
740742
"created": created,
@@ -865,6 +867,13 @@ def import_from_stix2(self, **kwargs):
865867
stix_object["x_opencti_granted_refs"] = (
866868
self.opencti.get_attribute_in_extension("granted_refs", stix_object)
867869
)
870+
if "x_opencti_content" not in stix_object or "content" not in stix_object:
871+
stix_object["content"] = self.opencti.get_attribute_in_extension(
872+
"content", stix_object
873+
)
874+
if "x_opencti_content" in stix_object:
875+
stix_object["content"] = stix_object["x_opencti_content"]
876+
868877
if "x_opencti_workflow_id" not in stix_object:
869878
stix_object["x_opencti_workflow_id"] = (
870879
self.opencti.get_attribute_in_extension("workflow_id", stix_object)
@@ -904,6 +913,11 @@ def import_from_stix2(self, **kwargs):
904913
confidence=(
905914
stix_object["confidence"] if "confidence" in stix_object else None
906915
),
916+
content=(
917+
self.opencti.stix2.convert_markdown(stix_object["content"])
918+
if "content" in stix_object
919+
else None
920+
),
907921
lang=stix_object["lang"] if "lang" in stix_object else None,
908922
created=stix_object["created"] if "created" in stix_object else None,
909923
modified=stix_object["modified"] if "modified" in stix_object else None,

pycti/entities/opencti_external_reference.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,13 @@ def add_file(self, **kwargs):
276276
file_markings = kwargs.get("fileMarkings", None)
277277
mime_type = kwargs.get("mime_type", "text/plain")
278278
no_trigger_import = kwargs.get("no_trigger_import", False)
279+
embedded = kwargs.get("embedded", False)
279280
if id is not None and file_name is not None:
280281
final_file_name = os.path.basename(file_name)
281282
query = """
282-
mutation ExternalReferenceEdit($id: ID!, $file: Upload!, $fileMarkings: [String], $version: DateTime, $noTriggerImport: Boolean) {
283+
mutation ExternalReferenceEdit($id: ID!, $file: Upload!, $fileMarkings: [String], $version: DateTime, $noTriggerImport: Boolean, $embedded: Boolean) {
283284
externalReferenceEdit(id: $id) {
284-
importPush(file: $file, fileMarkings: $fileMarkings, version: $version, noTriggerImport: $noTriggerImport) {
285+
importPush(file: $file, fileMarkings: $fileMarkings, version: $version, noTriggerImport: $noTriggerImport, embedded: $embedded) {
285286
id
286287
name
287288
}
@@ -310,6 +311,7 @@ def add_file(self, **kwargs):
310311
if isinstance(no_trigger_import, bool)
311312
else no_trigger_import == "True"
312313
),
314+
"embedded": embedded,
313315
},
314316
)
315317
else:

pycti/entities/opencti_grouping.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ def create(self, **kwargs):
644644
modified = kwargs.get("modified", None)
645645
name = kwargs.get("name", None)
646646
context = kwargs.get("context", None)
647+
content = kwargs.get("content", None)
647648
description = kwargs.get("description", None)
648649
x_opencti_aliases = kwargs.get("x_opencti_aliases", None)
649650
x_opencti_stix_ids = kwargs.get("x_opencti_stix_ids", None)
@@ -681,6 +682,7 @@ def create(self, **kwargs):
681682
"modified": modified,
682683
"name": name,
683684
"context": context,
685+
"content": content,
684686
"description": description,
685687
"x_opencti_aliases": x_opencti_aliases,
686688
"x_opencti_stix_ids": x_opencti_stix_ids,
@@ -802,6 +804,13 @@ def import_from_stix2(self, **kwargs):
802804
stix_object["x_opencti_granted_refs"] = (
803805
self.opencti.get_attribute_in_extension("granted_refs", stix_object)
804806
)
807+
if "x_opencti_content" not in stix_object or "content" not in stix_object:
808+
stix_object["content"] = self.opencti.get_attribute_in_extension(
809+
"content", stix_object
810+
)
811+
if "x_opencti_content" in stix_object:
812+
stix_object["content"] = stix_object["x_opencti_content"]
813+
805814
if "x_opencti_workflow_id" not in stix_object:
806815
stix_object["x_opencti_workflow_id"] = (
807816
self.opencti.get_attribute_in_extension("workflow_id", stix_object)
@@ -826,6 +835,11 @@ def import_from_stix2(self, **kwargs):
826835
if "external_references_ids" in extras
827836
else None
828837
),
838+
content=(
839+
self.opencti.stix2.convert_markdown(stix_object["content"])
840+
if "content" in stix_object
841+
else None
842+
),
829843
revoked=stix_object["revoked"] if "revoked" in stix_object else None,
830844
confidence=(
831845
stix_object["confidence"] if "confidence" in stix_object else None

pycti/entities/opencti_stix_cyber_observable.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,13 @@ def add_file(self, **kwargs):
185185
version = kwargs.get("version", None)
186186
mime_type = kwargs.get("mime_type", "text/plain")
187187
no_trigger_import = kwargs.get("no_trigger_import", False)
188+
embedded = kwargs.get("embedded", False)
188189
if id is not None and file_name is not None:
189190
final_file_name = os.path.basename(file_name)
190191
query = """
191-
mutation StixCyberObservableEdit($id: ID!, $file: Upload!, $fileMarkings: [String], $version: DateTime, $noTriggerImport: Boolean) {
192+
mutation StixCyberObservableEdit($id: ID!, $file: Upload!, $fileMarkings: [String], $version: DateTime, $noTriggerImport: Boolean, $embedded: Boolean) {
192193
stixCyberObservableEdit(id: $id) {
193-
importPush(file: $file, version: $version, fileMarkings: $fileMarkings, noTriggerImport: $noTriggerImport) {
194+
importPush(file: $file, version: $version, fileMarkings: $fileMarkings, noTriggerImport: $noTriggerImport, embedded: $embedded) {
194195
id
195196
name
196197
}
@@ -219,6 +220,7 @@ def add_file(self, **kwargs):
219220
if isinstance(no_trigger_import, bool)
220221
else no_trigger_import == "True"
221222
),
223+
"embedded": embedded,
222224
},
223225
)
224226
else:

pycti/entities/opencti_stix_domain_object.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,12 +1368,13 @@ def add_file(self, **kwargs):
13681368
version = kwargs.get("version", None)
13691369
mime_type = kwargs.get("mime_type", "text/plain")
13701370
no_trigger_import = kwargs.get("no_trigger_import", False)
1371+
embedded = kwargs.get("embedded", False)
13711372
if id is not None and file_name is not None:
13721373
final_file_name = os.path.basename(file_name)
13731374
query = """
1374-
mutation StixDomainObjectEdit($id: ID!, $file: Upload!, $fileMarkings: [String], $version: DateTime, $noTriggerImport: Boolean) {
1375+
mutation StixDomainObjectEdit($id: ID!, $file: Upload!, $fileMarkings: [String], $version: DateTime, $noTriggerImport: Boolean, $embedded: Boolean) {
13751376
stixDomainObjectEdit(id: $id) {
1376-
importPush(file: $file, version: $version, fileMarkings: $fileMarkings, noTriggerImport: $noTriggerImport) {
1377+
importPush(file: $file, version: $version, fileMarkings: $fileMarkings, noTriggerImport: $noTriggerImport, embedded: $embedded) {
13771378
id
13781379
name
13791380
}
@@ -1402,6 +1403,7 @@ def add_file(self, **kwargs):
14021403
if isinstance(no_trigger_import, bool)
14031404
else no_trigger_import == "True"
14041405
),
1406+
"embedded": embedded,
14051407
},
14061408
)
14071409
else:

pycti/utils/opencti_stix2.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ def extract_embedded_relationships(
758758
fileMarkings=file.get("object_marking_refs", None),
759759
mime_type=file["mime_type"],
760760
no_trigger_import=file.get("no_trigger_import", False),
761+
embedded=file.get("embedded", False),
761762
)
762763
if (
763764
self.opencti.get_attribute_in_extension("files", external_reference)
@@ -775,6 +776,7 @@ def extract_embedded_relationships(
775776
fileMarkings=file.get("object_marking_refs", None),
776777
mime_type=file["mime_type"],
777778
no_trigger_import=file.get("no_trigger_import", False),
779+
embedded=file.get("embedded", False),
778780
)
779781
external_references_ids.append(external_reference_id)
780782
# Granted refs
@@ -1042,6 +1044,7 @@ def import_object(
10421044
if "x_opencti_files" in stix_object:
10431045
for file in stix_object["x_opencti_files"]:
10441046
if "data" in file:
1047+
print(file)
10451048
self.opencti.stix_domain_object.add_file(
10461049
id=stix_object_result["id"],
10471050
file_name=file["name"],
@@ -1050,6 +1053,7 @@ def import_object(
10501053
fileMarkings=file.get("object_marking_refs", None),
10511054
mime_type=file["mime_type"],
10521055
no_trigger_import=file.get("no_trigger_import", False),
1056+
embedded=file.get("embedded", False),
10531057
)
10541058
if (
10551059
self.opencti.get_attribute_in_extension("files", stix_object)
@@ -1059,6 +1063,7 @@ def import_object(
10591063
"files", stix_object
10601064
):
10611065
if "data" in file:
1066+
print(file)
10621067
self.opencti.stix_domain_object.add_file(
10631068
id=stix_object_result["id"],
10641069
file_name=file["name"],
@@ -1067,6 +1072,7 @@ def import_object(
10671072
fileMarkings=file.get("object_marking_refs", None),
10681073
mime_type=file["mime_type"],
10691074
no_trigger_import=file.get("no_trigger_import", False),
1075+
embedded=file.get("embedded", False),
10701076
)
10711077
return stix_object_results
10721078

@@ -1179,6 +1185,7 @@ def import_observable(
11791185
fileMarkings=file.get("object_marking_refs", None),
11801186
mime_type=file["mime_type"],
11811187
no_trigger_import=file.get("no_trigger_import", False),
1188+
embedded=file.get("embedded", False),
11821189
)
11831190
if (
11841191
self.opencti.get_attribute_in_extension("files", stix_object)
@@ -1196,6 +1203,7 @@ def import_observable(
11961203
fileMarkings=file.get("object_marking_refs", None),
11971204
mime_type=file["mime_type"],
11981205
no_trigger_import=file.get("no_trigger_import", False),
1206+
embedded=file.get("embedded", False),
11991207
)
12001208
if "id" in stix_object:
12011209
self.mapping_cache[stix_object["id"]] = {
@@ -2472,6 +2480,7 @@ def apply_patch_files(self, item):
24722480
fileMarkings=file.get("object_marking_refs", None),
24732481
mime_type=file.get("mime_type", None),
24742482
no_trigger_import=file.get("no_trigger_import", False),
2483+
embedded=file.get("embedded", False),
24752484
)
24762485

24772486
def apply_patch(self, item):

0 commit comments

Comments
 (0)