44import stix
55from stix .common import StructuredTextList
66import stix .bindings .exploit_target as exploit_target_binding
7+ from mixbox import fields , entities
78
8-
9- class Configuration (stix .Entity ):
9+ class Configuration (entities .Entity ):
1010 """Implementation of STIX ``Configuration``.
1111
1212 Args:
@@ -19,7 +19,12 @@ class Configuration(stix.Entity):
1919 _binding_class = _binding .ConfigurationType
2020 _namespace = "http://stix.mitre.org/ExploitTarget-1"
2121
22+ descriptions = fields .TypedField ("Description" , type_ = "stix.common.StructuredTextList" )
23+ short_descriptions = fields .TypedField ("Short_Description" , type_ = "stix.common.StructuredTextList" )
24+ cce_id = fields .TypedField ("CCE_ID" )
25+
2226 def __init__ (self , description = None , short_description = None , cce_id = None ):
27+ super (Configuration , self ).__init__ ()
2328 self .description = description
2429 self .short_description = short_description
2530 self .cce_id = cce_id
@@ -35,51 +40,18 @@ def description(self):
3540 the description with the lowest ordinality value.
3641
3742 Returns:
38- An instance of
39- :class:`.StructuredText`
40-
43+ An instance of :class:`.StructuredText`
4144 """
4245 return next (iter (self .descriptions ), None )
4346
4447 @description .setter
4548 def description (self , value ):
4649 self .descriptions = value
4750
48- @property
49- def descriptions (self ):
50- """A :class:`.StructuredTextList` object, containing descriptions about
51- the purpose or intent of this object.
52-
53- This is typically used for the purpose of providing multiple
54- descriptions with different classificaton markings.
55-
56- Iterating over this object will yield its contents sorted by their
57- ``ordinality`` value.
58-
59- Default Value: Empty :class:`.StructuredTextList` object.
60-
61- Note:
62- IF this is set to a value that is not an instance of
63- :class:`.StructuredText`, an effort will ne made to convert it.
64- If this is set to an iterable, any values contained that are not
65- an instance of :class:`.StructuredText` will be be converted.
66-
67- Returns:
68- An instance of
69- :class:`.StructuredTextList`
70-
71- """
72- return self ._description
73-
74- @descriptions .setter
75- def descriptions (self , value ):
76- self ._description = StructuredTextList (value )
77-
7851 def add_description (self , description ):
7952 """Adds a description to the ``descriptions`` collection.
8053
8154 This is the same as calling "foo.descriptions.add(bar)".
82-
8355 """
8456 self .descriptions .add (description )
8557
@@ -96,113 +68,20 @@ def short_description(self):
9668
9769 Returns:
9870 An instance of :class:`.StructuredText`
99-
10071 """
10172 return next (iter (self .short_descriptions ), None )
10273
10374 @short_description .setter
10475 def short_description (self , value ):
10576 self .short_descriptions = value
10677
107- @property
108- def short_descriptions (self ):
109- """A :class:`.StructuredTextList` object, containing short descriptions
110- about the purpose or intent of this object.
111-
112- This is typically used for the purpose of providing multiple
113- short descriptions with different classificaton markings.
114-
115- Iterating over this object will yield its contents sorted by their
116- ``ordinality`` value.
117-
118- Default Value: Empty :class:`.StructuredTextList` object.
119-
120- Note:
121- IF this is set to a value that is not an instance of
122- :class:`.StructuredText`, an effort will ne made to convert it.
123- If this is set to an iterable, any values contained that are not
124- an instance of :class:`.StructuredText` will be be converted.
125-
126- Returns:
127- An instance of :class:`.StructuredTextList`
128-
129- """
130- return self ._short_description
131-
132- @short_descriptions .setter
133- def short_descriptions (self , value ):
134- self ._short_description = StructuredTextList (value )
135-
13678 def add_short_description (self , description ):
13779 """Adds a description to the ``short_descriptions`` collection.
13880
13981 This is the same as calling "foo.short_descriptions.add(bar)".
140-
14182 """
14283 self .short_descriptions .add (description )
14384
144- @property
145- def cce_id (self ):
146- """Common Configuration Enumeration value for this :class:`Configuration`.
147-
148- Default Value: ``None``
149-
150- Returns:
151- A string representing the CCE ID
152- """
153- return self ._cce_id
154-
155- @cce_id .setter
156- def cce_id (self , value ):
157- self ._cce_id = value
158-
159- def to_obj (self , return_obj = None , ns_info = None ):
160- super (Configuration , self ).to_obj (return_obj = return_obj , ns_info = ns_info )
161-
162- if not return_obj :
163- return_obj = self ._binding_class ()
164-
165- if self .descriptions :
166- return_obj .Description = self .descriptions .to_obj (ns_info = ns_info )
167- if self .short_descriptions :
168- return_obj .Short_Description = self .short_descriptions .to_obj (ns_info = ns_info )
169- return_obj .CCE_ID = self .cce_id
170-
171- return return_obj
172-
173- @classmethod
174- def from_obj (cls , obj , return_obj = None ):
175- if not obj :
176- return None
177-
178- if not return_obj :
179- return_obj = cls ()
180-
181- return_obj .descriptions = StructuredTextList .from_obj (obj .Description )
182- return_obj .short_description = StructuredTextList .from_obj (obj .Short_Description )
183- return_obj .cce_id = obj .CCE_ID
184-
185- return return_obj
186-
187- def to_dict (self ):
188- return super (Configuration , self ).to_dict ()
189-
190- @classmethod
191- def from_dict (cls , dict_repr , return_obj = None ):
192- if not dict_repr :
193- return None
194-
195- if not return_obj :
196- return_obj = cls ()
197-
198- get = dict_repr .get
199- return_obj .descriptions = StructuredTextList .from_dict (get ('description' ))
200- return_obj .short_descriptions = StructuredTextList .from_dict (get ('short_description' ))
201- return_obj .cce_id = get ('cce_id' )
202-
203- return return_obj
204-
205-
20685# NOT AN ACTUAL STIX TYPE!
20786class _Configurations (stix .TypedList ):
20887 _contained_type = Configuration
0 commit comments