<s> import sys <EOL> from mixbox . binding_utils import * <EOL> from stix . bindings import register_extension <EOL> import stix . bindings . exploit_target as exploit_target_binding <EOL> XML_NS = "<STR_LIT>" <EOL> @ register_extension <EOL> class CVRF1_1InstanceType ( exploit_target_binding . VulnerabilityType ) : <EOL> """<STR_LIT>""" <EOL> subclass = None <EOL> superclass = exploit_target_binding . VulnerabilityType <EOL> xmlns = XML_NS <EOL> xmlns_prefix = "<STR_LIT>" <EOL> xml_type = "<STR_LIT>" <EOL> def __init__ ( self , Description = None , CVE_ID = None , OSVDB_ID = None , CVSS_Score = None , cvrfdoc = None ) : <EOL> super ( CVRF1_1InstanceType , self ) . __init__ ( Description = Description , CVE_ID = CVE_ID , OSVDB_ID = OSVDB_ID , CVSS_Score = CVSS_Score ) <EOL> self . cvrfdoc = cvrfdoc <EOL> def factory ( * args_ , ** kwargs_ ) : <EOL> if CVRF1_1InstanceType . subclass : <EOL> return CVRF1_1InstanceType . subclass ( * args_ , ** kwargs_ ) <EOL> else : <EOL> return CVRF1_1InstanceType ( * args_ , ** kwargs_ ) <EOL> factory = staticmethod ( factory ) <EOL> def get_cvrfdoc ( self ) : return self . cvrfdoc <EOL> def set_cvrfdoc ( self , cvrfdoc ) : self . cvrfdoc = cvrfdoc <EOL> def hasContent_ ( self ) : <EOL> if ( <EOL> self . cvrfdoc is not None or <EOL> super ( CVRF1_1InstanceType , 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 ( CVRF1_1InstanceType , 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> xmlns = "<STR_LIT>" % ( self . xmlns_prefix , self . xmlns ) <EOL> lwrite ( xmlns ) <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> def exportChildren ( self , lwrite , level , nsmap , namespace_ = XML_NS , name_ = '<STR_LIT>' , fromsubclass_ = False , pretty_print = True ) : <EOL> super ( CVRF1_1InstanceType , 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 . cvrfdoc is not None : <EOL> showIndent ( lwrite , level , pretty_print ) <EOL> lwrite ( etree_ . tostring ( self . cvrfdoc , 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 ( CVRF1_1InstanceType , self ) . buildAttributes ( node , attrs , already_processed ) <EOL> def buildChildren ( self , child_ , node , nodeName_ , fromsubclass_ = False ) : <EOL> if nodeName_ == '<STR_LIT>' : <EOL> self . set_cvrfdoc ( child_ ) <EOL> super ( CVRF1_1InstanceType , 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 = CVRF1_1InstanceType <EOL> rootObj = rootClass . factory ( ) <EOL> rootObj . build ( rootNode ) <EOL> doc = None <EOL> sys . stdout . write ( '<STR_LIT>' ) <EOL> rootObj . export ( sys . stdout , <NUM_LIT:0> , name_ = rootTag , <EOL> namespacedef_ = '<STR_LIT>' , <EOL> pretty_print = True ) <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 = CVRF1_1InstanceType <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 = CVRF1_1InstanceType <EOL> rootObj = rootClass . factory ( ) <EOL> rootObj . build ( rootNode ) <EOL> doc = None <EOL> sys . stdout . write ( '<STR_LIT>' ) <EOL> rootObj . export ( sys . stdout , <NUM_LIT:0> , name_ = "<STR_LIT>" , <EOL> namespacedef_ = '<STR_LIT>' ) <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> ] </s>
