def update_inplace_risk(self, scanning_progress, rule, res): """Function updates inplace risk""" inplace_risk = XccdfHelper.get_check_import_inplace_risk(rule) if inplace_risk: logger_report.debug("Update_inplace_risk '%s'", inplace_risk) return_value = XccdfHelper.get_and_print_inplace_risk(0, inplace_risk) logger_report.debug("Get and print inplace risk return code '%s'", return_value) if int(return_value)/2 == 1: res.text = ReportHelper.get_needs_inspection() elif int(return_value)/2 == 2: res.text = ReportHelper.get_needs_action() for index, row in enumerate(scanning_progress.output_data): if self.get_nodes_text(rule, "title") in row: scanning_progress.output_data[index] = "{0}:{1}".format( self.get_nodes_text(rule, "title"), res.text)
def replace_inplace_risk(self, scanning_results=None): """ This function has aim to replace FAILED to NEEDS_INSPECTION in case that risks are SLIGHT or MEDIUM """ #Filter all rule-result in TestResult changed_fields = [] self.remove_empty_check_import() inplace_dict = { 0: ReportHelper.upd_inspection, 1: ReportHelper.upd_action, 2: ReportHelper.upd_extreme, } for rule in self.get_all_result_rules(): result = [ x for x in self.get_nodes(rule, "result") if x.text == "fail" ] # Get all affected rules and taken their names for res in result: inplace_risk = XccdfHelper.get_check_import_inplace_risk(rule) logger_report.debug(inplace_risk) # In case that report has state fail and # no log_risk than it should be needs_inspection if not inplace_risk: changed = rule.get("idref") res.text = "fail" log_message( 'The %s module exits as fail but without a risk.' % rule.get("idref")) else: inplace_num = XccdfHelper.get_and_print_inplace_risk( 0, inplace_risk) logger_report.debug("Call function '%s'", inplace_dict[inplace_num]) changed, res.text = inplace_dict[inplace_num](rule) logger_report.debug("Replace text '%s:%s'", changed, res.text) if changed is not None: changed_fields.append(changed + ":" + res.text) if scanning_results: scanning_results.update_data(changed_fields) self.write_xml()
def replace_inplace_risk(self, scanning_results=None): """ This function has aim to replace FAILED to NEEDS_INSPECTION in case that risks are SLIGHT or MEDIUM """ #Filter all rule-result in TestResult changed_fields = [] self.remove_empty_check_import() inplace_dict = { 0: ReportHelper.upd_inspection, 1: ReportHelper.upd_action, 2: ReportHelper.upd_extreme, } for rule in self.get_all_result_rules(): result = [x for x in self.get_nodes(rule, "result") if x.text == "fail"] # Get all affected rules and taken their names for res in result: inplace_risk = XccdfHelper.get_check_import_inplace_risk(rule) logger_report.debug(inplace_risk) # In case that report has state fail and # no log_risk than it should be needs_inspection if not inplace_risk: changed = rule.get("idref") res.text = "fail" log_message('The %s module exits as fail but without a risk.' % rule.get("idref")) else: inplace_num = XccdfHelper.get_and_print_inplace_risk(0, inplace_risk) logger_report.debug("Call function '%s'", inplace_dict[inplace_num]) changed, res.text = inplace_dict[inplace_num](rule) logger_report.debug("Replace text '%s:%s'", changed, res.text) if changed is not None: changed_fields.append(changed+":"+res.text) if scanning_results: scanning_results.update_data(changed_fields) self.write_xml()