def replace_inplace_risk(self, scanning_results=None):
        """
        This function has aim to replace FAILED to
        NEEDS_INSPECTION in case that risks are NONE or SLIGHT
        """
        #Filter all rule-result in TestResult
        changed_fields = []
        self.remove_empty_check_import()
        inplace_dict = {
            0: upd_inspection,
            1: upd_inspection,
            2: upd_inspection,
            3: upd_action,
            4: 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 = xccdf.get_check_import_inplace_risk(rule)
                # In case that report has state fail and
                # no log_risk than it should be needs_inspection
                if not inplace_risk:
                    changed, res.text = inplace_dict[0](rule)
                else:
                    inplace_num = int(xccdf.get_and_print_inplace_risk(0, inplace_risk))
                    changed, res.text = inplace_dict[inplace_num](rule)
                if changed is not None:
                    changed_fields.append(changed+":"+res.text)

        if scanning_results:
            scanning_results.update_data(changed_fields)

        self.write_xml()
Example #2
0
 def update_inplace_risk(self, scanning_progress, rule, res):
     """Function updates inplace risk"""
     inplace_risk = xccdf.get_check_import_inplace_risk(rule)
     if inplace_risk:
         return_value = xccdf.get_and_print_inplace_risk(0, inplace_risk)
         if int(return_value) < 3:
             res.text = utils.get_needs_inspection()
         elif int(return_value) == 3:
             res.text = utils.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 update_inplace_risk(self, scanning_progress, rule, res):
     """Function updates inplace risk"""
     inplace_risk = xccdf.get_check_import_inplace_risk(rule)
     if inplace_risk:
         return_value = xccdf.get_and_print_inplace_risk(0, inplace_risk)
         if int(return_value) < 3:
             res.text = utils.get_needs_inspection()
         elif int(return_value) == 3:
             res.text = utils.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)
Example #4
0
    def replace_inplace_risk(self, scanning_results=None):
        """
        This function has aim to replace FAILED to
        NEEDS_INSPECTION in case that risks are NONE or SLIGHT
        """
        #Filter all rule-result in TestResult
        changed_fields = []
        self.remove_empty_check_import()
        inplace_dict = {
            0: upd_inspection,
            1: upd_inspection,
            2: upd_inspection,
            3: upd_action,
            4: 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 = xccdf.get_check_import_inplace_risk(rule)
                # In case that report has state fail and
                # no log_risk than it should be needs_inspection
                if not inplace_risk:
                    changed, res.text = inplace_dict[0](rule)
                else:
                    inplace_num = int(
                        xccdf.get_and_print_inplace_risk(0, inplace_risk))
                    changed, res.text = inplace_dict[inplace_num](rule)
                if changed is not None:
                    changed_fields.append(changed + ":" + res.text)

        if scanning_results:
            scanning_results.update_data(changed_fields)

        self.write_xml()