def check_script_modification(self, key, k): """Function checks a check script""" script_utils.check_scripts(k, self.dirname, script_name=key[k]) check_func = {'log_': ['log_none_risk', 'log_slight_risk', 'log_medium_risk', 'log_high_risk', 'log_extreme_risk', 'log_info', 'log_error', 'log_warning'], 'exit_': ['exit_error', 'exit_fail', 'exit_fixed', 'exit_not_applicable', 'exit_pass', 'exit_unknown', 'exit_informational']} for check in check_func: script_utils.check_inplace_risk(self.dirname, prefix=check, script_name=key[k], check_func=check_func[check]) self.update_values_list(self.rule, "{scap_name}", key[k].split('.')[0]) requirements = {'applies_to': 'check_applies', 'binary_req': 'check_bin', 'requires': 'check_rpm'} updates = dict() for req in requirements: if req in key: updates[requirements[req]] = key[req] script_utils.update_check_script(self.dirname, updates, script_name=key[k], author=key['author'] if 'author' in key else "") self.update_values_list(self.rule, "{"+k+"}", key[k])
def check_script_modification(self, key, k): """Function checks a check script""" script_utils.check_scripts(k, self.dirname, script_name=key[k]) check_func = { 'log_': [ 'log_none_risk', 'log_slight_risk', 'log_medium_risk', 'log_high_risk', 'log_extreme_risk', 'log_info', 'log_error', 'log_warning' ], 'exit_': [ 'exit_error', 'exit_fail', 'exit_fixed', 'exit_not_applicable', 'exit_pass', 'exit_unknown', 'exit_informational' ] } for check in check_func: script_utils.check_inplace_risk(self.dirname, prefix=check, script_name=key[k], check_func=check_func[check]) self.update_values_list(self.rule, "{scap_name}", key[k].split('.')[0]) requirements = { 'applies_to': 'check_applies', 'binary_req': 'check_bin', 'requires': 'check_rpm' } updates = dict() for req in requirements: if req in key: updates[requirements[req]] = key[req] script_utils.update_check_script( self.dirname, updates, script_name=key[k], author=key['author'] if 'author' in key else "") self.update_values_list(self.rule, "{" + k + "}", key[k])
def solution_modification(self, key): """Function handles a solution text or scripts""" fix_tag = [] for k in key['solution'].split(','): k = k.strip() script_utils.check_scripts('solution', self.dirname, script_name=k) script_type = script_utils.get_script_type(self.dirname, script_name=k) if script_type == "txt": fix_tag.append(xml_tags.FIX_TEXT) else: fix_tag.append(xml_tags.FIX) self.update_values_list(fix_tag, "{solution_text}", key['solution_type'] if 'solution_type' in key else "text") self.update_values_list(fix_tag, "{solution}", k) self.update_values_list(fix_tag, "{script_type}", script_type) self.update_values_list(self.rule, '{fix}', ''.join(fix_tag))
def solution_modification(self, key): """Function handles a solution text or scripts""" fix_tag = [] for k in key['solution'].split(','): k = k.strip() script_utils.check_scripts('solution', self.dirname, script_name=k) script_type = script_utils.get_script_type(self.dirname, script_name=k) if script_type == "txt": fix_tag.append(xml_tags.FIX_TEXT) else: fix_tag.append(xml_tags.FIX) self.update_values_list( fix_tag, "{solution_text}", key['solution_type'] if 'solution_type' in key else "text") self.update_values_list(fix_tag, "{solution}", k) self.update_values_list(fix_tag, "{script_type}", script_type) self.update_values_list(self.rule, '{fix}', ''.join(fix_tag))