<s> import stix <EOL> import stix . bindings . ttp as ttp_binding <EOL> from stix . common import vocabs , Statement <EOL> from stix . common . kill_chains import KillChainPhasesReference <EOL> from stix . common . related import RelatedPackageRefs <EOL> from . behavior import Behavior <EOL> from . resource import Resource <EOL> from . victim_targeting import VictimTargeting <EOL> class TTP ( stix . BaseCoreComponent ) : <EOL> """<STR_LIT>""" <EOL> _binding = ttp_binding <EOL> _binding_class = _binding . TTPType <EOL> _namespace = "<STR_LIT>" <EOL> _version = "<STR_LIT>" <EOL> _ALL_VERSIONS = ( "<STR_LIT:1.0>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> _ID_PREFIX = "<STR_LIT>" <EOL> def __init__ ( self , id_ = None , idref = None , timestamp = None , title = None , <EOL> description = None , short_description = None ) : <EOL> super ( TTP , self ) . __init__ ( <EOL> id_ = id_ , <EOL> idref = idref , <EOL> timestamp = timestamp , <EOL> title = title , <EOL> description = description , <EOL> short_description = short_description <EOL> ) <EOL> self . behavior = None <EOL> self . related_ttps = None <EOL> self . intended_effects = None <EOL> self . resources = None <EOL> self . victim_targeting = None <EOL> self . exploit_targets = ExploitTargets ( ) <EOL> self . related_packages = None <EOL> self . kill_chain_phases = None <EOL> @ property <EOL> def behavior ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _behavior <EOL> @ behavior . setter <EOL> def behavior ( self , value ) : <EOL> self . _set_var ( Behavior , try_cast = False , behavior = value ) <EOL> @ property <EOL> def related_ttps ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _related_ttps <EOL> @ related_ttps . setter <EOL> def related_ttps ( self , value ) : <EOL> if isinstance ( value , RelatedTTPs ) : <EOL> self . _related_ttps = value <EOL> else : <EOL> self . _related_ttps = RelatedTTPs ( value ) <EOL> def add_related_ttp ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . related_ttps . append ( value ) <EOL> @ property <EOL> def exploit_targets ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _exploit_targets <EOL> @ exploit_targets . setter <EOL> def exploit_targets ( self , value ) : <EOL> if isinstance ( value , ExploitTargets ) : <EOL> self . _exploit_targets = value <EOL> else : <EOL> self . _exploit_targets = ExploitTargets ( value ) <EOL> def add_exploit_target ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . exploit_targets . append ( value ) <EOL> @ property <EOL> def intended_effects ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _intended_effects <EOL> @ intended_effects . setter <EOL> def intended_effects ( self , value ) : <EOL> self . _intended_effects = _IntendedEffects ( value ) <EOL> def add_intended_effect ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . intended_effects . append ( value ) <EOL> @ property <EOL> def resources ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _resources <EOL> @ resources . setter <EOL> def resources ( self , value ) : <EOL> self . _set_var ( Resource , resources = value ) <EOL> @ property <EOL> def victim_targeting ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _victim_targeting <EOL> @ victim_targeting . setter <EOL> def victim_targeting ( self , value ) : <EOL> self . _set_var ( VictimTargeting , try_cast = False , victim_targeting = value ) <EOL> @ property <EOL> def kill_chain_phases ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _kill_chain_phases <EOL> @ kill_chain_phases . setter <EOL> def kill_chain_phases ( self , value ) : <EOL> self . _kill_chain_phases = KillChainPhasesReference ( value ) <EOL> def add_kill_chain_phase ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . kill_chain_phases . append ( value ) <EOL> @ property <EOL> def related_packages ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _related_packages <EOL> @ related_packages . setter <EOL> def related_packages ( self , value ) : <EOL> self . _related_packages = RelatedPackageRefs ( value ) <EOL> def add_related_package ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . related_packages . append ( value ) <EOL> def to_obj ( self , return_obj = None , ns_info = None ) : <EOL> if not return_obj : <EOL> return_obj = self . _binding_class ( ) <EOL> super ( TTP , self ) . to_obj ( return_obj = return_obj , ns_info = ns_info ) <EOL> if self . behavior : <EOL> return_obj . Behavior = self . behavior . to_obj ( ns_info = ns_info ) <EOL> if self . related_ttps : <EOL> return_obj . Related_TTPs = self . related_ttps . to_obj ( ns_info = ns_info ) <EOL> if self . exploit_targets : <EOL> return_obj . Exploit_Targets = self . exploit_targets . to_obj ( ns_info = ns_info ) <EOL> if self . intended_effects : <EOL> return_obj . Intended_Effect = self . intended_effects . to_obj ( ns_info = ns_info ) <EOL> if self . resources : <EOL> return_obj . Resources = self . resources . to_obj ( ns_info = ns_info ) <EOL> if self . victim_targeting : <EOL> return_obj . Victim_Targeting = self . victim_targeting . to_obj ( ns_info = ns_info ) <EOL> if self . kill_chain_phases : <EOL> return_obj . Kill_Chain_Phases = self . kill_chain_phases . to_obj ( ns_info = ns_info ) <EOL> if self . related_packages : <EOL> return_obj . Related_Packages = self . related_packages . to_obj ( ns_info = ns_info ) <EOL> return return_obj <EOL> @ classmethod <EOL> def from_obj ( cls , obj , return_obj = None ) : <EOL> if not obj : <EOL> return None <EOL> if not return_obj : <EOL> return_obj = cls ( ) <EOL> super ( TTP , cls ) . from_obj ( obj , return_obj = return_obj ) <EOL> if isinstance ( obj , cls . _binding_class ) : <EOL> return_obj . behavior = Behavior . from_obj ( obj . Behavior ) <EOL> return_obj . related_ttps = RelatedTTPs . from_obj ( obj . Related_TTPs ) <EOL> return_obj . exploit_targets = ExploitTargets . from_obj ( obj . Exploit_Targets ) <EOL> return_obj . resources = Resource . from_obj ( obj . Resources ) <EOL> return_obj . victim_targeting = VictimTargeting . from_obj ( obj . Victim_Targeting ) <EOL> return_obj . intended_effects = _IntendedEffects . from_obj ( obj . Intended_Effect ) <EOL> return_obj . kill_chain_phases = KillChainPhasesReference . from_obj ( obj . Kill_Chain_Phases ) <EOL> return_obj . related_packages = RelatedPackageRefs . from_obj ( obj . Related_Packages ) <EOL> return return_obj <EOL> def to_dict ( self ) : <EOL> return super ( TTP , self ) . to_dict ( ) <EOL> @ classmethod <EOL> def from_dict ( cls , dict_repr , return_obj = None ) : <EOL> if not dict_repr : <EOL> return None <EOL> if not return_obj : <EOL> return_obj = cls ( ) <EOL> super ( TTP , cls ) . from_dict ( dict_repr , return_obj = return_obj ) <EOL> get = dict_repr . get <EOL> return_obj . behavior = Behavior . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return_obj . related_ttps = RelatedTTPs . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return_obj . exploit_targets = ExploitTargets . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return_obj . intended_effects = _IntendedEffects . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return_obj . resources = Resource . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return_obj . victim_targeting = VictimTargeting . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return_obj . related_packages = RelatedPackageRefs . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return_obj . kill_chain_phases = KillChainPhasesReference . from_dict ( get ( '<STR_LIT>' ) ) <EOL> return return_obj <EOL> class _IntendedEffects ( stix . TypedList ) : <EOL> _contained_type = Statement <EOL> def _fix_value ( self , value ) : <EOL> intended_effect = vocabs . IntendedEffect ( value ) <EOL> return Statement ( value = intended_effect ) <EOL> from . related_ttps import RelatedTTPs <EOL> from . exploit_targets import ExploitTargets </s>
