Skip to content

Commit 89ebdf7

Browse files
committed
fix: [tests] Updated tests following implementation changes on the STIX object labels generation
1 parent 663d9b4 commit 89ebdf7

10 files changed

+45
-92
lines changed

tests/_test_stix_export.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _check_attack_pattern_object(self, attack_pattern, misp_object, identity_id)
172172
self.assertEqual(attack_pattern.type, 'attack-pattern')
173173
self.assertEqual(attack_pattern.created_by_ref, identity_id)
174174
self._check_killchain(attack_pattern.kill_chain_phases[0], misp_object['meta-category'])
175-
self._check_object_labels(misp_object, attack_pattern.labels, to_ids=False)
175+
self._check_object_labels(misp_object, attack_pattern.labels)
176176
timestamp = misp_object['timestamp']
177177
if not isinstance(timestamp, datetime):
178178
timestamp = self._datetime_from_timestamp(timestamp)
@@ -212,11 +212,7 @@ def _check_attribute_indicator_features(self, indicator, attribute, identity_id,
212212
self._check_indicator_time_features(indicator, attribute['timestamp'])
213213

214214
def _check_attribute_labels(self, attribute, labels):
215-
if attribute.get('to_ids'):
216-
type_label, category_label, ids_label = labels
217-
self.assertEqual(ids_label, f'misp:to_ids="{attribute["to_ids"]}"')
218-
else:
219-
type_label, category_label = labels
215+
type_label, category_label = labels
220216
self.assertEqual(type_label, f'misp:type="{attribute["type"]}"')
221217
self.assertEqual(category_label, f'misp:category="{attribute["category"]}"')
222218

@@ -564,21 +560,17 @@ def _check_malware_meta_fields(self, stix_object, meta):
564560
def _check_object_indicator_features(self, indicator, misp_object, identity_id, object_ref):
565561
self._check_indicator_features(indicator, identity_id, object_ref, misp_object['uuid'])
566562
self._check_killchain(indicator.kill_chain_phases[0], misp_object['meta-category'])
567-
self._check_object_labels(misp_object, indicator.labels, to_ids=True)
563+
self._check_object_labels(misp_object, indicator.labels)
568564
self._check_indicator_time_features(indicator, misp_object['timestamp'])
569565

570-
def _check_object_labels(self, misp_object, labels, to_ids=None):
571-
if to_ids is not None:
572-
name_label, category_label, ids_label = labels
573-
self.assertEqual(ids_label, f'misp:to_ids="{to_ids}"')
574-
else:
575-
name_label, category_label = labels
566+
def _check_object_labels(self, misp_object, labels):
567+
name_label, category_label = labels
576568
self.assertEqual(name_label, f'misp:name="{misp_object["name"]}"')
577569
self.assertEqual(category_label, f'misp:meta-category="{misp_object["meta-category"]}"')
578570

579571
def _check_object_observable_features(self, observed_data, misp_object, identity_id, object_ref):
580572
self._check_observable_features(observed_data, identity_id, object_ref, misp_object['uuid'])
581-
self._check_object_labels(misp_object, observed_data.labels, to_ids=False)
573+
self._check_object_labels(misp_object, observed_data.labels)
582574
self._check_observable_time_features(observed_data, misp_object['timestamp'])
583575

584576
def _check_object_vulnerability_features(self, vulnerability, misp_object, identity_id, object_ref):
@@ -587,7 +579,7 @@ def _check_object_vulnerability_features(self, vulnerability, misp_object, ident
587579
)
588580
self.assertEqual(vulnerability.type, 'vulnerability')
589581
self.assertEqual(vulnerability.created_by_ref, identity_id)
590-
self._check_object_labels(misp_object, vulnerability.labels, to_ids=False)
582+
self._check_object_labels(misp_object, vulnerability.labels)
591583
timestamp = misp_object['timestamp']
592584
if not isinstance(timestamp, datetime):
593585
timestamp = self._datetime_from_timestamp(timestamp)
@@ -883,7 +875,7 @@ def _remove_object_ids_flags(event):
883875
def _run_custom_attribute_tests(self, attribute, custom_object, object_ref, identity_id):
884876
attribute_type = attribute['type']
885877
category = attribute['category']
886-
custom_type = f"x-misp-attribute"
878+
custom_type = 'x-misp-attribute'
887879
self.assertEqual(custom_object.type, custom_type)
888880
self._assert_multiple_equal(
889881
custom_object.id,
@@ -893,8 +885,6 @@ def _run_custom_attribute_tests(self, attribute, custom_object, object_ref, iden
893885
self.assertEqual(custom_object.created_by_ref, identity_id)
894886
self.assertEqual(custom_object.labels[0], f'misp:type="{attribute_type}"')
895887
self.assertEqual(custom_object.labels[1], f'misp:category="{category}"')
896-
if attribute.get('to_ids', False):
897-
self.assertEqual(custom_object.labels[2], 'misp:to_ids="True"')
898888
self.assertEqual(custom_object.x_misp_type, attribute_type)
899889
self.assertEqual(custom_object.x_misp_category, category)
900890
if attribute.get('comment'):

tests/test_attributes_collection_stix20.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
},
4949
"labels": [
5050
"misp:type=\"domain\"",
51-
"misp:category=\"Network activity\"",
52-
"misp:to_ids=\"True\""
51+
"misp:category=\"Network activity\""
5352
]
5453
},
5554
{
@@ -69,8 +68,7 @@
6968
],
7069
"labels": [
7170
"misp:type=\"domain\"",
72-
"misp:category=\"Network activity\"",
73-
"misp:to_ids=\"True\""
71+
"misp:category=\"Network activity\""
7472
]
7573
},
7674
{
@@ -106,8 +104,7 @@
106104
},
107105
"labels": [
108106
"misp:type=\"domain|ip\"",
109-
"misp:category=\"Network activity\"",
110-
"misp:to_ids=\"True\""
107+
"misp:category=\"Network activity\""
111108
]
112109
},
113110
{
@@ -127,8 +124,7 @@
127124
],
128125
"labels": [
129126
"misp:type=\"domain|ip\"",
130-
"misp:category=\"Network activity\"",
131-
"misp:to_ids=\"True\""
127+
"misp:category=\"Network activity\""
132128
]
133129
},
134130
{
@@ -148,8 +144,7 @@
148144
},
149145
"labels": [
150146
"misp:type=\"filename\"",
151-
"misp:category=\"Payload delivery\"",
152-
"misp:to_ids=\"True\""
147+
"misp:category=\"Payload delivery\""
153148
]
154149
},
155150
{
@@ -169,8 +164,7 @@
169164
],
170165
"labels": [
171166
"misp:type=\"filename\"",
172-
"misp:category=\"Payload delivery\"",
173-
"misp:to_ids=\"True\""
167+
"misp:category=\"Payload delivery\""
174168
]
175169
},
176170
{

tests/test_attributes_collection_stix21.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
],
5151
"labels": [
5252
"misp:type=\"domain\"",
53-
"misp:category=\"Network activity\"",
54-
"misp:to_ids=\"True\""
53+
"misp:category=\"Network activity\""
5554
]
5655
},
5756
{
@@ -80,8 +79,7 @@
8079
],
8180
"labels": [
8281
"misp:type=\"domain\"",
83-
"misp:category=\"Network activity\"",
84-
"misp:to_ids=\"True\""
82+
"misp:category=\"Network activity\""
8583
]
8684
},
8785
{
@@ -110,8 +108,7 @@
110108
],
111109
"labels": [
112110
"misp:type=\"domain|ip\"",
113-
"misp:category=\"Network activity\"",
114-
"misp:to_ids=\"True\""
111+
"misp:category=\"Network activity\""
115112
]
116113
},
117114
{
@@ -149,8 +146,7 @@
149146
],
150147
"labels": [
151148
"misp:type=\"domain|ip\"",
152-
"misp:category=\"Network activity\"",
153-
"misp:to_ids=\"True\""
149+
"misp:category=\"Network activity\""
154150
]
155151
},
156152
{
@@ -168,8 +164,7 @@
168164
],
169165
"labels": [
170166
"misp:type=\"filename\"",
171-
"misp:category=\"Payload delivery\"",
172-
"misp:to_ids=\"True\""
167+
"misp:category=\"Payload delivery\""
173168
]
174169
},
175170
{
@@ -198,8 +193,7 @@
198193
],
199194
"labels": [
200195
"misp:type=\"filename\"",
201-
"misp:category=\"Payload delivery\"",
202-
"misp:to_ids=\"True\""
196+
"misp:category=\"Payload delivery\""
203197
]
204198
},
205199
{

tests/test_event1_stix20.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@
8282
},
8383
"labels": [
8484
"misp:type=\"domain\"",
85-
"misp:category=\"Network activity\"",
86-
"misp:to_ids=\"True\""
85+
"misp:category=\"Network activity\""
8786
]
8887
},
8988
{
@@ -103,8 +102,7 @@
103102
],
104103
"labels": [
105104
"misp:type=\"domain\"",
106-
"misp:category=\"Network activity\"",
107-
"misp:to_ids=\"True\""
105+
"misp:category=\"Network activity\""
108106
]
109107
},
110108
{

tests/test_event1_stix21.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@
8888
],
8989
"labels": [
9090
"misp:type=\"domain\"",
91-
"misp:category=\"Network activity\"",
92-
"misp:to_ids=\"True\""
91+
"misp:category=\"Network activity\""
9392
]
9493
},
9594
{
@@ -118,8 +117,7 @@
118117
],
119118
"labels": [
120119
"misp:type=\"domain\"",
121-
"misp:category=\"Network activity\"",
122-
"misp:to_ids=\"True\""
120+
"misp:category=\"Network activity\""
123121
]
124122
},
125123
{

tests/test_event2_stix20.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@
5353
},
5454
"labels": [
5555
"misp:type=\"domain|ip\"",
56-
"misp:category=\"Network activity\"",
57-
"misp:to_ids=\"True\""
56+
"misp:category=\"Network activity\""
5857
]
5958
},
6059
{
@@ -74,8 +73,8 @@
7473
],
7574
"labels": [
7675
"misp:type=\"domain|ip\"",
77-
"misp:category=\"Network activity\"",
78-
"misp:to_ids=\"True\""
76+
"misp:category=\"Network activity\""
77+
7978
]
8079
},
8180
{
@@ -122,8 +121,7 @@
122121
},
123122
"labels": [
124123
"misp:type=\"filename\"",
125-
"misp:category=\"Payload delivery\"",
126-
"misp:to_ids=\"True\""
124+
"misp:category=\"Payload delivery\""
127125
]
128126
},
129127
{
@@ -143,8 +141,7 @@
143141
],
144142
"labels": [
145143
"misp:type=\"filename\"",
146-
"misp:category=\"Payload delivery\"",
147-
"misp:to_ids=\"True\""
144+
"misp:category=\"Payload delivery\""
148145
]
149146
},
150147
{

tests/test_event2_stix21.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
],
4949
"labels": [
5050
"misp:type=\"domain|ip\"",
51-
"misp:category=\"Network activity\"",
52-
"misp:to_ids=\"True\""
51+
"misp:category=\"Network activity\""
5352
]
5453
},
5554
{
@@ -87,8 +86,7 @@
8786
],
8887
"labels": [
8988
"misp:type=\"domain|ip\"",
90-
"misp:category=\"Network activity\"",
91-
"misp:to_ids=\"True\""
89+
"misp:category=\"Network activity\""
9290
]
9391
},
9492
{
@@ -136,8 +134,7 @@
136134
],
137135
"labels": [
138136
"misp:type=\"filename\"",
139-
"misp:category=\"Payload delivery\"",
140-
"misp:to_ids=\"True\""
137+
"misp:category=\"Payload delivery\""
141138
]
142139
},
143140
{
@@ -166,8 +163,7 @@
166163
],
167164
"labels": [
168165
"misp:type=\"filename\"",
169-
"misp:category=\"Payload delivery\"",
170-
"misp:to_ids=\"True\""
166+
"misp:category=\"Payload delivery\""
171167
]
172168
},
173169
{

tests/test_events_collection_stix20.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@
8282
},
8383
"labels": [
8484
"misp:type=\"domain\"",
85-
"misp:category=\"Network activity\"",
86-
"misp:to_ids=\"True\""
85+
"misp:category=\"Network activity\""
8786
]
8887
},
8988
{
@@ -103,8 +102,7 @@
103102
],
104103
"labels": [
105104
"misp:type=\"domain\"",
106-
"misp:category=\"Network activity\"",
107-
"misp:to_ids=\"True\""
105+
"misp:category=\"Network activity\""
108106
]
109107
},
110108
{
@@ -158,8 +156,7 @@
158156
},
159157
"labels": [
160158
"misp:type=\"domain|ip\"",
161-
"misp:category=\"Network activity\"",
162-
"misp:to_ids=\"True\""
159+
"misp:category=\"Network activity\""
163160
]
164161
},
165162
{
@@ -179,8 +176,7 @@
179176
],
180177
"labels": [
181178
"misp:type=\"domain|ip\"",
182-
"misp:category=\"Network activity\"",
183-
"misp:to_ids=\"True\""
179+
"misp:category=\"Network activity\""
184180
]
185181
},
186182
{
@@ -227,8 +223,7 @@
227223
},
228224
"labels": [
229225
"misp:type=\"filename\"",
230-
"misp:category=\"Payload delivery\"",
231-
"misp:to_ids=\"True\""
226+
"misp:category=\"Payload delivery\""
232227
]
233228
},
234229
{
@@ -248,8 +243,7 @@
248243
],
249244
"labels": [
250245
"misp:type=\"filename\"",
251-
"misp:category=\"Payload delivery\"",
252-
"misp:to_ids=\"True\""
246+
"misp:category=\"Payload delivery\""
253247
]
254248
},
255249
{

0 commit comments

Comments
 (0)