Skip to content

Commit efafd8c

Browse files
author
Bryan Worrell
committed
Added support for Suggested_COAs on Indicator
1 parent a5d9b51 commit efafd8c

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

stix/indicator/indicator.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import stix.extensions.identity as ext_identity
1010
import stix.bindings.indicator as indicator_binding
1111
from .test_mechanism import _BaseTestMechanism
12+
from stix.common.related import GenericRelationshipList, RelatedCOA
1213
from cybox.core import Observable, ObservableComposition
1314
from cybox.common import Time
1415

@@ -36,6 +37,7 @@ def __init__(self, id_=None, idref=None, timestamp=None, title=None, description
3637
self.confidence = None
3738
self.indicated_ttps = None
3839
self.test_mechanisms = None
40+
self.suggested_coas = SuggestedCOAs()
3941

4042
@property
4143
def timestamp(self):
@@ -302,6 +304,8 @@ def to_obj(self, return_obj=None):
302304
tms_obj = self._binding.TestMechanismsType()
303305
tms_obj.set_Test_Mechanism([x.to_obj() for x in self.test_mechanisms])
304306
return_obj.set_Test_Mechanisms(tms_obj)
307+
if self.suggested_coas:
308+
return_obj.set_Suggested_COAs(self.suggested_coas.to_obj())
305309

306310
return return_obj
307311

@@ -334,7 +338,9 @@ def from_obj(cls, obj, return_obj=None):
334338
return_obj.indicated_ttps = [RelatedTTP.from_obj(x) for x in obj.get_Indicated_TTP()]
335339
if obj.get_Test_Mechanisms():
336340
return_obj.test_mechanisms = [_BaseTestMechanism.from_obj(x) for x in obj.get_Test_Mechanisms().get_Test_Mechanism()]
337-
341+
if obj.get_Suggested_COAs():
342+
return_obj.suggested_coas = SuggestedCOAs.from_obj(obj.get_Suggested_COAs())
343+
338344
return return_obj
339345

340346
def to_dict(self):
@@ -369,7 +375,9 @@ def to_dict(self):
369375
d['indicated_ttps'] = [x.to_dict() for x in self.indicated_ttps]
370376
if self.test_mechanisms:
371377
d['test_mechanisms'] = [x.to_dict() for x in self.test_mechanisms]
372-
378+
if self.suggested_coas:
379+
d['suggested_coas'] = self.suggested_coas.to_dict()
380+
373381
return d
374382

375383
@classmethod
@@ -393,6 +401,7 @@ def from_dict(cls, dict_repr, return_obj=None):
393401
return_obj.short_description = StructuredText.from_dict(dict_repr.get('short_description'))
394402
return_obj.indicated_ttps = [RelatedTTP.from_dict(x) for x in dict_repr.get('indicated_ttps', [])]
395403
return_obj.test_mechanisms = [_BaseTestMechanism.from_dict(x) for x in dict_repr.get('test_mechanisms', [])]
404+
return_obj.suggested_coas = SuggestedCOAs.from_dict(dict_repr.get('suggested_coas'))
396405

397406
if observable_dict:
398407
return_obj.add_observable(Observable.from_dict(observable_dict))
@@ -408,3 +417,16 @@ def from_dict(cls, dict_repr, return_obj=None):
408417

409418

410419
return return_obj
420+
421+
class SuggestedCOAs(GenericRelationshipList):
422+
_namespace = "http://stix.mitre.org/Indicator-2"
423+
_binding = indicator_binding
424+
_binding_class = indicator_binding.SuggestedCOAsType
425+
_binding_var = "Suggested_COA"
426+
_contained_type = RelatedCOA
427+
_inner_name = "suggested_coas"
428+
429+
def __init__(self, suggested_coas=None, scope=None):
430+
if suggested_coas is None:
431+
suggested_coas = []
432+
super(SuggestedCOAs, self).__init__(*suggested_coas, scope=scope)

0 commit comments

Comments
 (0)