1616from .vulnerability import Vulnerability , _Vulnerabilities # noqa
1717from .weakness import Weakness , _Weaknesses # noqa
1818from .configuration import Configuration , _Configurations # noqa
19-
19+ from stix . common import InformationSource
2020
2121class ExploitTarget (stix .BaseCoreComponent ):
2222 """Implementation of STIX Exploit Target.
@@ -41,6 +41,14 @@ class ExploitTarget(stix.BaseCoreComponent):
4141 _ALL_VERSIONS = ("1.0" , "1.0.1" , "1.1" , "1.1.1" , "1.2" )
4242 _ID_PREFIX = 'et'
4343
44+ potential_coas = fields .TypedField ("Potential_COAs" , type_ = "stix.exploit_target.PotentialCOAs" )
45+ related_exploit_targets = fields .TypedField ("Related_Exploit_Targets" , type_ = "stix.exploit_target.RelatedExploitTargets" )
46+ vulnerabilities = fields .TypedField ("Vulnerability" , Vulnerability , multiple = True , key_name = "vulnerabilities" )
47+ weaknesses = fields .TypedField ("Weakness" , Weakness , multiple = True , key_name = "weaknesses" )
48+ configuration = fields .TypedField ("Configuration" , Configuration , multiple = True )
49+ related_packages = fields .TypedField ("Related_Packages" , RelatedPackageRefs )
50+ information_source = fields .TypedField ("Information_Source" , InformationSource )
51+
4452 def __init__ (self , id_ = None , idref = None , timestamp = None , title = None ,
4553 description = None , short_description = None ):
4654
@@ -55,32 +63,7 @@ def __init__(self, id_=None, idref=None, timestamp=None, title=None,
5563
5664 self .potential_coas = PotentialCOAs ()
5765 self .related_exploit_targets = RelatedExploitTargets ()
58- self .vulnerabilities = None
59- self .weaknesses = None
60- self .configuration = None
6166 self .related_packages = RelatedPackageRefs ()
62-
63- @property
64- def vulnerabilities (self ):
65- """A collection of :class:`.Vulnerability` objects. This behaves like
66- a ``MutableSequence`` type.
67-
68- Default Value: ``None``
69-
70- Returns:
71- A list of :class:`.Vulnerability`
72-
73- Raises:
74- ValueError: If set to a value that is not ``None`` and not an
75- instance of :class:`.Vulnerability`
76-
77- """
78-
79- return self ._vulnerabilities
80-
81- @vulnerabilities .setter
82- def vulnerabilities (self , value ):
83- self ._vulnerabilities = _Vulnerabilities (value )
8467
8568 def add_vulnerability (self , value ):
8669 """Adds a vulnerability to the :attr:`vulnerabilities` list property.
@@ -95,29 +78,7 @@ def add_vulnerability(self, value):
9578 ValueError: if the `value` param is of type :class:`.Vulnerability`
9679
9780 """
98- self .vulnerabilities .append (value )
99-
100- @property
101- def weaknesses (self ):
102- """A collection of :class:`.Weakness` objects. This behaves like
103- a ``MutableSequence`` type.
104-
105- Default Value: ``None``
106-
107- Returns:
108- A list of :class:`.Weakness` objects.
109-
110- Raises:
111- ValueError: If set to a value that is not ``None`` and not an
112- instance of :class:`.Weakness`
113-
114- """
115- return self ._weaknesses
116-
117- @weaknesses .setter
118- def weaknesses (self , value ):
119- self ._weaknesses = _Weaknesses (value )
120-
81+ self .vul
12182 def add_weakness (self , value ):
12283 """Adds a weakness to the :attr:`weaknesses` list property.
12384
@@ -131,28 +92,6 @@ def add_weakness(self, value):
13192
13293 """
13394 self .weaknesses .append (value )
134-
135- @property
136- def configuration (self ):
137- """A list of :class:`.Configuration` objects. This behaves like
138- a ``MutableSequence`` type.
139-
140- Default Value: ``None``
141-
142- Returns:
143- A list of :class:`.Configuration` objects.
144-
145- Raises:
146- ValueError: If set to a value that is not ``None`` and not an
147- instance of :class:`.Configuration`.
148-
149- """
150-
151- return self ._configuration
152-
153- @configuration .setter
154- def configuration (self , value ):
155- self ._configuration = _Configurations (value )
15695
15796 def add_configuration (self , value ):
15897 """Adds a configuration to the :attr:`configurations` list property.
@@ -168,71 +107,7 @@ def add_configuration(self, value):
168107
169108 """
170109 self .configuration .append (value )
171- """
172- def to_obj(self, return_obj=None, ns_info=None):
173- if not return_obj:
174- return_obj = self._binding_class()
175-
176- super(ExploitTarget, self).to_obj(return_obj=return_obj, ns_info=ns_info)
177-
178- if self.potential_coas:
179- return_obj.Potential_COAs = self.potential_coas.to_obj(ns_info=ns_info)
180- if self.related_exploit_targets:
181- return_obj.Related_Exploit_Targets = self.related_exploit_targets.to_obj(ns_info=ns_info)
182- if self.vulnerabilities:
183- return_obj.Vulnerability = self.vulnerabilities.to_obj(ns_info=ns_info)
184- if self.weaknesses:
185- return_obj.Weakness = self.weaknesses.to_obj(ns_info=ns_info)
186- if self.configuration:
187- return_obj.Configuration = self.configuration.to_obj(ns_info=ns_info)
188- if self.related_packages:
189- return_obj.Related_Packages = self.related_packages.to_obj(ns_info=ns_info)
190-
191- return return_obj
192-
193- @classmethod
194- def from_obj(cls, obj, return_obj=None):
195- if not obj:
196- return None
197-
198- if not return_obj:
199- return_obj = cls()
200-
201- super(ExploitTarget, cls).from_obj(obj, return_obj=return_obj)
202-
203- if isinstance(obj, cls._binding_class):
204- return_obj.potential_coas = PotentialCOAs.from_obj(obj.Potential_COAs)
205- return_obj.related_exploit_targets = RelatedExploitTargets.from_obj(obj.Related_Exploit_Targets)
206- return_obj.vulnerabilities = _Vulnerabilities.from_obj(obj.Vulnerability)
207- return_obj.weaknesses = _Weaknesses.from_obj(obj.Weakness)
208- return_obj.configuration = _Configurations.from_obj(obj.Configuration)
209- return_obj.related_packages = RelatedPackageRefs.from_obj(obj.Related_Packages)
210-
211- return return_obj
212-
213- def to_dict(self):
214- return super(ExploitTarget, self).to_dict()
215-
216- @classmethod
217- def from_dict(cls, dict_repr, return_obj=None):
218- if not dict_repr:
219- return None
220-
221- if not return_obj:
222- return_obj = cls()
223-
224- super(ExploitTarget, cls).from_dict(dict_repr, return_obj=return_obj)
225110
226- get = dict_repr.get
227- return_obj.potential_coas = PotentialCOAs.from_dict(get('potential_coas'))
228- return_obj.related_exploit_targets = RelatedExploitTargets.from_dict(get('related_exploit_targets'))
229- return_obj.vulnerabilities = _Vulnerabilities.from_dict(get('vulnerabilities'))
230- return_obj.weaknesses = _Weaknesses.from_dict(get('weaknesses'))
231- return_obj.configuration = _Configurations.from_dict(get('configuration'))
232- return_obj.related_packages = RelatedPackageRefs.from_dict(get('related_packages'))
233-
234- return return_obj
235- """
236111
237112class PotentialCOAs (GenericRelationshipList ):
238113 """
0 commit comments