@@ -121,6 +121,42 @@ def _add_object_ids_flag(event):
121121 for misp_object in event ['Object' ]:
122122 misp_object ['Attribute' ][0 ]['to_ids' ] = True
123123
124+ def _check_account_indicator_objects (self , misp_objects , patterns ):
125+ gitlab_object , telegram_object = misp_objects
126+ gitlab_pattern , telegram_pattern = patterns
127+ gitlab_id = gitlab_object .attributes [0 ].value
128+ account_type , user_id = gitlab_pattern [1 :- 1 ].split (' AND ' )
129+ self .assertEqual (account_type , f"user-account:account_type = 'gitlab'" )
130+ self .assertEqual (user_id , f"user-account:user_id = '{ gitlab_id } '" )
131+ telegram_id = telegram_object .attributes [0 ].value
132+ account_type , user_id = telegram_pattern [1 :- 1 ].split (' AND ' )
133+ self .assertEqual (account_type , "user-account:account_type = 'telegram'" )
134+ self .assertEqual (user_id , f"user-account:user_id = '{ telegram_id } '" )
135+
136+ def _check_account_with_attachment_indicator_objects (self , misp_objects , patterns ):
137+ facebook_account , github_user , parler_account , reddit_account , twitter_account = misp_objects
138+ facebook_pattern , github_pattern , parler_pattern , reddit_pattern , twitter_pattern = patterns
139+ account_id = facebook_account .attributes [0 ].value
140+ account_type , user_id = facebook_pattern [1 :- 1 ].split (' AND ' )
141+ self .assertEqual (account_type , f"user-account:account_type = 'facebook'" )
142+ self .assertEqual (user_id , f"user-account:user_id = '{ account_id } '" )
143+ github_id = github_user .attributes [0 ].value
144+ account_type , user_id = github_pattern [1 :- 1 ].split (' AND ' )
145+ self .assertEqual (account_type , "user-account:account_type = 'github'" )
146+ self .assertEqual (user_id , f"user-account:user_id = '{ github_id } '" )
147+ parler_id = parler_account .attributes [0 ].value
148+ account_type , user_id = parler_pattern [1 :- 1 ].split (' AND ' )
149+ self .assertEqual (account_type , f"user-account:account_type = 'parler'" )
150+ self .assertEqual (user_id , f"user-account:user_id = '{ parler_id } '" )
151+ reddit_id = reddit_account .attributes [0 ].value
152+ account_type , user_id = reddit_pattern [1 :- 1 ].split (' AND ' )
153+ self .assertEqual (account_type , f"user-account:account_type = 'reddit'" )
154+ self .assertEqual (user_id , f"user-account:user_id = '{ reddit_id } '" )
155+ _id = twitter_account .attributes [0 ].value
156+ account_type , user_id = twitter_pattern [1 :- 1 ].split (' AND ' )
157+ self .assertEqual (account_type , f"user-account:account_type = 'twitter'" )
158+ self .assertEqual (user_id , f"user-account:user_id = '{ _id } '" )
159+
124160 def _check_attack_pattern_meta_fields (self , stix_object , meta ):
125161 external_ref , * external_refs = stix_object .external_references
126162 self .assertEqual (external_ref .external_id , meta ['external_id' ])
@@ -459,9 +495,7 @@ def _check_object_observable_features(self, observed_data, misp_object, identity
459495
460496 def _check_object_vulnerability_features (self , vulnerability , misp_object , identity_id , object_ref ):
461497 self ._assert_multiple_equal (
462- vulnerability .id ,
463- f"vulnerability--{ misp_object ['uuid' ]} " ,
464- object_ref
498+ vulnerability .id , f"vulnerability--{ misp_object ['uuid' ]} " , object_ref
465499 )
466500 self .assertEqual (vulnerability .type , 'vulnerability' )
467501 self .assertEqual (vulnerability .created_by_ref , identity_id )
@@ -470,7 +504,9 @@ def _check_object_vulnerability_features(self, vulnerability, misp_object, ident
470504 if not isinstance (timestamp , datetime ):
471505 timestamp = self ._datetime_from_timestamp (timestamp )
472506 self .assertEqual (vulnerability .modified , timestamp )
473- cve , cvss , summary , created , published , references1 , references2 = (attribute ['value' ] for attribute in misp_object ['Attribute' ])
507+ cve , cvss , summary , created , published , references1 , references2 = (
508+ attribute .value for attribute in misp_object .attributes
509+ )
474510 self .assertEqual (vulnerability .name , cve )
475511 self .assertEqual (vulnerability .description , summary )
476512 timestamp = misp_object ['timestamp' ]
@@ -858,6 +894,7 @@ def _populate_objects_documentation(self, misp_object, name=None, summary=None,
858894 return
859895 self ._objects_v20 [name ]['STIX' ] = json .loads (stix_objects .serialize ())
860896
897+
861898class TestSTIX21Export (TestSTIX2Export ):
862899 _attributes_v21 = defaultdict (lambda : defaultdict (dict ))
863900 _objects_v21 = defaultdict (lambda : defaultdict (dict ))
0 commit comments