@@ -754,48 +754,7 @@ def extract_embedded_relationships(
754754 "reports" : reports ,
755755 }
756756
757- def get_listers (self ):
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
799758 def get_readers (self ):
800759 return {
801760 "Attack-Pattern" : self .opencti .attack_pattern .read ,
@@ -851,8 +810,11 @@ def get_reader(self, entity_type: str):
851810 entity_type = "Identity"
852811 if LocationTypes .has_value (entity_type ):
853812 entity_type = "Location"
813+ if entity_type == "Container" :
814+ entity_type = "Stix-Domain-Object"
854815 if StixCyberObservableTypes .has_value (entity_type ):
855816 entity_type = "Stix-Cyber-Observable"
817+
856818 readers = self .get_readers ()
857819 return readers .get (
858820 entity_type , lambda ** kwargs : self .unknown_type ({"type" : entity_type })
@@ -1872,7 +1834,7 @@ def prepare_export(
18721834 filters = relationships_from_filter
18731835 )
18741836 if len (x ) > 0 :
1875- entity ["sighting_of_ref" ] = entity ["from" ]["id " ]
1837+ entity ["sighting_of_ref" ] = entity ["from" ]["standard_id " ]
18761838 # handle from and to separately like Stix Core Relationship and call 2 requests
18771839 objects_to_get .append (
18781840 entity ["from" ]
@@ -1886,7 +1848,7 @@ def prepare_export(
18861848 filters = relationships_to_filter
18871849 )
18881850 if len (y ) > 0 :
1889- entity ["where_sighted_refs" ] = [entity ["to" ]["id " ]]
1851+ entity ["where_sighted_refs" ] = [entity ["to" ]["standard_id " ]]
18901852 objects_to_get .append (entity ["to" ])
18911853
18921854 del entity ["from" ]
@@ -1903,7 +1865,7 @@ def prepare_export(
19031865 filters = relationships_from_filter
19041866 )
19051867 if len (x ) > 0 :
1906- entity ["source_ref" ] = entity ["from" ]["id " ]
1868+ entity ["source_ref" ] = entity ["from" ]["standard_id " ]
19071869 # handle from and to separately like Stix Core Relationship and call 2 requests
19081870 objects_to_get .append (
19091871 entity ["from" ]
@@ -1918,7 +1880,7 @@ def prepare_export(
19181880 filters = relationships_to_filter
19191881 )
19201882 if len (y ) > 0 :
1921- entity ["target_ref" ] = entity ["to" ]["id " ]
1883+ entity ["target_ref" ] = entity ["to" ]["standard_id " ]
19221884 objects_to_get .append (entity ["to" ])
19231885 del entity ["to" ]
19241886 # Stix Domain Object
@@ -2095,32 +2057,14 @@ def prepare_export(
20952057
20962058 if no_custom_attributes :
20972059 del entity ["x_opencti_id" ]
2098- # Export
2099- reader = self .get_readers ()
21002060 # Get extra objects
21012061 for entity_object in objects_to_get :
2102- # Map types
2103- if entity_object ["entity_type" ] == "StixFile" :
2104- entity_object ["entity_type" ] = "File"
2105-
2106- if IdentityTypes .has_value (entity_object ["entity_type" ]):
2107- entity_object ["entity_type" ] = "Identity"
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 )
21242068 query_filters = self .prepare_id_filters_export (
21252069 entity_object ["id" ], access_filter
21262070 )
@@ -2225,20 +2169,7 @@ def get_stix_bundle_or_object_from_entity_id(
22252169 "id" : "bundle--" + str (uuid .uuid4 ()),
22262170 "objects" : [],
22272171 }
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 )
22422173 entity = do_read (id = entity_id )
22432174 if entity is None :
22442175 self .opencti .app_logger .error (
0 commit comments