<s> import sys <EOL> from mixbox . binding_utils import * <EOL> from stix . bindings import register_extension <EOL> import stix . bindings . stix_common as stix_common_binding <EOL> import stix . bindings . data_marking as data_marking_binding <EOL> XML_NS = "<STR_LIT>" <EOL> class NamesType ( GeneratedsSuper ) : <EOL> subclass = None <EOL> superclass = None <EOL> def __init__ ( self , Name = None ) : <EOL> if Name is None : <EOL> self . Name = [ ] <EOL> else : <EOL> self . Name = Name <EOL> def factory ( * args_ , ** kwargs_ ) : <EOL> if NamesType . subclass : <EOL> return NamesType . subclass ( * args_ , ** kwargs_ ) <EOL> else : <EOL> return NamesType ( * args_ , ** kwargs_ ) <EOL> factory = staticmethod ( factory ) <EOL> def get_Name ( self ) : return self . Name <EOL> def set_Name ( self , Name ) : self . Name = Name <EOL> def add_Name ( self , value ) : self . Name . append ( value ) <EOL> def insert_Name ( self , index , value ) : self . Name [ index ] = value <EOL> def hasContent_ ( self ) : <EOL> if ( <EOL> self . Name <EOL> ) : <EOL> return True <EOL> else : <EOL> return False <EOL> def export ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , namespacedef_ = '<STR_LIT>' , pretty_print = True ) : <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , namespacedef_ and '<STR_LIT:U+0020>' + namespacedef_ or '<STR_LIT>' , ) ) <EOL> already_processed = set ( ) <EOL> self . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> if self . hasContent_ ( ) : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> self . exportChildren ( lwrite , level + <NUM_LIT:1> , nsmap , XML_NS , name_ , pretty_print = pretty_print ) <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , eol_ ) ) <EOL> else : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> def exportAttributes ( self , lwrite , level , already_processed , namespace_ = '<STR_LIT>' , name_ = '<STR_LIT>' ) : <EOL> pass <EOL> def exportChildren ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , fromsubclass_ = False , pretty_print = True ) : <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> for Name_ in self . Name : <EOL> Name_ . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT:Name>' , pretty_print = pretty_print ) <EOL> def build ( self , node ) : <EOL> already_processed = set ( ) <EOL> self . buildAttributes ( node , node . attrib , already_processed ) <EOL> for child in node : <EOL> nodeName_ = Tag_pattern_ . match ( child . tag ) . groups ( ) [ - <NUM_LIT:1> ] <EOL> self . buildChildren ( child , node , nodeName_ ) <EOL> def buildAttributes ( self , node , attrs , already_processed ) : <EOL> pass <EOL> def buildChildren ( self , child_ , node , nodeName_ , fromsubclass_ = False ) : <EOL> if nodeName_ == '<STR_LIT:Name>' : <EOL> obj_ = stix_common_binding . ControlledVocabularyStringType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . Name . append ( obj_ ) <EOL> class AssociatedCampaignsType ( stix_common_binding . GenericRelationshipListType ) : <EOL> subclass = None <EOL> superclass = stix_common_binding . GenericRelationshipListType <EOL> def __init__ ( self , scope = '<STR_LIT>' , Associated_Campaign = None ) : <EOL> super ( AssociatedCampaignsType , self ) . __init__ ( scope = scope ) <EOL> if Associated_Campaign is None : <EOL> self . Associated_Campaign = [ ] <EOL> else : <EOL> self . Associated_Campaign = Associated_Campaign <EOL> def factory ( * args_ , ** kwargs_ ) : <EOL> if AssociatedCampaignsType . subclass : <EOL> return AssociatedCampaignsType . subclass ( * args_ , ** kwargs_ ) <EOL> else : <EOL> return AssociatedCampaignsType ( * args_ , ** kwargs_ ) <EOL> factory = staticmethod ( factory ) <EOL> def get_Associated_Campaign ( self ) : return self . Associated_Campaign <EOL> def set_Associated_Campaign ( self , Associated_Campaign ) : self . Associated_Campaign = Associated_Campaign <EOL> def add_Associated_Campaign ( self , value ) : self . Associated_Campaign . append ( value ) <EOL> def insert_Associated_Campaign ( self , index , value ) : self . Associated_Campaign [ index ] = value <EOL> def hasContent_ ( self ) : <EOL> if ( <EOL> self . Associated_Campaign or <EOL> super ( AssociatedCampaignsType , self ) . hasContent_ ( ) <EOL> ) : <EOL> return True <EOL> else : <EOL> return False <EOL> def export ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , namespacedef_ = '<STR_LIT>' , pretty_print = True ) : <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , namespacedef_ and '<STR_LIT:U+0020>' + namespacedef_ or '<STR_LIT>' , ) ) <EOL> already_processed = set ( ) <EOL> self . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> if self . hasContent_ ( ) : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> self . exportChildren ( lwrite , level + <NUM_LIT:1> , nsmap , XML_NS , name_ , pretty_print = pretty_print ) <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , eol_ ) ) <EOL> else : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> def exportAttributes ( self , lwrite , level , already_processed , namespace_ = '<STR_LIT>' , name_ = '<STR_LIT>' ) : <EOL> super ( AssociatedCampaignsType , self ) . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> def exportChildren ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , fromsubclass_ = False , pretty_print = True ) : <EOL> super ( AssociatedCampaignsType , self ) . exportChildren ( lwrite , level , nsmap , namespace_ , name_ , True , pretty_print = pretty_print ) <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> for Associated_Campaign_ in self . Associated_Campaign : <EOL> Associated_Campaign_ . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> def build ( self , node ) : <EOL> already_processed = set ( ) <EOL> self . buildAttributes ( node , node . attrib , already_processed ) <EOL> for child in node : <EOL> nodeName_ = Tag_pattern_ . match ( child . tag ) . groups ( ) [ - <NUM_LIT:1> ] <EOL> self . buildChildren ( child , node , nodeName_ ) <EOL> def buildAttributes ( self , node , attrs , already_processed ) : <EOL> super ( AssociatedCampaignsType , self ) . buildAttributes ( node , attrs , already_processed ) <EOL> def buildChildren ( self , child_ , node , nodeName_ , fromsubclass_ = False ) : <EOL> if nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . RelatedCampaignType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . Associated_Campaign . append ( obj_ ) <EOL> super ( AssociatedCampaignsType , self ) . buildChildren ( child_ , node , nodeName_ , True ) <EOL> class RelatedIndicatorsType ( stix_common_binding . GenericRelationshipListType ) : <EOL> subclass = None <EOL> superclass = stix_common_binding . GenericRelationshipListType <EOL> def __init__ ( self , scope = '<STR_LIT>' , Related_Indicator = None ) : <EOL> super ( RelatedIndicatorsType , self ) . __init__ ( scope = scope ) <EOL> if Related_Indicator is None : <EOL> self . Related_Indicator = [ ] <EOL> else : <EOL> self . Related_Indicator = Related_Indicator <EOL> def factory ( * args_ , ** kwargs_ ) : <EOL> if RelatedIndicatorsType . subclass : <EOL> return RelatedIndicatorsType . subclass ( * args_ , ** kwargs_ ) <EOL> else : <EOL> return RelatedIndicatorsType ( * args_ , ** kwargs_ ) <EOL> factory = staticmethod ( factory ) <EOL> def get_Related_Indicator ( self ) : return self . Related_Indicator <EOL> def set_Related_Indicator ( self , Related_Indicator ) : self . Related_Indicator = Related_Indicator <EOL> def add_Related_Indicator ( self , value ) : self . Related_Indicator . append ( value ) <EOL> def insert_Related_Indicator ( self , index , value ) : self . Related_Indicator [ index ] = value <EOL> def hasContent_ ( self ) : <EOL> if ( <EOL> self . Related_Indicator or <EOL> super ( RelatedIndicatorsType , self ) . hasContent_ ( ) <EOL> ) : <EOL> return True <EOL> else : <EOL> return False <EOL> def export ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , namespacedef_ = '<STR_LIT>' , pretty_print = True ) : <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , namespacedef_ and '<STR_LIT:U+0020>' + namespacedef_ or '<STR_LIT>' , ) ) <EOL> already_processed = set ( ) <EOL> self . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> if self . hasContent_ ( ) : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> self . exportChildren ( lwrite , level + <NUM_LIT:1> , nsmap , XML_NS , name_ , pretty_print = pretty_print ) <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , eol_ ) ) <EOL> else : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> def exportAttributes ( self , lwrite , level , already_processed , namespace_ = '<STR_LIT>' , name_ = '<STR_LIT>' ) : <EOL> super ( RelatedIndicatorsType , self ) . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> def exportChildren ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , fromsubclass_ = False , pretty_print = True ) : <EOL> super ( RelatedIndicatorsType , self ) . exportChildren ( lwrite , level , nsmap , namespace_ , name_ , True , pretty_print = pretty_print ) <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> for Related_Indicator_ in self . Related_Indicator : <EOL> Related_Indicator_ . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> def build ( self , node ) : <EOL> already_processed = set ( ) <EOL> self . buildAttributes ( node , node . attrib , already_processed ) <EOL> for child in node : <EOL> nodeName_ = Tag_pattern_ . match ( child . tag ) . groups ( ) [ - <NUM_LIT:1> ] <EOL> self . buildChildren ( child , node , nodeName_ ) <EOL> def buildAttributes ( self , node , attrs , already_processed ) : <EOL> super ( RelatedIndicatorsType , self ) . buildAttributes ( node , attrs , already_processed ) <EOL> def buildChildren ( self , child_ , node , nodeName_ , fromsubclass_ = False ) : <EOL> if nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . RelatedIndicatorType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . Related_Indicator . append ( obj_ ) <EOL> super ( RelatedIndicatorsType , self ) . buildChildren ( child_ , node , nodeName_ , True ) <EOL> class RelatedIncidentsType ( stix_common_binding . GenericRelationshipListType ) : <EOL> subclass = None <EOL> superclass = stix_common_binding . GenericRelationshipListType <EOL> def __init__ ( self , scope = '<STR_LIT>' , Related_Incident = None ) : <EOL> super ( RelatedIncidentsType , self ) . __init__ ( scope = scope ) <EOL> if Related_Incident is None : <EOL> self . Related_Incident = [ ] <EOL> else : <EOL> self . Related_Incident = Related_Incident <EOL> def factory ( * args_ , ** kwargs_ ) : <EOL> if RelatedIncidentsType . subclass : <EOL> return RelatedIncidentsType . subclass ( * args_ , ** kwargs_ ) <EOL> else : <EOL> return RelatedIncidentsType ( * args_ , ** kwargs_ ) <EOL> factory = staticmethod ( factory ) <EOL> def get_Related_Incident ( self ) : return self . Related_Incident <EOL> def set_Related_Incident ( self , Related_Incident ) : self . Related_Incident = Related_Incident <EOL> def add_Related_Incident ( self , value ) : self . Related_Incident . append ( value ) <EOL> def insert_Related_Incident ( self , index , value ) : self . Related_Incident [ index ] = value <EOL> def hasContent_ ( self ) : <EOL> if ( <EOL> self . Related_Incident or <EOL> super ( RelatedIncidentsType , self ) . hasContent_ ( ) <EOL> ) : <EOL> return True <EOL> else : <EOL> return False <EOL> def export ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , namespacedef_ = '<STR_LIT>' , pretty_print = True ) : <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , namespacedef_ and '<STR_LIT:U+0020>' + namespacedef_ or '<STR_LIT>' , ) ) <EOL> already_processed = set ( ) <EOL> self . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> if self . hasContent_ ( ) : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> self . exportChildren ( lwrite , level + <NUM_LIT:1> , nsmap , XML_NS , name_ , pretty_print = pretty_print ) <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , eol_ ) ) <EOL> else : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> def exportAttributes ( self , lwrite , level , already_processed , namespace_ = '<STR_LIT>' , name_ = '<STR_LIT>' ) : <EOL> super ( RelatedIncidentsType , self ) . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> def exportChildren ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , fromsubclass_ = False , pretty_print = True ) : <EOL> super ( RelatedIncidentsType , self ) . exportChildren ( lwrite , level , nsmap , namespace_ , name_ , True , pretty_print = pretty_print ) <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> for Related_Incident_ in self . Related_Incident : <EOL> Related_Incident_ . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> def build ( self , node ) : <EOL> already_processed = set ( ) <EOL> self . buildAttributes ( node , node . attrib , already_processed ) <EOL> for child in node : <EOL> nodeName_ = Tag_pattern_ . match ( child . tag ) . groups ( ) [ - <NUM_LIT:1> ] <EOL> self . buildChildren ( child , node , nodeName_ ) <EOL> def buildAttributes ( self , node , attrs , already_processed ) : <EOL> super ( RelatedIncidentsType , self ) . buildAttributes ( node , attrs , already_processed ) <EOL> def buildChildren ( self , child_ , node , nodeName_ , fromsubclass_ = False ) : <EOL> if nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . RelatedIncidentType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . Related_Incident . append ( obj_ ) <EOL> super ( RelatedIncidentsType , self ) . buildChildren ( child_ , node , nodeName_ , True ) <EOL> class RelatedTTPsType ( stix_common_binding . GenericRelationshipListType ) : <EOL> subclass = None <EOL> superclass = stix_common_binding . GenericRelationshipListType <EOL> def __init__ ( self , scope = '<STR_LIT>' , Related_TTP = None ) : <EOL> super ( RelatedTTPsType , self ) . __init__ ( scope = scope ) <EOL> if Related_TTP is None : <EOL> self . Related_TTP = [ ] <EOL> else : <EOL> self . Related_TTP = Related_TTP <EOL> def factory ( * args_ , ** kwargs_ ) : <EOL> if RelatedTTPsType . subclass : <EOL> return RelatedTTPsType . subclass ( * args_ , ** kwargs_ ) <EOL> else : <EOL> return RelatedTTPsType ( * args_ , ** kwargs_ ) <EOL> factory = staticmethod ( factory ) <EOL> def get_Related_TTP ( self ) : return self . Related_TTP <EOL> def set_Related_TTP ( self , Related_TTP ) : self . Related_TTP = Related_TTP <EOL> def add_Related_TTP ( self , value ) : self . Related_TTP . append ( value ) <EOL> def insert_Related_TTP ( self , index , value ) : self . Related_TTP [ index ] = value <EOL> def hasContent_ ( self ) : <EOL> if ( <EOL> self . Related_TTP or <EOL> super ( RelatedTTPsType , self ) . hasContent_ ( ) <EOL> ) : <EOL> return True <EOL> else : <EOL> return False <EOL> def export ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , namespacedef_ = '<STR_LIT>' , pretty_print = True ) : <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , namespacedef_ and '<STR_LIT:U+0020>' + namespacedef_ or '<STR_LIT>' , ) ) <EOL> already_processed = set ( ) <EOL> self . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> if self . hasContent_ ( ) : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> self . exportChildren ( lwrite , level + <NUM_LIT:1> , nsmap , XML_NS , name_ , pretty_print = pretty_print ) <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , eol_ ) ) <EOL> else : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> def exportAttributes ( self , lwrite , level , already_processed , namespace_ = '<STR_LIT>' , name_ = '<STR_LIT>' ) : <EOL> super ( RelatedTTPsType , self ) . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> def exportChildren ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , fromsubclass_ = False , pretty_print = True ) : <EOL> super ( RelatedTTPsType , self ) . exportChildren ( lwrite , level , nsmap , namespace_ , name_ , True , pretty_print = pretty_print ) <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> for Related_TTP_ in self . Related_TTP : <EOL> Related_TTP_ . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> def build ( self , node ) : <EOL> already_processed = set ( ) <EOL> self . buildAttributes ( node , node . attrib , already_processed ) <EOL> for child in node : <EOL> nodeName_ = Tag_pattern_ . match ( child . tag ) . groups ( ) [ - <NUM_LIT:1> ] <EOL> self . buildChildren ( child , node , nodeName_ ) <EOL> def buildAttributes ( self , node , attrs , already_processed ) : <EOL> super ( RelatedTTPsType , self ) . buildAttributes ( node , attrs , already_processed ) <EOL> def buildChildren ( self , child_ , node , nodeName_ , fromsubclass_ = False ) : <EOL> if nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . RelatedTTPType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . Related_TTP . append ( obj_ ) <EOL> super ( RelatedTTPsType , self ) . buildChildren ( child_ , node , nodeName_ , True ) <EOL> class AttributionType ( stix_common_binding . GenericRelationshipListType ) : <EOL> """<STR_LIT>""" <EOL> subclass = None <EOL> superclass = stix_common_binding . GenericRelationshipListType <EOL> def __init__ ( self , scope = '<STR_LIT>' , Attributed_Threat_Actor = None ) : <EOL> super ( AttributionType , self ) . __init__ ( scope = scope ) <EOL> if Attributed_Threat_Actor is None : <EOL> self . Attributed_Threat_Actor = [ ] <EOL> else : <EOL> self . Attributed_Threat_Actor = Attributed_Threat_Actor <EOL> def factory ( * args_ , ** kwargs_ ) : <EOL> if AttributionType . subclass : <EOL> return AttributionType . subclass ( * args_ , ** kwargs_ ) <EOL> else : <EOL> return AttributionType ( * args_ , ** kwargs_ ) <EOL> factory = staticmethod ( factory ) <EOL> def get_Attributed_Threat_Actor ( self ) : return self . Attributed_Threat_Actor <EOL> def set_Attributed_Threat_Actor ( self , Attributed_Threat_Actor ) : self . Attributed_Threat_Actor = Attributed_Threat_Actor <EOL> def add_Attributed_Threat_Actor ( self , value ) : self . Attributed_Threat_Actor . append ( value ) <EOL> def insert_Attributed_Threat_Actor ( self , index , value ) : self . Attributed_Threat_Actor [ index ] = value <EOL> def hasContent_ ( self ) : <EOL> if ( <EOL> self . Attributed_Threat_Actor or <EOL> super ( AttributionType , self ) . hasContent_ ( ) <EOL> ) : <EOL> return True <EOL> else : <EOL> return False <EOL> def export ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , namespacedef_ = '<STR_LIT>' , pretty_print = True ) : <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , namespacedef_ and '<STR_LIT:U+0020>' + namespacedef_ or '<STR_LIT>' , ) ) <EOL> already_processed = set ( ) <EOL> self . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> if self . hasContent_ ( ) : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> self . exportChildren ( lwrite , level + <NUM_LIT:1> , nsmap , XML_NS , name_ , pretty_print = pretty_print ) <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , eol_ ) ) <EOL> else : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> def exportAttributes ( self , lwrite , level , already_processed , namespace_ = '<STR_LIT>' , name_ = '<STR_LIT>' ) : <EOL> super ( AttributionType , self ) . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> def exportChildren ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , fromsubclass_ = False , pretty_print = True ) : <EOL> super ( AttributionType , self ) . exportChildren ( lwrite , level , nsmap , namespace_ , name_ , True , pretty_print = pretty_print ) <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> for Attributed_Threat_Actor_ in self . Attributed_Threat_Actor : <EOL> Attributed_Threat_Actor_ . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> def build ( self , node ) : <EOL> already_processed = set ( ) <EOL> self . buildAttributes ( node , node . attrib , already_processed ) <EOL> for child in node : <EOL> nodeName_ = Tag_pattern_ . match ( child . tag ) . groups ( ) [ - <NUM_LIT:1> ] <EOL> self . buildChildren ( child , node , nodeName_ ) <EOL> def buildAttributes ( self , node , attrs , already_processed ) : <EOL> super ( AttributionType , self ) . buildAttributes ( node , attrs , already_processed ) <EOL> def buildChildren ( self , child_ , node , nodeName_ , fromsubclass_ = False ) : <EOL> if nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . RelatedThreatActorType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . Attributed_Threat_Actor . append ( obj_ ) <EOL> super ( AttributionType , self ) . buildChildren ( child_ , node , nodeName_ , True ) <EOL> @ register_extension <EOL> class CampaignType ( stix_common_binding . CampaignBaseType ) : <EOL> """<STR_LIT>""" <EOL> subclass = None <EOL> superclass = stix_common_binding . CampaignBaseType <EOL> xmlns = "<STR_LIT>" <EOL> xmlns_prefix = "<STR_LIT>" <EOL> xml_type = "<STR_LIT>" <EOL> def __init__ ( self , idref = None , id = None , timestamp = None , version = None , Title = None , Description = None , Short_Description = None , Names = None , Intended_Effect = None , Status = None , Related_TTPs = None , Related_Incidents = None , Related_Indicators = None , Attribution = None , Associated_Campaigns = None , Confidence = None , Activity = None , Information_Source = None , Handling = None , Related_Packages = None ) : <EOL> super ( CampaignType , self ) . __init__ ( idref = idref , id = id , timestamp = timestamp ) <EOL> self . version = _cast ( None , version ) <EOL> self . Title = Title <EOL> if Description is None : <EOL> self . Description = [ ] <EOL> else : <EOL> self . Description = Description <EOL> if Short_Description is None : <EOL> self . Short_Description = [ ] <EOL> else : <EOL> self . Short_Description = Short_Description <EOL> self . Names = Names <EOL> if Intended_Effect is None : <EOL> self . Intended_Effect = [ ] <EOL> else : <EOL> self . Intended_Effect = Intended_Effect <EOL> self . Status = Status <EOL> self . Related_TTPs = Related_TTPs <EOL> self . Related_Incidents = Related_Incidents <EOL> self . Related_Indicators = Related_Indicators <EOL> if Attribution is None : <EOL> self . Attribution = [ ] <EOL> else : <EOL> self . Attribution = Attribution <EOL> self . Associated_Campaigns = Associated_Campaigns <EOL> self . Confidence = Confidence <EOL> if Activity is None : <EOL> self . Activity = [ ] <EOL> else : <EOL> self . Activity = Activity <EOL> self . Information_Source = Information_Source <EOL> self . Handling = Handling <EOL> self . Related_Packages = Related_Packages <EOL> def factory ( * args_ , ** kwargs_ ) : <EOL> if CampaignType . subclass : <EOL> return CampaignType . subclass ( * args_ , ** kwargs_ ) <EOL> else : <EOL> return CampaignType ( * args_ , ** kwargs_ ) <EOL> factory = staticmethod ( factory ) <EOL> def get_Title ( self ) : return self . Title <EOL> def set_Title ( self , Title ) : self . Title = Title <EOL> def insert_Description ( self , index , value ) : self . Description [ index ] = value <EOL> def add_Description ( self , Description ) : self . Description . append ( Description ) <EOL> def get_Description ( self ) : return self . Description <EOL> def set_Description ( self , Description ) : self . Description = Description <EOL> def insert_Short_Description ( self , index , value ) : self . Short_Description [ index ] = value <EOL> def add_Short_Description ( self , Short_Description ) : self . Short_Description . append ( Short_Description ) <EOL> def get_Short_Description ( self ) : return self . Short_Description <EOL> def set_Short_Description ( self , Short_Description ) : self . Short_Description = Short_Description <EOL> def get_Names ( self ) : return self . Names <EOL> def set_Names ( self , Names ) : self . Names = Names <EOL> def get_Intended_Effect ( self ) : return self . Intended_Effect <EOL> def set_Intended_Effect ( self , Intended_Effect ) : self . Intended_Effect = Intended_Effect <EOL> def add_Intended_Effect ( self , value ) : self . Intended_Effect . append ( value ) <EOL> def insert_Intended_Effect ( self , index , value ) : self . Intended_Effect [ index ] = value <EOL> def get_Status ( self ) : return self . Status <EOL> def set_Status ( self , Status ) : self . Status = Status <EOL> def get_Related_TTPs ( self ) : return self . Related_TTPs <EOL> def set_Related_TTPs ( self , Related_TTPs ) : self . Related_TTPs = Related_TTPs <EOL> def get_Related_Incidents ( self ) : return self . Related_Incidents <EOL> def set_Related_Incidents ( self , Related_Incidents ) : self . Related_Incidents = Related_Incidents <EOL> def get_Related_Indicators ( self ) : return self . Related_Indicators <EOL> def set_Related_Indicators ( self , Related_Indicators ) : self . Related_Indicators = Related_Indicators <EOL> def get_Attribution ( self ) : return self . Attribution <EOL> def set_Attribution ( self , Attribution ) : self . Attribution = Attribution <EOL> def add_Attribution ( self , value ) : self . Attribution . append ( value ) <EOL> def insert_Attribution ( self , index , value ) : self . Attribution [ index ] = value <EOL> def get_Associated_Campaigns ( self ) : return self . Associated_Campaigns <EOL> def set_Associated_Campaigns ( self , Associated_Campaigns ) : self . Associated_Campaigns = Associated_Campaigns <EOL> def get_Confidence ( self ) : return self . Confidence <EOL> def set_Confidence ( self , Confidence ) : self . Confidence = Confidence <EOL> def get_Activity ( self ) : return self . Activity <EOL> def set_Activity ( self , Activity ) : self . Activity = Activity <EOL> def add_Activity ( self , value ) : self . Activity . append ( value ) <EOL> def insert_Activity ( self , index , value ) : self . Activity [ index ] = value <EOL> def get_Information_Source ( self ) : return self . Information_Source <EOL> def set_Information_Source ( self , Information_Source ) : self . Information_Source = Information_Source <EOL> def get_Handling ( self ) : return self . Handling <EOL> def set_Handling ( self , Handling ) : self . Handling = Handling <EOL> def get_Related_Packages ( self ) : return self . Related_Packages <EOL> def set_Related_Packages ( self , Related_Packages ) : self . Related_Packages = Related_Packages <EOL> def get_version ( self ) : return self . version <EOL> def set_version ( self , version ) : self . version = version <EOL> def hasContent_ ( self ) : <EOL> if ( <EOL> self . Title is not None or <EOL> self . Description or <EOL> self . Short_Description or <EOL> self . Names is not None or <EOL> self . Intended_Effect or <EOL> self . Status is not None or <EOL> self . Related_TTPs is not None or <EOL> self . Related_Incidents is not None or <EOL> self . Related_Indicators is not None or <EOL> self . Attribution or <EOL> self . Associated_Campaigns is not None or <EOL> self . Confidence is not None or <EOL> self . Activity or <EOL> self . Information_Source is not None or <EOL> self . Handling is not None or <EOL> self . Related_Packages is not None or <EOL> super ( CampaignType , self ) . hasContent_ ( ) <EOL> ) : <EOL> return True <EOL> else : <EOL> return False <EOL> def export ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , namespacedef_ = '<STR_LIT>' , pretty_print = True ) : <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , namespacedef_ and '<STR_LIT:U+0020>' + namespacedef_ or '<STR_LIT>' , ) ) <EOL> already_processed = set ( ) <EOL> self . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> if self . hasContent_ ( ) : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> self . exportChildren ( lwrite , level + <NUM_LIT:1> , nsmap , XML_NS , name_ , pretty_print = pretty_print ) <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , name_ , eol_ ) ) <EOL> else : <EOL> lwrite ( '<STR_LIT>' % ( eol_ , ) ) <EOL> def exportAttributes ( self , lwrite , level , already_processed , namespace_ = '<STR_LIT>' , name_ = '<STR_LIT>' ) : <EOL> super ( CampaignType , self ) . exportAttributes ( lwrite , level , already_processed , namespace_ , name_ = '<STR_LIT>' ) <EOL> if '<STR_LIT>' not in already_processed : <EOL> already_processed . add ( '<STR_LIT>' ) <EOL> xsi_type = "<STR_LIT>" % ( self . xmlns_prefix , self . xml_type ) <EOL> lwrite ( xsi_type ) <EOL> if self . version is not None and '<STR_LIT:version>' not in already_processed : <EOL> already_processed . add ( '<STR_LIT:version>' ) <EOL> lwrite ( '<STR_LIT>' % ( quote_attrib ( self . version ) , ) ) <EOL> def exportChildren ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , fromsubclass_ = False , pretty_print = True ) : <EOL> super ( CampaignType , self ) . exportChildren ( lwrite , level , nsmap , namespace_ , name_ , True , pretty_print = pretty_print ) <EOL> if pretty_print : <EOL> eol_ = '<STR_LIT:\n>' <EOL> else : <EOL> eol_ = '<STR_LIT>' <EOL> if self . Title is not None : <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( '<STR_LIT>' % ( nsmap [ namespace_ ] , quote_xml ( self . Title ) , nsmap [ namespace_ ] , eol_ ) ) <EOL> for Description in self . Description : <EOL> Description . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> for Short_Description in self . Short_Description : <EOL> Short_Description . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> if self . Names is not None : <EOL> self . Names . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> for Intended_Effect_ in self . Intended_Effect : <EOL> Intended_Effect_ . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> if self . Status is not None : <EOL> self . Status . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> if self . Related_TTPs is not None : <EOL> self . Related_TTPs . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> if self . Related_Incidents is not None : <EOL> self . Related_Incidents . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> if self . Related_Indicators is not None : <EOL> self . Related_Indicators . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> for Attribution_ in self . Attribution : <EOL> Attribution_ . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> if self . Associated_Campaigns is not None : <EOL> self . Associated_Campaigns . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> if self . Confidence is not None : <EOL> self . Confidence . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> for Activity_ in self . get_Activity ( ) : <EOL> Activity_ . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> if self . Information_Source is not None : <EOL> self . Information_Source . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> if self . Handling is not None : <EOL> self . Handling . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> if self . Related_Packages is not None : <EOL> self . Related_Packages . export ( lwrite , level , nsmap , namespace_ , name_ = '<STR_LIT>' , pretty_print = pretty_print ) <EOL> def build ( self , node ) : <EOL> already_processed = set ( ) <EOL> self . buildAttributes ( node , node . attrib , already_processed ) <EOL> for child in node : <EOL> nodeName_ = Tag_pattern_ . match ( child . tag ) . groups ( ) [ - <NUM_LIT:1> ] <EOL> self . buildChildren ( child , node , nodeName_ ) <EOL> def buildAttributes ( self , node , attrs , already_processed ) : <EOL> value = find_attr_value_ ( '<STR_LIT:version>' , node ) <EOL> if value is not None and '<STR_LIT:version>' not in already_processed : <EOL> already_processed . add ( '<STR_LIT:version>' ) <EOL> self . version = value <EOL> super ( CampaignType , self ) . buildAttributes ( node , attrs , already_processed ) <EOL> def buildChildren ( self , child_ , node , nodeName_ , fromsubclass_ = False ) : <EOL> if nodeName_ == '<STR_LIT>' : <EOL> Title_ = child_ . text <EOL> Title_ = self . gds_validate_string ( Title_ , node , '<STR_LIT>' ) <EOL> self . Title = Title_ <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . StructuredTextType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . add_Description ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . StructuredTextType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . add_Short_Description ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = NamesType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . set_Names ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . StatementType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . Intended_Effect . append ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . ControlledVocabularyStringType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . set_Status ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = RelatedTTPsType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . set_Related_TTPs ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = RelatedIncidentsType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . set_Related_Incidents ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = RelatedIndicatorsType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . set_Related_Indicators ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = AttributionType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . Attribution . append ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = AssociatedCampaignsType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . set_Associated_Campaigns ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . ConfidenceType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . set_Confidence ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . ActivityType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . Activity . append ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = stix_common_binding . InformationSourceType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . set_Information_Source ( obj_ ) <EOL> elif nodeName_ == '<STR_LIT>' : <EOL> obj_ = data_marking_binding . MarkingType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . set_Handling ( obj_ ) <EOL> elif nodeName_ == "<STR_LIT>" : <EOL> obj_ = stix_common_binding . RelatedPackageRefsType . factory ( ) <EOL> obj_ . build ( child_ ) <EOL> self . set_Related_Packages ( obj_ ) <EOL> super ( CampaignType , self ) . buildChildren ( child_ , node , nodeName_ , True ) <EOL> GDSClassesMapping = { } <EOL> USAGE_TEXT = """<STR_LIT>""" <EOL> def usage ( ) : <EOL> print USAGE_TEXT <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def get_root_tag ( node ) : <EOL> tag = Tag_pattern_ . match ( node . tag ) . groups ( ) [ - <NUM_LIT:1> ] <EOL> rootClass = GDSClassesMapping . get ( tag ) <EOL> if rootClass is None : <EOL> rootClass = globals ( ) . get ( tag ) <EOL> return tag , rootClass <EOL> def parse ( inFileName ) : <EOL> doc = parsexml_ ( inFileName ) <EOL> rootNode = doc . getroot ( ) <EOL> rootTag , rootClass = get_root_tag ( rootNode ) <EOL> if rootClass is None : <EOL> rootTag = '<STR_LIT>' <EOL> rootClass = CampaignType <EOL> rootObj = rootClass . factory ( ) <EOL> rootObj . build ( rootNode ) <EOL> doc = None <EOL> return rootObj <EOL> def parseEtree ( inFileName ) : <EOL> doc = parsexml_ ( inFileName ) <EOL> rootNode = doc . getroot ( ) <EOL> rootTag , rootClass = get_root_tag ( rootNode ) <EOL> if rootClass is None : <EOL> rootTag = '<STR_LIT>' <EOL> rootClass = CampaignType <EOL> rootObj = rootClass . factory ( ) <EOL> rootObj . build ( rootNode ) <EOL> doc = None <EOL> rootElement = rootObj . to_etree ( None , name_ = rootTag ) <EOL> content = etree_ . tostring ( rootElement , pretty_print = True , <EOL> xml_declaration = True , encoding = "<STR_LIT:utf-8>" ) <EOL> sys . stdout . write ( content ) <EOL> sys . stdout . write ( '<STR_LIT:\n>' ) <EOL> return rootObj , rootElement <EOL> def parseString ( inString ) : <EOL> from StringIO import StringIO <EOL> doc = parsexml_ ( StringIO ( inString ) ) <EOL> rootNode = doc . getroot ( ) <EOL> rootTag , rootClass = get_root_tag ( rootNode ) <EOL> if rootClass is None : <EOL> rootTag = '<STR_LIT>' <EOL> rootClass = CampaignType <EOL> rootObj = rootClass . factory ( ) <EOL> rootObj . build ( rootNode ) <EOL> doc = None <EOL> return rootObj <EOL> def main ( ) : <EOL> args = sys . argv [ <NUM_LIT:1> : ] <EOL> if len ( args ) == <NUM_LIT:1> : <EOL> parse ( args [ <NUM_LIT:0> ] ) <EOL> else : <EOL> usage ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) <EOL> __all__ = [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] </s>
