pycti 6.1.2__py3-none-any.whl → 6.1.4__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/connector/opencti_connector_helper.py +3 -10
- pycti/entities/opencti_stix_core_relationship.py +7 -0
- pycti/utils/opencti_stix2.py +15 -84
- {pycti-6.1.2.dist-info → pycti-6.1.4.dist-info}/METADATA +1 -1
- {pycti-6.1.2.dist-info → pycti-6.1.4.dist-info}/RECORD +9 -9
- {pycti-6.1.2.dist-info → pycti-6.1.4.dist-info}/LICENSE +0 -0
- {pycti-6.1.2.dist-info → pycti-6.1.4.dist-info}/WHEEL +0 -0
- {pycti-6.1.2.dist-info → pycti-6.1.4.dist-info}/top_level.txt +0 -0
pycti/__init__.py
CHANGED
|
@@ -262,17 +262,10 @@ class ListenQueue(threading.Thread):
|
|
|
262
262
|
raise ValueError(
|
|
263
263
|
"Internal enrichment must be based on a specific id"
|
|
264
264
|
)
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
reader_type = (
|
|
268
|
-
entity_type if entity_type is not None else default_reader_type
|
|
265
|
+
do_read = self.helper.api.stix2.get_reader(
|
|
266
|
+
entity_type if entity_type is not None else "Stix-Core-Object"
|
|
269
267
|
)
|
|
270
|
-
|
|
271
|
-
readers[reader_type]
|
|
272
|
-
if reader_type in readers
|
|
273
|
-
else readers[default_reader_type]
|
|
274
|
-
)
|
|
275
|
-
opencti_entity = selected_reader(id=entity_id, withFiles=True)
|
|
268
|
+
opencti_entity = do_read(id=entity_id, withFiles=True)
|
|
276
269
|
if opencti_entity is None:
|
|
277
270
|
raise ValueError(
|
|
278
271
|
"Unable to read/access to the entity, please check that the connector permission"
|
|
@@ -588,6 +588,7 @@ class StixCoreRelationship:
|
|
|
588
588
|
external_references = kwargs.get("externalReferences", None)
|
|
589
589
|
kill_chain_phases = kwargs.get("killChainPhases", None)
|
|
590
590
|
granted_refs = kwargs.get("objectOrganization", None)
|
|
591
|
+
x_opencti_workflow_id = kwargs.get("x_opencti_workflow_id", None)
|
|
591
592
|
update = kwargs.get("update", False)
|
|
592
593
|
|
|
593
594
|
self.opencti.app_logger.info(
|
|
@@ -630,6 +631,7 @@ class StixCoreRelationship:
|
|
|
630
631
|
"objectOrganization": granted_refs,
|
|
631
632
|
"externalReferences": external_references,
|
|
632
633
|
"killChainPhases": kill_chain_phases,
|
|
634
|
+
"x_opencti_workflow_id": x_opencti_workflow_id,
|
|
633
635
|
"update": update,
|
|
634
636
|
}
|
|
635
637
|
},
|
|
@@ -1190,6 +1192,11 @@ class StixCoreRelationship:
|
|
|
1190
1192
|
if "x_opencti_granted_refs" in stix_relation
|
|
1191
1193
|
else None
|
|
1192
1194
|
),
|
|
1195
|
+
x_opencti_workflow_id=(
|
|
1196
|
+
stix_relation["x_opencti_workflow_id"]
|
|
1197
|
+
if "x_opencti_workflow_id" in stix_relation
|
|
1198
|
+
else None
|
|
1199
|
+
),
|
|
1193
1200
|
update=update,
|
|
1194
1201
|
)
|
|
1195
1202
|
else:
|
pycti/utils/opencti_stix2.py
CHANGED
|
@@ -754,48 +754,7 @@ class OpenCTIStix2:
|
|
|
754
754
|
"reports": reports,
|
|
755
755
|
}
|
|
756
756
|
|
|
757
|
-
|
|
758
|
-
return {
|
|
759
|
-
"Stix-Core-Object": self.opencti.stix_core_object.list,
|
|
760
|
-
"Stix-Domain-Object": self.opencti.stix_domain_object.list,
|
|
761
|
-
"Administrative-Area": self.opencti.location.list,
|
|
762
|
-
"Attack-Pattern": self.opencti.attack_pattern.list,
|
|
763
|
-
"Campaign": self.opencti.campaign.list,
|
|
764
|
-
"Channel": self.opencti.channel.list,
|
|
765
|
-
"Event": self.opencti.event.list,
|
|
766
|
-
"Note": self.opencti.note.list,
|
|
767
|
-
"Observed-Data": self.opencti.observed_data.list,
|
|
768
|
-
"Opinion": self.opencti.opinion.list,
|
|
769
|
-
"Report": self.opencti.report.list,
|
|
770
|
-
"Grouping": self.opencti.grouping.list,
|
|
771
|
-
"Case-Incident": self.opencti.case_incident.list,
|
|
772
|
-
"Feedback": self.opencti.feedback.list,
|
|
773
|
-
"Case-Rfi": self.opencti.case_rfi.list,
|
|
774
|
-
"Case-Rft": self.opencti.case_rft.list,
|
|
775
|
-
"Task": self.opencti.task.list,
|
|
776
|
-
"Course-Of-Action": self.opencti.course_of_action.list,
|
|
777
|
-
"Data-Component": self.opencti.data_component.list,
|
|
778
|
-
"Data-Source": self.opencti.data_source.list,
|
|
779
|
-
"Identity": self.opencti.identity.list,
|
|
780
|
-
"Indicator": self.opencti.indicator.list,
|
|
781
|
-
"Infrastructure": self.opencti.infrastructure.list,
|
|
782
|
-
"Intrusion-Set": self.opencti.intrusion_set.list,
|
|
783
|
-
"Location": self.opencti.location.list,
|
|
784
|
-
"Language": self.opencti.language.list,
|
|
785
|
-
"Malware": self.opencti.malware.list,
|
|
786
|
-
"Malware-Analysis": self.opencti.malware_analysis.list,
|
|
787
|
-
"Threat-Actor": self.opencti.threat_actor_group.list,
|
|
788
|
-
"Threat-Actor-Group": self.opencti.threat_actor_group.list,
|
|
789
|
-
"Threat-Actor-Individual": self.opencti.threat_actor_individual.list,
|
|
790
|
-
"Tool": self.opencti.tool.list,
|
|
791
|
-
"Narrative": self.opencti.narrative.list,
|
|
792
|
-
"Vulnerability": self.opencti.vulnerability.list,
|
|
793
|
-
"Incident": self.opencti.incident.list,
|
|
794
|
-
"Stix-Cyber-Observable": self.opencti.stix_cyber_observable.list,
|
|
795
|
-
"stix-sighting-relationship": self.opencti.stix_sighting_relationship.list,
|
|
796
|
-
"stix-core-relationship": self.opencti.stix_core_relationship.list,
|
|
797
|
-
}
|
|
798
|
-
|
|
757
|
+
# Please use get_reader instead of this definition
|
|
799
758
|
def get_readers(self):
|
|
800
759
|
return {
|
|
801
760
|
"Attack-Pattern": self.opencti.attack_pattern.read,
|
|
@@ -851,8 +810,11 @@ class OpenCTIStix2:
|
|
|
851
810
|
entity_type = "Identity"
|
|
852
811
|
if LocationTypes.has_value(entity_type):
|
|
853
812
|
entity_type = "Location"
|
|
813
|
+
if entity_type == "Container":
|
|
814
|
+
entity_type = "Stix-Domain-Object"
|
|
854
815
|
if StixCyberObservableTypes.has_value(entity_type):
|
|
855
816
|
entity_type = "Stix-Cyber-Observable"
|
|
817
|
+
|
|
856
818
|
readers = self.get_readers()
|
|
857
819
|
return readers.get(
|
|
858
820
|
entity_type, lambda **kwargs: self.unknown_type({"type": entity_type})
|
|
@@ -1872,7 +1834,7 @@ class OpenCTIStix2:
|
|
|
1872
1834
|
filters=relationships_from_filter
|
|
1873
1835
|
)
|
|
1874
1836
|
if len(x) > 0:
|
|
1875
|
-
entity["sighting_of_ref"] = entity["from"]["
|
|
1837
|
+
entity["sighting_of_ref"] = entity["from"]["standard_id"]
|
|
1876
1838
|
# handle from and to separately like Stix Core Relationship and call 2 requests
|
|
1877
1839
|
objects_to_get.append(
|
|
1878
1840
|
entity["from"]
|
|
@@ -1886,7 +1848,7 @@ class OpenCTIStix2:
|
|
|
1886
1848
|
filters=relationships_to_filter
|
|
1887
1849
|
)
|
|
1888
1850
|
if len(y) > 0:
|
|
1889
|
-
entity["where_sighted_refs"] = [entity["to"]["
|
|
1851
|
+
entity["where_sighted_refs"] = [entity["to"]["standard_id"]]
|
|
1890
1852
|
objects_to_get.append(entity["to"])
|
|
1891
1853
|
|
|
1892
1854
|
del entity["from"]
|
|
@@ -1903,7 +1865,7 @@ class OpenCTIStix2:
|
|
|
1903
1865
|
filters=relationships_from_filter
|
|
1904
1866
|
)
|
|
1905
1867
|
if len(x) > 0:
|
|
1906
|
-
entity["source_ref"] = entity["from"]["
|
|
1868
|
+
entity["source_ref"] = entity["from"]["standard_id"]
|
|
1907
1869
|
# handle from and to separately like Stix Core Relationship and call 2 requests
|
|
1908
1870
|
objects_to_get.append(
|
|
1909
1871
|
entity["from"]
|
|
@@ -1918,7 +1880,7 @@ class OpenCTIStix2:
|
|
|
1918
1880
|
filters=relationships_to_filter
|
|
1919
1881
|
)
|
|
1920
1882
|
if len(y) > 0:
|
|
1921
|
-
entity["target_ref"] = entity["to"]["
|
|
1883
|
+
entity["target_ref"] = entity["to"]["standard_id"]
|
|
1922
1884
|
objects_to_get.append(entity["to"])
|
|
1923
1885
|
del entity["to"]
|
|
1924
1886
|
# Stix Domain Object
|
|
@@ -2095,32 +2057,14 @@ class OpenCTIStix2:
|
|
|
2095
2057
|
|
|
2096
2058
|
if no_custom_attributes:
|
|
2097
2059
|
del entity["x_opencti_id"]
|
|
2098
|
-
# Export
|
|
2099
|
-
reader = self.get_readers()
|
|
2100
2060
|
# Get extra objects
|
|
2101
2061
|
for entity_object in objects_to_get:
|
|
2102
|
-
|
|
2103
|
-
if
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
elif LocationTypes.has_value(entity_object["entity_type"]):
|
|
2109
|
-
entity_object["entity_type"] = "Location"
|
|
2110
|
-
elif StixCyberObservableTypes.has_value(entity_object["entity_type"]):
|
|
2111
|
-
entity_object["entity_type"] = "Stix-Cyber-Observable"
|
|
2112
|
-
elif "stix-core-relationship" in entity_object["parent_types"]:
|
|
2113
|
-
entity_object["entity_type"] = "stix-core-relationship"
|
|
2114
|
-
elif "stix-ref-relationship" in entity_object["parent_types"]:
|
|
2115
|
-
entity_object["entity_type"] = "stix-ref-relationship"
|
|
2116
|
-
|
|
2117
|
-
do_read = reader.get(
|
|
2118
|
-
entity_object["entity_type"],
|
|
2119
|
-
lambda **kwargs: self.unknown_type(
|
|
2120
|
-
{"type": entity_object["entity_type"]}
|
|
2121
|
-
),
|
|
2122
|
-
)
|
|
2123
|
-
|
|
2062
|
+
resolve_type = entity_object["entity_type"]
|
|
2063
|
+
if "stix-core-relationship" in entity_object["parent_types"]:
|
|
2064
|
+
resolve_type = "stix-core-relationship"
|
|
2065
|
+
if "stix-ref-relationship" in entity_object["parent_types"]:
|
|
2066
|
+
resolve_type = "stix-ref-relationship"
|
|
2067
|
+
do_read = self.get_reader(resolve_type)
|
|
2124
2068
|
query_filters = self.prepare_id_filters_export(
|
|
2125
2069
|
entity_object["id"], access_filter
|
|
2126
2070
|
)
|
|
@@ -2225,20 +2169,7 @@ class OpenCTIStix2:
|
|
|
2225
2169
|
"id": "bundle--" + str(uuid.uuid4()),
|
|
2226
2170
|
"objects": [],
|
|
2227
2171
|
}
|
|
2228
|
-
|
|
2229
|
-
if entity_type == "StixFile":
|
|
2230
|
-
entity_type = "File"
|
|
2231
|
-
|
|
2232
|
-
# Map types
|
|
2233
|
-
if IdentityTypes.has_value(entity_type):
|
|
2234
|
-
entity_type = "Identity"
|
|
2235
|
-
if LocationTypes.has_value(entity_type):
|
|
2236
|
-
entity_type = "Location"
|
|
2237
|
-
|
|
2238
|
-
readers = self.get_readers()
|
|
2239
|
-
do_read = readers.get(
|
|
2240
|
-
entity_type, lambda **kwargs: self.unknown_type({"type": entity_type})
|
|
2241
|
-
)
|
|
2172
|
+
do_read = self.get_reader(entity_type)
|
|
2242
2173
|
entity = do_read(id=entity_id)
|
|
2243
2174
|
if entity is None:
|
|
2244
2175
|
self.opencti.app_logger.error(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
pycti/__init__.py,sha256
|
|
1
|
+
pycti/__init__.py,sha256=wZBeVfDfWr21plXv-SmfxEqF3S574PQgFfuvn0yq-ns,5035
|
|
2
2
|
pycti/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
pycti/api/opencti_api_client.py,sha256=fDeVJjExlsrTNYRf28LYhifz901JkdOZueCdvvko36Y,29575
|
|
4
4
|
pycti/api/opencti_api_connector.py,sha256=fYF0Jy9KIMFNt1RC_A1rpWomVJ-oj5HiSsBem4W0J5U,3549
|
|
@@ -6,7 +6,7 @@ pycti/api/opencti_api_playbook.py,sha256=OkqDawpnMYIHz5sD4djlJ_KgORkfvQ7YbJwttxE
|
|
|
6
6
|
pycti/api/opencti_api_work.py,sha256=JLfl7oy6Cq9IrYW_kUrqwzN46FoVzyIn1JJQKyK0h_w,7615
|
|
7
7
|
pycti/connector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
pycti/connector/opencti_connector.py,sha256=0vrZ8Y8ecbxegAP1YhpX6ybOZahYjjOkcId51D1oBi4,2449
|
|
9
|
-
pycti/connector/opencti_connector_helper.py,sha256=
|
|
9
|
+
pycti/connector/opencti_connector_helper.py,sha256=MUo8Eq53qn0MDIfyWj-mEV1jUJVrFCH8ENtAS8j0s-Q,60311
|
|
10
10
|
pycti/connector/opencti_metric_handler.py,sha256=4jXHeJflomtHjuQ_YU0b36TG7o26vOWbY_jvU8Ezobs,3725
|
|
11
11
|
pycti/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
pycti/entities/opencti_attack_pattern.py,sha256=ycAR0cReJ1dd_edQPAL6qBrFvvTx10GJFMTezyK91cg,21471
|
|
@@ -41,7 +41,7 @@ pycti/entities/opencti_opinion.py,sha256=SPcY8-0zRJCMle-eDLka-CFPyAqU3CnVVBtfVYh
|
|
|
41
41
|
pycti/entities/opencti_report.py,sha256=zKoq3Kpo3afvFsw0QCBOaeVm9J_xRMBOZfJC7ZPRaRg,33580
|
|
42
42
|
pycti/entities/opencti_stix.py,sha256=uMheSg8i1f2Ozx2Mk0iShWzHHjj6MMWDtV5nDjVxKEE,2275
|
|
43
43
|
pycti/entities/opencti_stix_core_object.py,sha256=3jABOB_-vm2CSB6LU3ylxpSj_oixRCcfU3T10n2_MFU,49559
|
|
44
|
-
pycti/entities/opencti_stix_core_relationship.py,sha256=
|
|
44
|
+
pycti/entities/opencti_stix_core_relationship.py,sha256=93E9sIiKIOYJtjzBecMBMOGoKNsgOJnrRi0HscmU6iA,43249
|
|
45
45
|
pycti/entities/opencti_stix_cyber_observable.py,sha256=EOJuXeSmFcm4oI2rPOqxZ8QZq_ej_CTkYgCTtUkZwsk,106785
|
|
46
46
|
pycti/entities/opencti_stix_domain_object.py,sha256=QI6uBbefNC_PQSwl0O5KpG4cWqa-15mIju8dwREzooU,78504
|
|
47
47
|
pycti/entities/opencti_stix_nested_ref_relationship.py,sha256=2r1i7cUl-WWictlnC_MJrm9sTIt_yJe2uqTpQm-yo6o,12330
|
|
@@ -57,12 +57,12 @@ pycti/entities/opencti_vulnerability.py,sha256=dzJ0fZB2XrkPwT-cANr6atzYOWXF5nk0a
|
|
|
57
57
|
pycti/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
58
|
pycti/utils/constants.py,sha256=Gj0fz94p0ApjCUCUqBQpFTfNslT021HS2w6M8azqXBY,10601
|
|
59
59
|
pycti/utils/opencti_logger.py,sha256=0dvB75V0SuPFGxL539dAQrxTt1N5Acx0A3Ogwl5WMJ8,2199
|
|
60
|
-
pycti/utils/opencti_stix2.py,sha256=
|
|
60
|
+
pycti/utils/opencti_stix2.py,sha256=7-AhzCrt0j28acGFbgTvXIAlUBI05zcYD5zmOAf-caY,112457
|
|
61
61
|
pycti/utils/opencti_stix2_splitter.py,sha256=Ht9Mp-W3gbwxIKEr7i_5NYpcDr3TA2gYdC4TzOz0G4c,4496
|
|
62
62
|
pycti/utils/opencti_stix2_update.py,sha256=CnMyqkeVA0jgyxEcgqna8sABU4YPMjkEJ228GVurIn4,14658
|
|
63
63
|
pycti/utils/opencti_stix2_utils.py,sha256=4r9qglN3AIN8JH1B9Ts2o20Qn3K203M4c5-lIPzRpZ4,4138
|
|
64
|
-
pycti-6.1.
|
|
65
|
-
pycti-6.1.
|
|
66
|
-
pycti-6.1.
|
|
67
|
-
pycti-6.1.
|
|
68
|
-
pycti-6.1.
|
|
64
|
+
pycti-6.1.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
65
|
+
pycti-6.1.4.dist-info/METADATA,sha256=M2QbuEG6qBPN6MmV195krKAjx_boL3XUD1bCHm0PriE,5313
|
|
66
|
+
pycti-6.1.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
67
|
+
pycti-6.1.4.dist-info/top_level.txt,sha256=cqEpxitAhHP4VgSA6xmrak6Yk9MeBkwoMTB6k7d2ZnE,6
|
|
68
|
+
pycti-6.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|