Exemplo n.º 1
0
    def load_from_xml_element(self, root, config_file):
        self.id_ = Task.get_task_id_from_filepath(config_file)
        self.enabled = root.get("enabled", "false") == "true"

        self.title = et_helpers.get_element_text(root, "title")

        self.evaluation_spec = evaluation_spec.EvaluationSpec()
        self.evaluation_spec.load_from_xml_element(
            et_helpers.get_element(root, "evaluation_spec"))

        self.schedule = Schedule()
        self.schedule.load_from_xml_element(
            et_helpers.get_element(root, "schedule"))

        self.config_file = config_file
Exemplo n.º 2
0
    def __init__(self):
        self.id_ = None
        self.config_file = None
        self.enabled = False

        self.title = None
        self.evaluation_spec = evaluation_spec.EvaluationSpec()

        self.schedule = Schedule()
        # If True, this task will be evaluated once without affecting the
        # schedule. This feature is important for test runs. This variable does
        # not persist because it is not saved to the config file!
        self.run_outside_schedule_once = False

        # Prevents multiple updates of the same task running
        self.update_lock = threading.Lock()
Exemplo n.º 3
0
    def __init__(self):
        self.id_ = None
        self.config_file = None
        self.enabled = False

        self.title = None
        self.evaluation_spec = evaluation_spec.EvaluationSpec()

        # How many results should we keep before pruning old results
        # -1 means use the default from config
        # -2 means never prune any results
        self.max_results_to_keep = -1

        self.schedule = Schedule()
        # If True, this task will be evaluated once without affecting the
        # schedule. This feature is important for test runs. This variable does
        # not persist because it is not saved to the config file!
        self.run_outside_schedule_once = False

        # Prevents multiple updates of the same task running
        self.update_lock = threading.Lock()
Exemplo n.º 4
0
def cli_create_evaluation_spec(dbus_iface):
    """Interactively create EvaluationSpec and return it. Returns None if user
    cancels the action.
    """
    print("Creating EvaluationSpec interactively...")
    print("")

    try:
        target = py2_raw_input("Target (empty for localhost): ")
        if not target:
            target = "localhost"

        print("Found the following SCAP Security Guide content: ")
        ssg_choices = dbus_iface.GetSSGChoices()
        i = 0
        for ssg_choice in ssg_choices:
            print("\t%i:  %s" % (i + 1, ssg_choice))
            i += 1

        input_file = None
        input_ssg_choice = py2_raw_input(
            "Choose SSG content by number (empty for custom content): ")
        if not input_ssg_choice:
            input_file = py2_raw_input("Input file (absolute path): ")
        else:
            input_file = ssg_choices[int(input_ssg_choice) - 1]

        input_file = os.path.abspath(input_file)

        tailoring_file = py2_raw_input(
            "Tailoring file (absolute path, empty for no tailoring): ")
        if tailoring_file in [None, ""]:
            tailoring_file = ""
        else:
            tailoring_file = os.path.abspath(tailoring_file)

        print("Found the following possible profiles: ")
        profile_choices = dbus_iface.GetProfileChoicesForInput(
            input_file, tailoring_file)
        i = 0
        for key, value in profile_choices.items():
            print("\t%i:  %s (id='%s')" % (i + 1, value, key))
            i += 1

        profile_choice = py2_raw_input(
            "Choose profile by number (empty for (default) profile): ")
        if profile_choice is not None:
            profile = list(profile_choices.keys())[int(profile_choice) - 1]
        else:
            profile = None

        online_remediation = False
        if py2_raw_input("Online remediation (1, y or Y for yes, else no): ") \
                in ["1", "y", "Y"]:
            online_remediation = True

        ret = evaluation_spec.EvaluationSpec()
        ret.target = target
        ret.input_.set_file_path(input_file)
        if tailoring_file not in [None, ""]:
            ret.tailoring.set_file_path(tailoring_file)
        ret.profile_id = profile
        ret.online_remediation = online_remediation

        return ret

    except KeyboardInterrupt:
        return None