33
44import stix
55import stix .utils
6- from stix .common import Identity , InformationSource , StructuredText
6+ from stix .common import Identity , InformationSource , StructuredText , VocabString
77import stix .extensions .identity as ext_identity
88import stix .bindings .indicator as indicator_binding
99from cybox .core import Observable , ObservableComposition
1010from cybox .common import Time
1111
12+
13+ class IndicatorType (VocabString ):
14+ _XSI_TYPE = 'stixVocabs:IndicatorTypeVocab-1.0'
15+
16+
1217class Indicator (stix .Entity ):
13- def __init__ (self , id_ = None , title = None , description = None , producer = None , observables = None ):
18+ def __init__ (self , id_ = None , title = None , description = None , indicator_type = None , producer = None , observables = None ):
1419 self .id_ = id_ if id_ is not None else stix .utils .create_id ()
1520 self .producer = producer
1621 self .observables = observables
1722 self .title = title
1823 self .description = description
24+ self .indicator_type = indicator_type
1925
2026 @property
2127 def description (self ):
@@ -54,6 +60,18 @@ def observables(self, valuelist):
5460 for value in valuelist :
5561 self .add_observable (value )
5662
63+ @property
64+ def indicator_type (self ):
65+ return self ._indicator_tye
66+
67+ @indicator_type .setter
68+ def indicator_type (self , value ):
69+ if value and not isinstance (value , IndicatorType ):
70+ value = IndicatorType (value )
71+
72+ self ._indicator_type = value
73+
74+
5775 def set_producer_identity (self , identity ):
5876 '''
5977 Sets the name of the producer of this indicator.
@@ -141,6 +159,9 @@ def to_obj(self, return_obj=None):
141159 if self .description :
142160 return_obj .set_Description (self .description .to_obj ())
143161
162+ if self .indicator_type :
163+ return_obj .set_Type (self .indicator_type .to_obj ())
164+
144165 return_obj .set_Title (self .title )
145166
146167 if self .observables :
@@ -164,10 +185,11 @@ def from_obj(cls, obj, return_obj=None):
164185 if not return_obj :
165186 return_obj = cls ()
166187
167- return_obj .id_ = obj .get_id ()
168- return_obj .title = obj .get_Title ()
169- return_obj .description = StructuredText .from_obj (obj .get_Description ())
170- return_obj .producer = InformationSource .from_obj (obj .get_Producer ())
188+ return_obj .id_ = obj .get_id ()
189+ return_obj .title = obj .get_Title ()
190+ return_obj .description = StructuredText .from_obj (obj .get_Description ())
191+ return_obj .producer = InformationSource .from_obj (obj .get_Producer ())
192+ return_obj .indicator_type = IndicatorType .from_obj (obj .get_Type ())
171193
172194 if obj .get_Observable ():
173195 observable_obj = obj .get_Observable ()
@@ -199,6 +221,9 @@ def to_dict(self, return_dict=None):
199221 if self .description :
200222 return_dict ['description' ] = self .description .to_dict ()
201223
224+ if self .indicator_type :
225+ return_dict ['indicator_type' ] = self .indicator_type .to_dict ()
226+
202227 return return_dict
203228
204229
@@ -215,6 +240,7 @@ def from_dict(cls, dict_repr, return_obj=None):
215240 observable_dict = dict_repr .get ('observable' )
216241 producer_dict = dict_repr .get ('producer' )
217242 description_dict = dict_repr .get ('description' )
243+ indicator_type_dict = dict_repr .get ('indicator_type' )
218244
219245 if observable_dict :
220246 return_obj .add_observable (Observable .from_dict (observable_dict ))
@@ -225,8 +251,11 @@ def from_dict(cls, dict_repr, return_obj=None):
225251 if description_dict :
226252 return_obj .description = StructuredText .from_dict (description_dict )
227253
254+ if indicator_type_dict :
255+ return_obj .indicator_type = IndicatorType .from_dict (indicator_type_dict )
256+
228257 return return_obj
229258
230259
231-
260+
232261
0 commit comments