def __init__(self, infilename, outfilename, verbose_mode): self.converted_ids = [] self.skipped_observables = [] self.oval_defs = oval.DefinitionsType() self.oval_tests = oval.TestsType() self.oval_objects = oval.ObjectsType() self.oval_states = oval.StatesType() self.ovaldefroot = oval.oval_definitions() self.mappings = cybox_oval_mappings.cybox_oval_mappings() self.infilename = infilename self.outfilename = outfilename self.verbose_mode = verbose_mode
def __init__(self, infilename, outfilename, verbose_mode, stat_mode): self.converted_ids = [] self.skipped_actions = [] self.oval_defs = oval.DefinitionsType() self.oval_tests = oval.TestsType() self.oval_objects = oval.ObjectsType() self.oval_states = oval.StatesType() self.ovaldefroot = oval.oval_definitions() self.mappings = cybox_oval_mappings.cybox_oval_mappings('maec_to_oval') self.supported_action_types = ['create', 'modify'] self.metadata = oval.MetadataType(title = 'Object check', description = 'Existence check for object(s) extracted from MAEC Action') self.infilename = infilename self.outfilename = outfilename self.verbose_mode = verbose_mode self.stat_mode = stat_mode self.current_bundle = None
def __init__(self, infilename, outfilename, verbose_mode, stat_mode): self.converted_ids = [] self.skipped_actions = [] self.oval_defs = oval.DefinitionsType() self.oval_tests = oval.TestsType() self.oval_objects = oval.ObjectsType() self.oval_states = oval.StatesType() self.ovaldefroot = oval.oval_definitions() self.mappings = cybox_oval_mappings.cybox_oval_mappings('maec_to_oval') self.supported_action_types = ['Create', 'Modify'] self.metadata = oval.MetadataType( title='Object check', description= 'Existence check for object(s) extracted from MAEC Action') self.infilename = infilename self.outfilename = outfilename self.verbose_mode = verbose_mode self.stat_mode = stat_mode
def main(): verbose_error_mode = 0 #Get the command-line arguments args = sys.argv[1:] if len(args) == 4: if args[0] != '-i' or args[2] != '-o': usage() sys.exit(1) infilename = args[1] outfilename = args[3] elif len(args) == 5: if args[0] != '-v' or args[1] != '-i' or args[3] != '-o': usage() sys.exit(1) infilename = args[2] outfilename = args[4] verbose_error_mode = 1 else: usage() sys.exit(1) #Check the existence of the input file if os.path.isfile(infilename): #Get the MAEC bundle object from the document #Do some basic error handling here.. rootObject = None try: rootObject = maec.parse(infilename) except Exception, err: print('\nError: %s\n' % str(err)) #Create the root OVAL document ovaldefroot = oval.oval_definitions() global maec_bundle if rootObject != None: maec_bundle = rootObject else: if verbose_error_mode: traceback.print_exc() print('Error: MAEC Bundle object not found. No OVAL exported.') sys.exit(1) #Setup the OVAL document global oval_defs global oval_tests global oval_objects oval_defs = oval.DefinitionsType() oval_tests = oval.TestsType() oval_objects = oval.ObjectsType() #Add the generator to the defs oval_gen = oval.GeneratorType() oval_gen.set_product_name('MAEC XML to OVAL Script') oval_gen.set_product_version('1.1') oval_gen.set_schema_version('5.7') #Generate the datetime oval_gen.set_timestamp(generate_datetime()) #Call the main parsing function to do all the dirty work print "\nExtracting MAEC objects and generating OVAL definitions...\n" try: parse_actions() except Exception, err: if verbose_error_mode: traceback.print_exc() print('\nError: %s\n' % str(err)) print('Error in parse_actions(). No OVAL exported.') sys.exit(1)