Exemple #1
0
def get_cis(agent_id=None,
            offset=0,
            limit=common.database_limit,
            sort=None,
            search=None):
    """
    Get all the CIS requirements used in the rootchecks of the agent.

    :param agent_id: Agent ID.
    :param offset: First item to return.
    :param limit: Maximum number of items to return.
    :param sort: Sorts the items. Format: {"fields":["field1","field2"],"order":"asc|desc"}.
    :param search: Looks for items with the specified string.
    :return: Dictionary: {'items': array of items, 'totalItems': Number of items (without applying the limit)}
    """
    if is_a_local_request() or agent_id == "000":
        return get_cis_local(agent_id, offset, limit, sort, search)
    else:
        if not is_cluster_running():
            raise WazuhException(3015)

        request_type = list_requests_rootcheck['ROOTCHECK_CIS']
        args = [str(offset), str(limit), str(sort), str(search)]
        return distributed_api_request(request_type,
                                       Agent.get_agents_by_node(agent_id),
                                       args)
Exemple #2
0
def last_scan(agent_id):
    """
    Gets the last scan of the agent.

    :param agent_id: Agent ID.
    :return: Dictionary: end, start.
    """
    if is_a_local_request() or agent_id == "000":
        return last_scan_local(agent_id)
    else:
        if not is_cluster_running():
            raise WazuhException(3015)

        request_type = list_requests_rootcheck['ROOTCHECK_LAST_SCAN']
        args = []
        return distributed_api_request(request_type,
                                       Agent.get_agents_by_node(agent_id),
                                       args)
Exemple #3
0
def run(agent_id=None, all_agents=False, cluster_depth=1):
    """
    Runs rootcheck and syscheck.

    :param agent_id: Run rootcheck/syscheck in the agent.
    :param all_agents: Run rootcheck/syscheck in all agents.
    :return: Message.
    """
    if is_a_local_request() or agent_id == "000" or cluster_depth <= 0:
        return run_local(agent_id, all_agents)
    else:
        if not is_cluster_running():
            raise WazuhException(3015)

        request_type = list_requests_rootcheck['ROOTCHECK_RUN']
        args = [str(all_agents)]
        return distributed_api_request(request_type,
                                       Agent.get_agents_by_node(agent_id),
                                       args, cluster_depth)
Exemple #4
0
def clear(agent_id=None, all_agents=False, cluster_depth=1):
    """
    Clears the database.

    :param agent_id: For an agent.
    :param all_agents: For all agents.
    :return: Message.
    """
    if is_a_local_request() or agent_id == "000" or cluster_depth <= 0:
        return clear_local(agent_id, all_agents)
    else:
        if not is_cluster_running():
            raise WazuhException(3015)

        request_type = list_requests_rootcheck['ROOTCHECK_CLEAR']
        args = [str(all_agents)]
        return distributed_api_request(request_type,
                                       Agent.get_agents_by_node(agent_id),
                                       args, cluster_depth)