def main(): parser = create_parser() args = parser.parse_args() xccdffile = args.xccdf_file idname = args.id_name # Step over xccdf file, and find referenced check files xccdftree = ssgcommon.parse_xml_file(xccdffile) if 'unlinked-ocilref' not in xccdffile: check_that_oval_and_rule_id_match(xccdftree) checks = xccdftree.findall(".//{%s}check" % xccdf_ns) translator = idtranslate.IDTranslator(idname) oval_linker = OVALFileLinker(translator, xccdftree, checks) oval_linker.link() oval_linker.save_linked_tree() oval_linker.link_xccdf() ocil_linker = OCILFileLinker(translator, xccdftree, checks) ocil_linker.link() ocil_linker.save_linked_tree() ocil_linker.link_xccdf() newxccdffile = xccdffile.replace("unlinked", "linked") ssgcommon.ElementTree.ElementTree(xccdftree).write(newxccdffile) sys.exit(0)
def link(self): self.tree = ssgcommon.parse_xml_file(self.fname) try: self._link_oval_tree() # Verify if CCE identifiers present in the XCCDF follow the required form # (either CCE-XXXX-X, or CCE-XXXXX-X). Drop from XCCDF those who don't follow it verify_correct_form_of_referenced_cce_identifiers(self.xccdftree) except ssgcommon.SSGError as exc: raise ssgcommon.SSGError("Error processing {0}: {1}".format( self.fname, str(exc))) self.tree = self.translator.translate(self.tree, store_defname=True)
def link(self): self.tree = ssgcommon.parse_xml_file(self.fname) self.tree = self.translator.translate(self.tree, store_defname=True)