pycti 5.12.13__py3-none-any.whl → 5.12.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pycti might be problematic. Click here for more details.
- pycti/__init__.py +1 -1
- pycti/api/__init__.py +0 -3
- pycti/api/opencti_api_client.py +10 -56
- pycti/api/opencti_api_connector.py +1 -2
- pycti/api/opencti_api_playbook.py +3 -4
- pycti/api/opencti_api_work.py +15 -12
- pycti/connector/__init__.py +0 -3
- pycti/connector/opencti_connector_helper.py +63 -54
- pycti/connector/opencti_metric_handler.py +8 -5
- pycti/entities/__init__.py +0 -3
- pycti/entities/opencti_attack_pattern.py +17 -11
- pycti/entities/opencti_campaign.py +15 -9
- pycti/entities/opencti_case_incident.py +39 -43
- pycti/entities/opencti_case_rfi.py +34 -46
- pycti/entities/opencti_case_rft.py +35 -44
- pycti/entities/opencti_channel.py +15 -9
- pycti/entities/opencti_course_of_action.py +15 -9
- pycti/entities/opencti_data_component.py +17 -14
- pycti/entities/opencti_data_source.py +12 -16
- pycti/entities/opencti_event.py +15 -9
- pycti/entities/opencti_external_reference.py +20 -15
- pycti/entities/opencti_feedback.py +36 -46
- pycti/entities/opencti_grouping.py +22 -20
- pycti/entities/opencti_identity.py +15 -8
- pycti/entities/opencti_incident.py +13 -9
- pycti/entities/opencti_indicator.py +18 -15
- pycti/entities/opencti_infrastructure.py +15 -9
- pycti/entities/opencti_intrusion_set.py +12 -8
- pycti/entities/opencti_kill_chain_phase.py +16 -12
- pycti/entities/opencti_label.py +16 -12
- pycti/entities/opencti_language.py +13 -9
- pycti/entities/opencti_location.py +13 -9
- pycti/entities/opencti_malware.py +15 -9
- pycti/entities/opencti_malware_analysis.py +17 -9
- pycti/entities/opencti_marking_definition.py +15 -11
- pycti/entities/opencti_narrative.py +15 -9
- pycti/entities/opencti_note.py +35 -20
- pycti/entities/opencti_observed_data.py +34 -19
- pycti/entities/opencti_opinion.py +37 -20
- pycti/entities/opencti_report.py +36 -20
- pycti/entities/opencti_stix.py +8 -19
- pycti/entities/opencti_stix_core_object.py +15 -9
- pycti/entities/opencti_stix_core_relationship.py +69 -52
- pycti/entities/opencti_stix_cyber_observable.py +78 -62
- pycti/entities/opencti_stix_domain_object.py +75 -55
- pycti/entities/opencti_stix_nested_ref_relationship.py +21 -14
- pycti/entities/opencti_stix_object_or_stix_relationship.py +4 -7
- pycti/entities/opencti_stix_sighting_relationship.py +34 -26
- pycti/entities/opencti_task.py +37 -44
- pycti/entities/opencti_threat_actor.py +7 -4
- pycti/entities/opencti_threat_actor_group.py +10 -8
- pycti/entities/opencti_threat_actor_individual.py +10 -9
- pycti/entities/opencti_tool.py +15 -9
- pycti/entities/opencti_vocabulary.py +11 -13
- pycti/entities/opencti_vulnerability.py +15 -9
- pycti/utils/opencti_logger.py +64 -0
- pycti/utils/opencti_stix2.py +30 -24
- pycti/utils/opencti_stix2_update.py +2 -6
- {pycti-5.12.13.dist-info → pycti-5.12.15.dist-info}/METADATA +1 -1
- pycti-5.12.15.dist-info/RECORD +68 -0
- pycti-5.12.13.dist-info/RECORD +0 -67
- {pycti-5.12.13.dist-info → pycti-5.12.15.dist-info}/LICENSE +0 -0
- {pycti-5.12.13.dist-info → pycti-5.12.15.dist-info}/WHEEL +0 -0
- {pycti-5.12.13.dist-info → pycti-5.12.15.dist-info}/top_level.txt +0 -0
pycti/entities/opencti_report.py
CHANGED
|
@@ -7,8 +7,6 @@ import uuid
|
|
|
7
7
|
from dateutil.parser import parse
|
|
8
8
|
from stix2.canonicalization.Canonicalize import canonicalize
|
|
9
9
|
|
|
10
|
-
from pycti.entities import LOGGER
|
|
11
|
-
|
|
12
10
|
|
|
13
11
|
class Report:
|
|
14
12
|
def __init__(self, opencti):
|
|
@@ -490,7 +488,9 @@ class Report:
|
|
|
490
488
|
if get_all:
|
|
491
489
|
first = 100
|
|
492
490
|
|
|
493
|
-
|
|
491
|
+
self.opencti.app_logger.info(
|
|
492
|
+
"Listing Reports with filters", {"filters": json.dumps(filters)}
|
|
493
|
+
)
|
|
494
494
|
query = (
|
|
495
495
|
"""
|
|
496
496
|
query Reports($filters: FilterGroup, $search: String, $first: Int, $after: ID, $orderBy: ReportsOrdering, $orderMode: OrderingMode) {
|
|
@@ -534,7 +534,7 @@ class Report:
|
|
|
534
534
|
final_data = final_data + data
|
|
535
535
|
while result["data"]["reports"]["pageInfo"]["hasNextPage"]:
|
|
536
536
|
after = result["data"]["reports"]["pageInfo"]["endCursor"]
|
|
537
|
-
|
|
537
|
+
self.opencti.app_logger.info("Listing Reports", {"after": after})
|
|
538
538
|
result = self.opencti.query(
|
|
539
539
|
query,
|
|
540
540
|
{
|
|
@@ -568,7 +568,7 @@ class Report:
|
|
|
568
568
|
custom_attributes = kwargs.get("customAttributes", None)
|
|
569
569
|
with_files = kwargs.get("withFiles", False)
|
|
570
570
|
if id is not None:
|
|
571
|
-
|
|
571
|
+
self.opencti.app_logger.info("Reading Report", {"id": id})
|
|
572
572
|
query = (
|
|
573
573
|
"""
|
|
574
574
|
query Report($id: String!) {
|
|
@@ -639,9 +639,12 @@ class Report:
|
|
|
639
639
|
"stixObjectOrStixRelationshipId", None
|
|
640
640
|
)
|
|
641
641
|
if id is not None and stix_object_or_stix_relationship_id is not None:
|
|
642
|
-
|
|
643
|
-
"Checking StixObjectOrStixRelationship
|
|
644
|
-
|
|
642
|
+
self.opencti.app_logger.info(
|
|
643
|
+
"Checking StixObjectOrStixRelationship in Report",
|
|
644
|
+
{
|
|
645
|
+
"id": id,
|
|
646
|
+
"stixObjectOrStixRelationshipId": stix_object_or_stix_relationship_id,
|
|
647
|
+
},
|
|
645
648
|
)
|
|
646
649
|
query = """
|
|
647
650
|
query ReportContainsStixObjectOrStixRelationship($id: String!, $stixObjectOrStixRelationshipId: String!) {
|
|
@@ -657,7 +660,7 @@ class Report:
|
|
|
657
660
|
)
|
|
658
661
|
return result["data"]["reportContainsStixObjectOrStixRelationship"]
|
|
659
662
|
else:
|
|
660
|
-
|
|
663
|
+
self.opencti.app_logger.error(
|
|
661
664
|
"[opencti_report] Missing parameters: id or stixObjectOrStixRelationshipId",
|
|
662
665
|
)
|
|
663
666
|
|
|
@@ -682,6 +685,7 @@ class Report:
|
|
|
682
685
|
modified = kwargs.get("modified", None)
|
|
683
686
|
name = kwargs.get("name", None)
|
|
684
687
|
description = kwargs.get("description", None)
|
|
688
|
+
content = kwargs.get("content", None)
|
|
685
689
|
report_types = kwargs.get("report_types", None)
|
|
686
690
|
published = kwargs.get("published", None)
|
|
687
691
|
x_opencti_reliability = kwargs.get("x_opencti_reliability", None)
|
|
@@ -690,7 +694,7 @@ class Report:
|
|
|
690
694
|
update = kwargs.get("update", False)
|
|
691
695
|
|
|
692
696
|
if name is not None and published is not None:
|
|
693
|
-
|
|
697
|
+
self.opencti.app_logger.info("Creating Report", {"name": name})
|
|
694
698
|
query = """
|
|
695
699
|
mutation ReportAdd($input: ReportAddInput!) {
|
|
696
700
|
reportAdd(input: $input) {
|
|
@@ -719,6 +723,7 @@ class Report:
|
|
|
719
723
|
"modified": modified,
|
|
720
724
|
"name": name,
|
|
721
725
|
"description": description,
|
|
726
|
+
"content": content,
|
|
722
727
|
"report_types": report_types,
|
|
723
728
|
"published": published,
|
|
724
729
|
"x_opencti_reliability": x_opencti_reliability,
|
|
@@ -729,7 +734,7 @@ class Report:
|
|
|
729
734
|
)
|
|
730
735
|
return self.opencti.process_multiple_fields(result["data"]["reportAdd"])
|
|
731
736
|
else:
|
|
732
|
-
|
|
737
|
+
self.opencti.app_logger.error(
|
|
733
738
|
"[opencti_report] "
|
|
734
739
|
"Missing parameters: name and description and published and report_class"
|
|
735
740
|
)
|
|
@@ -748,9 +753,12 @@ class Report:
|
|
|
748
753
|
"stixObjectOrStixRelationshipId", None
|
|
749
754
|
)
|
|
750
755
|
if id is not None and stix_object_or_stix_relationship_id is not None:
|
|
751
|
-
|
|
752
|
-
"Adding StixObjectOrStixRelationship
|
|
753
|
-
|
|
756
|
+
self.opencti.app_logger.info(
|
|
757
|
+
"Adding StixObjectOrStixRelationship to Report",
|
|
758
|
+
{
|
|
759
|
+
"id": id,
|
|
760
|
+
"stixObjectOrStixRelationshipId": stix_object_or_stix_relationship_id,
|
|
761
|
+
},
|
|
754
762
|
)
|
|
755
763
|
query = """
|
|
756
764
|
mutation ReportEditRelationAdd($id: ID!, $input: StixRefRelationshipAddInput!) {
|
|
@@ -773,7 +781,7 @@ class Report:
|
|
|
773
781
|
)
|
|
774
782
|
return True
|
|
775
783
|
else:
|
|
776
|
-
|
|
784
|
+
self.opencti.app_logger.error(
|
|
777
785
|
"[opencti_report] Missing parameters: id and stixObjectOrStixRelationshipId",
|
|
778
786
|
)
|
|
779
787
|
return False
|
|
@@ -792,9 +800,12 @@ class Report:
|
|
|
792
800
|
"stixObjectOrStixRelationshipId", None
|
|
793
801
|
)
|
|
794
802
|
if id is not None and stix_object_or_stix_relationship_id is not None:
|
|
795
|
-
|
|
796
|
-
"Removing StixObjectOrStixRelationship
|
|
797
|
-
|
|
803
|
+
self.opencti.app_logger.info(
|
|
804
|
+
"Removing StixObjectOrStixRelationship to Report",
|
|
805
|
+
{
|
|
806
|
+
"id": id,
|
|
807
|
+
"stixObjectOrStixRelationshipId": stix_object_or_stix_relationship_id,
|
|
808
|
+
},
|
|
798
809
|
)
|
|
799
810
|
query = """
|
|
800
811
|
mutation ReportEditRelationDelete($id: ID!, $toId: StixRef!, $relationship_type: String!) {
|
|
@@ -815,7 +826,7 @@ class Report:
|
|
|
815
826
|
)
|
|
816
827
|
return True
|
|
817
828
|
else:
|
|
818
|
-
|
|
829
|
+
self.opencti.app_logger.error(
|
|
819
830
|
"[opencti_report] Missing parameters: id and stixObjectOrStixRelationshipId",
|
|
820
831
|
)
|
|
821
832
|
return False
|
|
@@ -874,6 +885,9 @@ class Report:
|
|
|
874
885
|
)
|
|
875
886
|
if "description" in stix_object
|
|
876
887
|
else None,
|
|
888
|
+
content=self.opencti.stix2.convert_markdown(stix_object["content"])
|
|
889
|
+
if "content" in stix_object
|
|
890
|
+
else None,
|
|
877
891
|
report_types=stix_object["report_types"]
|
|
878
892
|
if "report_types" in stix_object
|
|
879
893
|
else None,
|
|
@@ -892,4 +906,6 @@ class Report:
|
|
|
892
906
|
update=update,
|
|
893
907
|
)
|
|
894
908
|
else:
|
|
895
|
-
|
|
909
|
+
self.opencti.app_logger.error(
|
|
910
|
+
"[opencti_report] Missing parameters: stixObject"
|
|
911
|
+
)
|
pycti/entities/opencti_stix.py
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
|
|
3
|
-
from pycti.entities import LOGGER
|
|
4
|
-
|
|
5
|
-
|
|
6
1
|
class Stix:
|
|
7
2
|
def __init__(self, opencti):
|
|
8
3
|
self.opencti = opencti
|
|
@@ -17,7 +12,7 @@ class Stix:
|
|
|
17
12
|
def delete(self, **kwargs):
|
|
18
13
|
id = kwargs.get("id", None)
|
|
19
14
|
if id is not None:
|
|
20
|
-
|
|
15
|
+
self.opencti.app_logger.info("Deleting Stix element", {"id": id})
|
|
21
16
|
query = """
|
|
22
17
|
mutation StixEdit($id: ID!) {
|
|
23
18
|
stixEdit(id: $id) {
|
|
@@ -27,7 +22,7 @@ class Stix:
|
|
|
27
22
|
"""
|
|
28
23
|
self.opencti.query(query, {"id": id})
|
|
29
24
|
else:
|
|
30
|
-
|
|
25
|
+
self.opencti.app_logger.error("[opencti_stix] Missing parameters: id")
|
|
31
26
|
return None
|
|
32
27
|
|
|
33
28
|
"""
|
|
@@ -40,16 +35,11 @@ class Stix:
|
|
|
40
35
|
"""
|
|
41
36
|
|
|
42
37
|
def merge(self, **kwargs):
|
|
43
|
-
id = kwargs.get("id"
|
|
44
|
-
stix_objects_ids = kwargs.get("object_ids"
|
|
38
|
+
id = kwargs.get("id")
|
|
39
|
+
stix_objects_ids = kwargs.get("object_ids")
|
|
45
40
|
if id is not None and stix_objects_ids is not None:
|
|
46
|
-
self.opencti.
|
|
47
|
-
"
|
|
48
|
-
"Merging Stix object {"
|
|
49
|
-
+ id
|
|
50
|
-
+ "} with {"
|
|
51
|
-
+ ",".join(stix_objects_ids)
|
|
52
|
-
+ "}.",
|
|
41
|
+
self.opencti.app_logger.info(
|
|
42
|
+
"Merging Stix object", {"id": id, "sources": ",".join(stix_objects_ids)}
|
|
53
43
|
)
|
|
54
44
|
query = """
|
|
55
45
|
mutation StixEdit($id: ID!, $stixObjectsIds: [String]!) {
|
|
@@ -73,8 +63,7 @@ class Stix:
|
|
|
73
63
|
result["data"]["stixEdit"]["merge"]
|
|
74
64
|
)
|
|
75
65
|
else:
|
|
76
|
-
self.opencti.
|
|
77
|
-
"
|
|
78
|
-
"[opencti_stix] Missing parameters: id and object_ids",
|
|
66
|
+
self.opencti.app_logger.error(
|
|
67
|
+
"[opencti_stix] Missing parameters: id and object_ids"
|
|
79
68
|
)
|
|
80
69
|
return None
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
import json
|
|
3
3
|
|
|
4
|
-
from pycti.entities import LOGGER
|
|
5
|
-
|
|
6
4
|
|
|
7
5
|
class StixCoreObject:
|
|
8
6
|
def __init__(self, opencti, file):
|
|
@@ -1347,7 +1345,9 @@ class StixCoreObject:
|
|
|
1347
1345
|
if get_all:
|
|
1348
1346
|
first = 100
|
|
1349
1347
|
|
|
1350
|
-
|
|
1348
|
+
self.opencti.app_logger.info(
|
|
1349
|
+
"Listing Stix-Core-Objects with filters", {"filters": json.dumps(filters)}
|
|
1350
|
+
)
|
|
1351
1351
|
query = (
|
|
1352
1352
|
"""
|
|
1353
1353
|
query StixCoreObjects($types: [String], $filters: FilterGroup, $search: String, $relationship_type: [String], $elementId: [String], $first: Int, $after: ID, $orderBy: StixCoreObjectsOrdering, $orderMode: OrderingMode) {
|
|
@@ -1395,7 +1395,9 @@ class StixCoreObject:
|
|
|
1395
1395
|
final_data = final_data + data
|
|
1396
1396
|
while result["data"]["stixCoreObjects"]["pageInfo"]["hasNextPage"]:
|
|
1397
1397
|
after = result["data"]["stixCoreObjects"]["pageInfo"]["endCursor"]
|
|
1398
|
-
|
|
1398
|
+
self.opencti.app_logger.info(
|
|
1399
|
+
"Listing Stix-Core-Objects", {"after": after}
|
|
1400
|
+
)
|
|
1399
1401
|
result = self.opencti.query(
|
|
1400
1402
|
query,
|
|
1401
1403
|
{
|
|
@@ -1434,7 +1436,7 @@ class StixCoreObject:
|
|
|
1434
1436
|
custom_attributes = kwargs.get("customAttributes", None)
|
|
1435
1437
|
with_files = kwargs.get("withFiles", False)
|
|
1436
1438
|
if id is not None:
|
|
1437
|
-
|
|
1439
|
+
self.opencti.app_logger.info("Reading Stix-Core-Object", {"id": id})
|
|
1438
1440
|
query = (
|
|
1439
1441
|
"""
|
|
1440
1442
|
query StixCoreObject($id: String!) {
|
|
@@ -1463,12 +1465,14 @@ class StixCoreObject:
|
|
|
1463
1465
|
else:
|
|
1464
1466
|
return None
|
|
1465
1467
|
else:
|
|
1466
|
-
|
|
1468
|
+
self.opencti.app_logger.error(
|
|
1469
|
+
"[opencti_stix_core_object] Missing parameters: id or filters"
|
|
1470
|
+
)
|
|
1467
1471
|
return None
|
|
1468
1472
|
|
|
1469
1473
|
def list_files(self, **kwargs):
|
|
1470
1474
|
id = kwargs.get("id", None)
|
|
1471
|
-
|
|
1475
|
+
self.opencti.app_logger.info("Listing files of Stix-Core-Object", {"id": id})
|
|
1472
1476
|
query = """
|
|
1473
1477
|
query StixCoreObject($id: String!) {
|
|
1474
1478
|
stixCoreObject(id: $id) {
|
|
@@ -1523,7 +1527,9 @@ class StixCoreObject:
|
|
|
1523
1527
|
def reports(self, **kwargs):
|
|
1524
1528
|
id = kwargs.get("id", None)
|
|
1525
1529
|
if id is not None:
|
|
1526
|
-
|
|
1530
|
+
self.opencti.app_logger.info(
|
|
1531
|
+
"Getting reports of the Stix-Core-Object", {"id": id}
|
|
1532
|
+
)
|
|
1527
1533
|
query = """
|
|
1528
1534
|
query StixCoreObject($id: String!) {
|
|
1529
1535
|
stixCoreObject(id: $id) {
|
|
@@ -1647,5 +1653,5 @@ class StixCoreObject:
|
|
|
1647
1653
|
else:
|
|
1648
1654
|
return []
|
|
1649
1655
|
else:
|
|
1650
|
-
|
|
1656
|
+
self.opencti.app_logger.error("Missing parameters: id")
|
|
1651
1657
|
return None
|
|
@@ -5,8 +5,6 @@ import uuid
|
|
|
5
5
|
|
|
6
6
|
from stix2.canonicalization.Canonicalize import canonicalize
|
|
7
7
|
|
|
8
|
-
from pycti.entities import LOGGER
|
|
9
|
-
|
|
10
8
|
|
|
11
9
|
class StixCoreRelationship:
|
|
12
10
|
def __init__(self, opencti):
|
|
@@ -408,11 +406,17 @@ class StixCoreRelationship:
|
|
|
408
406
|
if get_all:
|
|
409
407
|
first = 100
|
|
410
408
|
|
|
411
|
-
|
|
412
|
-
"Listing stix_core_relationships
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
409
|
+
self.opencti.app_logger.info(
|
|
410
|
+
"Listing stix_core_relationships",
|
|
411
|
+
{
|
|
412
|
+
"relationship_type": relationship_type,
|
|
413
|
+
"element_id": element_id,
|
|
414
|
+
"from_id": from_id,
|
|
415
|
+
"to_id": to_id,
|
|
416
|
+
"element_with_target_types": element_with_target_types,
|
|
417
|
+
"from_types": from_types,
|
|
418
|
+
"to_types": to_types,
|
|
419
|
+
},
|
|
416
420
|
)
|
|
417
421
|
query = (
|
|
418
422
|
"""
|
|
@@ -465,7 +469,9 @@ class StixCoreRelationship:
|
|
|
465
469
|
final_data = final_data + data
|
|
466
470
|
while result["data"]["stixCoreRelationships"]["pageInfo"]["hasNextPage"]:
|
|
467
471
|
after = result["data"]["stixCoreRelationships"]["pageInfo"]["endCursor"]
|
|
468
|
-
|
|
472
|
+
self.opencti.app_logger.info(
|
|
473
|
+
"Listing StixCoreRelationships", {"after": after}
|
|
474
|
+
)
|
|
469
475
|
result = self.opencti.query(
|
|
470
476
|
query,
|
|
471
477
|
{
|
|
@@ -524,7 +530,7 @@ class StixCoreRelationship:
|
|
|
524
530
|
stop_time_stop = kwargs.get("stopTimeStop", None)
|
|
525
531
|
custom_attributes = kwargs.get("customAttributes", None)
|
|
526
532
|
if id is not None:
|
|
527
|
-
|
|
533
|
+
self.opencti.app_logger.info("Reading stix_core_relationship", {"id": id})
|
|
528
534
|
query = (
|
|
529
535
|
"""
|
|
530
536
|
query StixCoreRelationship($id: String!) {
|
|
@@ -560,7 +566,7 @@ class StixCoreRelationship:
|
|
|
560
566
|
else:
|
|
561
567
|
return None
|
|
562
568
|
else:
|
|
563
|
-
|
|
569
|
+
self.opencti.app_logger.error("Missing parameters: id or from_id and to_id")
|
|
564
570
|
return None
|
|
565
571
|
|
|
566
572
|
"""
|
|
@@ -591,11 +597,13 @@ class StixCoreRelationship:
|
|
|
591
597
|
granted_refs = kwargs.get("objectOrganization", None)
|
|
592
598
|
update = kwargs.get("update", False)
|
|
593
599
|
|
|
594
|
-
|
|
595
|
-
"Creating stix_core_relationship
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
600
|
+
self.opencti.app_logger.info(
|
|
601
|
+
"Creating stix_core_relationship",
|
|
602
|
+
{
|
|
603
|
+
"relationship_type": relationship_type,
|
|
604
|
+
"from_id": from_id,
|
|
605
|
+
"to_id": to_id,
|
|
606
|
+
},
|
|
599
607
|
)
|
|
600
608
|
query = """
|
|
601
609
|
mutation StixCoreRelationshipAdd($input: StixCoreRelationshipAddInput!) {
|
|
@@ -649,7 +657,7 @@ class StixCoreRelationship:
|
|
|
649
657
|
id = kwargs.get("id", None)
|
|
650
658
|
input = kwargs.get("input", None)
|
|
651
659
|
if id is not None and input is not None:
|
|
652
|
-
|
|
660
|
+
self.opencti.app_logger.info("Updating stix_core_relationship", {"id": id})
|
|
653
661
|
query = """
|
|
654
662
|
mutation StixCoreRelationshipEdit($id: ID!, $input: [EditInput]!) {
|
|
655
663
|
stixCoreRelationshipEdit(id: $id) {
|
|
@@ -672,7 +680,7 @@ class StixCoreRelationship:
|
|
|
672
680
|
result["data"]["stixCoreRelationshipEdit"]["fieldPatch"]
|
|
673
681
|
)
|
|
674
682
|
else:
|
|
675
|
-
|
|
683
|
+
self.opencti.app_logger.error(
|
|
676
684
|
"[opencti_stix_core_relationship] Missing parameters: id and key and value",
|
|
677
685
|
)
|
|
678
686
|
return None
|
|
@@ -687,7 +695,7 @@ class StixCoreRelationship:
|
|
|
687
695
|
def delete(self, **kwargs):
|
|
688
696
|
id = kwargs.get("id", None)
|
|
689
697
|
if id is not None:
|
|
690
|
-
|
|
698
|
+
self.opencti.app_logger.info("Deleting stix_core_relationship", {"id": id})
|
|
691
699
|
query = """
|
|
692
700
|
mutation StixCoreRelationshipEdit($id: ID!) {
|
|
693
701
|
stixCoreRelationshipEdit(id: $id) {
|
|
@@ -697,7 +705,9 @@ class StixCoreRelationship:
|
|
|
697
705
|
"""
|
|
698
706
|
self.opencti.query(query, {"id": id})
|
|
699
707
|
else:
|
|
700
|
-
|
|
708
|
+
self.opencti.app_logger.error(
|
|
709
|
+
"[opencti_stix_core_relationship] Missing parameters: id"
|
|
710
|
+
)
|
|
701
711
|
return None
|
|
702
712
|
|
|
703
713
|
"""
|
|
@@ -734,14 +744,16 @@ class StixCoreRelationship:
|
|
|
734
744
|
id=id, customAttributes=custom_attributes
|
|
735
745
|
)
|
|
736
746
|
if stix_core_relationship is None:
|
|
737
|
-
|
|
747
|
+
self.opencti.app_logger.error(
|
|
748
|
+
"Cannot add Marking-Definition, entity not found"
|
|
749
|
+
)
|
|
738
750
|
return False
|
|
739
751
|
if marking_definition_id in stix_core_relationship["objectMarkingIds"]:
|
|
740
752
|
return True
|
|
741
753
|
else:
|
|
742
|
-
|
|
743
|
-
"Adding Marking-Definition
|
|
744
|
-
|
|
754
|
+
self.opencti.app_logger.info(
|
|
755
|
+
"Adding Marking-Definition to Stix-Domain-Object",
|
|
756
|
+
{"id": id, "marking_definition_id": marking_definition_id},
|
|
745
757
|
)
|
|
746
758
|
query = """
|
|
747
759
|
mutation StixCoreRelationshipAddRelation($id: ID!, $input: StixRefRelationshipAddInput!) {
|
|
@@ -764,7 +776,9 @@ class StixCoreRelationship:
|
|
|
764
776
|
)
|
|
765
777
|
return True
|
|
766
778
|
else:
|
|
767
|
-
|
|
779
|
+
self.opencti.app_logger.error(
|
|
780
|
+
"Missing parameters: id and marking_definition_id"
|
|
781
|
+
)
|
|
768
782
|
return False
|
|
769
783
|
|
|
770
784
|
"""
|
|
@@ -779,9 +793,9 @@ class StixCoreRelationship:
|
|
|
779
793
|
id = kwargs.get("id", None)
|
|
780
794
|
marking_definition_id = kwargs.get("marking_definition_id", None)
|
|
781
795
|
if id is not None and marking_definition_id is not None:
|
|
782
|
-
|
|
783
|
-
"Removing Marking-Definition
|
|
784
|
-
|
|
796
|
+
self.opencti.app_logger.info(
|
|
797
|
+
"Removing Marking-Definition from stix_core_relationship",
|
|
798
|
+
{"id": id, "marking_definition_id": marking_definition_id},
|
|
785
799
|
)
|
|
786
800
|
query = """
|
|
787
801
|
mutation StixCoreRelationshipRemoveRelation($id: ID!, $toId: StixRef!, $relationship_type: String!) {
|
|
@@ -802,7 +816,7 @@ class StixCoreRelationship:
|
|
|
802
816
|
)
|
|
803
817
|
return True
|
|
804
818
|
else:
|
|
805
|
-
|
|
819
|
+
self.opencti.app_logger.error("Missing parameters: id and label_id")
|
|
806
820
|
return False
|
|
807
821
|
|
|
808
822
|
"""
|
|
@@ -831,8 +845,9 @@ class StixCoreRelationship:
|
|
|
831
845
|
label = self.opencti.label.create(value=label_name)
|
|
832
846
|
label_id = label["id"]
|
|
833
847
|
if id is not None and label_id is not None:
|
|
834
|
-
|
|
835
|
-
"Adding label
|
|
848
|
+
self.opencti.app_logger.info(
|
|
849
|
+
"Adding label to stix-core-relationship",
|
|
850
|
+
{"label_id": label_id, "id": id},
|
|
836
851
|
)
|
|
837
852
|
query = """
|
|
838
853
|
mutation StixCoreRelationshipAddRelation($id: ID!, $input: StixRefRelationshipAddInput!) {
|
|
@@ -855,7 +870,7 @@ class StixCoreRelationship:
|
|
|
855
870
|
)
|
|
856
871
|
return True
|
|
857
872
|
else:
|
|
858
|
-
|
|
873
|
+
self.opencti.app_logger.error("Missing parameters: id and label_id")
|
|
859
874
|
return False
|
|
860
875
|
|
|
861
876
|
"""
|
|
@@ -870,9 +885,9 @@ class StixCoreRelationship:
|
|
|
870
885
|
id = kwargs.get("id", None)
|
|
871
886
|
external_reference_id = kwargs.get("external_reference_id", None)
|
|
872
887
|
if id is not None and external_reference_id is not None:
|
|
873
|
-
|
|
874
|
-
"Adding External-Reference
|
|
875
|
-
|
|
888
|
+
self.opencti.app_logger.info(
|
|
889
|
+
"Adding External-Reference to stix-core-relationship",
|
|
890
|
+
{"external_reference_id": external_reference_id, "id": id},
|
|
876
891
|
)
|
|
877
892
|
query = """
|
|
878
893
|
mutation StixCoreRelationshipEditRelationAdd($id: ID!, $input: StixRefRelationshipAddInput!) {
|
|
@@ -895,7 +910,9 @@ class StixCoreRelationship:
|
|
|
895
910
|
)
|
|
896
911
|
return True
|
|
897
912
|
else:
|
|
898
|
-
|
|
913
|
+
self.opencti.app_logger.error(
|
|
914
|
+
"Missing parameters: id and external_reference_id"
|
|
915
|
+
)
|
|
899
916
|
return False
|
|
900
917
|
|
|
901
918
|
"""
|
|
@@ -910,9 +927,9 @@ class StixCoreRelationship:
|
|
|
910
927
|
id = kwargs.get("id", None)
|
|
911
928
|
external_reference_id = kwargs.get("external_reference_id", None)
|
|
912
929
|
if id is not None and external_reference_id is not None:
|
|
913
|
-
|
|
914
|
-
"Removing External-Reference
|
|
915
|
-
|
|
930
|
+
self.opencti.app_logger.info(
|
|
931
|
+
"Removing External-Reference from stix_core_relationship",
|
|
932
|
+
{"external_reference_id": external_reference_id, "id": id},
|
|
916
933
|
)
|
|
917
934
|
query = """
|
|
918
935
|
mutation StixCoreRelationshipRemoveRelation($id: ID!, $toId: StixRef!, $relationship_type: String!) {
|
|
@@ -933,7 +950,7 @@ class StixCoreRelationship:
|
|
|
933
950
|
)
|
|
934
951
|
return True
|
|
935
952
|
else:
|
|
936
|
-
|
|
953
|
+
self.opencti.app_logger.error("Missing parameters: id and label_id")
|
|
937
954
|
return False
|
|
938
955
|
|
|
939
956
|
"""
|
|
@@ -948,9 +965,9 @@ class StixCoreRelationship:
|
|
|
948
965
|
id = kwargs.get("id", None)
|
|
949
966
|
kill_chain_phase_id = kwargs.get("kill_chain_phase_id", None)
|
|
950
967
|
if id is not None and kill_chain_phase_id is not None:
|
|
951
|
-
|
|
952
|
-
"Adding Kill-Chain-Phase
|
|
953
|
-
|
|
968
|
+
self.opencti.app_logger.info(
|
|
969
|
+
"Adding Kill-Chain-Phase to stix-core-relationship",
|
|
970
|
+
{"kill_chain_phase_id": kill_chain_phase_id, "id": id},
|
|
954
971
|
)
|
|
955
972
|
query = """
|
|
956
973
|
mutation StixCoreRelationshipAddRelation($id: ID!, $input: StixRefRelationshipAddInput!) {
|
|
@@ -973,7 +990,7 @@ class StixCoreRelationship:
|
|
|
973
990
|
)
|
|
974
991
|
return True
|
|
975
992
|
else:
|
|
976
|
-
|
|
993
|
+
self.opencti.app_logger.error(
|
|
977
994
|
"[opencti_stix_core_relationship] Missing parameters: id and kill_chain_phase_id",
|
|
978
995
|
)
|
|
979
996
|
return False
|
|
@@ -990,9 +1007,9 @@ class StixCoreRelationship:
|
|
|
990
1007
|
id = kwargs.get("id", None)
|
|
991
1008
|
kill_chain_phase_id = kwargs.get("kill_chain_phase_id", None)
|
|
992
1009
|
if id is not None and kill_chain_phase_id is not None:
|
|
993
|
-
|
|
994
|
-
"Removing Kill-Chain-Phase
|
|
995
|
-
|
|
1010
|
+
self.opencti.app_logger.info(
|
|
1011
|
+
"Removing Kill-Chain-Phase from stix_core_relationship",
|
|
1012
|
+
{"kill_chain_phase_id": kill_chain_phase_id, "id": id},
|
|
996
1013
|
)
|
|
997
1014
|
query = """
|
|
998
1015
|
mutation StixCoreRelationshipRemoveRelation($id: ID!, $toId: StixRef!, $relationship_type: String!) {
|
|
@@ -1013,7 +1030,7 @@ class StixCoreRelationship:
|
|
|
1013
1030
|
)
|
|
1014
1031
|
return True
|
|
1015
1032
|
else:
|
|
1016
|
-
|
|
1033
|
+
self.opencti.app_loggererror(
|
|
1017
1034
|
"[stix_core_relationship] Missing parameters: id and kill_chain_phase_id"
|
|
1018
1035
|
)
|
|
1019
1036
|
return False
|
|
@@ -1030,9 +1047,9 @@ class StixCoreRelationship:
|
|
|
1030
1047
|
id = kwargs.get("id", None)
|
|
1031
1048
|
identity_id = kwargs.get("identity_id", None)
|
|
1032
1049
|
if id is not None:
|
|
1033
|
-
|
|
1034
|
-
"Updating author of stix_core_relationship
|
|
1035
|
-
|
|
1050
|
+
self.opencti.app_logger.info(
|
|
1051
|
+
"Updating author of stix_core_relationship with Identity",
|
|
1052
|
+
{"id": id, "identity_id": identity_id},
|
|
1036
1053
|
)
|
|
1037
1054
|
custom_attributes = """
|
|
1038
1055
|
id
|
|
@@ -1097,7 +1114,7 @@ class StixCoreRelationship:
|
|
|
1097
1114
|
}
|
|
1098
1115
|
self.opencti.query(query, variables)
|
|
1099
1116
|
else:
|
|
1100
|
-
|
|
1117
|
+
self.opencti.app_logger.error("Missing parameters: id")
|
|
1101
1118
|
return False
|
|
1102
1119
|
|
|
1103
1120
|
"""
|
|
@@ -1171,6 +1188,6 @@ class StixCoreRelationship:
|
|
|
1171
1188
|
update=update,
|
|
1172
1189
|
)
|
|
1173
1190
|
else:
|
|
1174
|
-
|
|
1191
|
+
self.opencti.app_logger.error(
|
|
1175
1192
|
"[opencti_stix_core_relationship] Missing parameters: stixObject"
|
|
1176
1193
|
)
|