コード例 #1
0
def set_auto_updates():
    enabled = is_json_true(request.args.get('enabled'))
    try:
        set_feed_auto_update(enabled=enabled)
    except APIException as e:
        return make_error_from_exception(e)

    return make_ok()
コード例 #2
0
def get_data_status_messages():
    """Retrieves a list of current_status messages matching the given criteria"""
    component_id = request.args.get('component_id')
    component_type = request.args.get('component_type')
    message_id = request.args.get('message_id', None)
    search = request.args.get('search', None)
    order_desc = is_json_true(request.args.get('order_desc'))
    only_unread = is_json_true(request.args.get('only_unread'))

    level = request.args.get('level')
    if level is not None:
        level = level.split(',')
        valid_levels = ["info","warning","error"]
        if not set(level).issubset(valid_levels):
            return make_bad_request("Invalid parameter level. Allowed valeus are %s" % str(valid_levels))

    page = request.args.get('page', 1)
    if page is not None:
        if not is_valid_integer(page):
            return make_bad_request("The parameter page (%s) is not a valid integer value" % str(page))
        page = int(page)

    page_row = request.args.get('page_rows', 50)
    if page_row is not None:
        page_row = int(page_row)

    message_type = request.args.get('message_type', None)
    if message_type is not None:
        message_type = message_type.split(',')

    orderby = request.args.get('order_by')
    if orderby not in ['creation_time', 'component_type', 'message_level', 'message_type', 'message_title', '', None]:
        return make_bad_request("Invalid parameter order by. Allowed values are ('creation_time','component_type','"
                                "message_level','message_type','message_title','')")

    (success, data) = get_status_messages(component_id=component_id, message_level=level, order_by=orderby,
                                          page=page, page_row=page_row, order_desc=order_desc,
                                          component_type=component_type, message_id=message_id,
                                          message_type=message_type, search=search, only_unread=only_unread,
                                          login_user=current_user.login,
                                          is_admin=current_user.is_admin)

    if not success:
        return make_error(data, 500)
    return make_ok(**data)
コード例 #3
0
def get_data_status_messages_stats():
    """ Retrieves a list of current status messages stats """
    search = request.args.get('search', None)
    only_unread = is_json_true(request.args.get('only_unread'))

    (success, data) = get_status_messages_stats(search=search, only_unread=only_unread, login_user=current_user.login, is_admin=current_user.is_admin)

    if not success:
        return make_error(data, 500)
    return make_ok(**data)
コード例 #4
0
ファイル: otx.py プロジェクト: jpalanco/alienvault-ossim
def get_pulse_detail(pulse_id):

    hide_ioc = is_json_true(request.args.get('hide_ioc'))

    success, pulse_detail = apimethod_get_pulse_detail(pulse_id, hide_ioc)
    if not success:
        current_app.logger.error("OTX: It wasn't possible to retrieve the Pulse detail: %s" % str(pulse_detail))
        return make_error(pulse_detail, 500)

    return make_ok(**pulse_detail)
コード例 #5
0
ファイル: config.py プロジェクト: jpalanco/alienvault-ossim
def set_telemetry_collection_config():
    if not first_init_admin_access():
        return make_error('Request forbidden -- authorization will not help', 403)

    enabled = is_json_true(request.args.get('enabled'))
    try:
        set_system_config_telemetry_enabled(enabled=enabled)
    except APIException as e:
        return make_error_from_exception(e)

    return make_ok()
コード例 #6
0
def set_telemetry_collection_config():
    if not first_init_admin_access():
        return make_error('Request forbidden -- authorization will not help',
                          403)

    enabled = is_json_true(request.args.get('enabled'))
    try:
        set_system_config_telemetry_enabled(enabled=enabled)
    except APIException as e:
        return make_error_from_exception(e)

    return make_ok()
コード例 #7
0
def get_pulse_detail(pulse_id):

    hide_ioc = is_json_true(request.args.get('hide_ioc'))

    success, pulse_detail = apimethod_get_pulse_detail(pulse_id, hide_ioc)
    if not success:
        current_app.logger.error(
            "OTX: It wasn't possible to retrieve the Pulse detail: %s" %
            str(pulse_detail))
        return make_error(pulse_detail, 500)

    return make_ok(**pulse_detail)
コード例 #8
0
ファイル: backup.py プロジェクト: jpalanco/alienvault-ossim
def get_system_backup_list(system_id):
    """
    Get the list of configuration backups in the system
    """
    backup_type = request.args.get('type', '')
    no_cache = request.args.get('no_cache', 'false')
    no_cache = is_json_true(no_cache)

    success, backup_list = get_backup_list(system_id=system_id,
                                           backup_type=backup_type,
                                           no_cache=no_cache)
    if not success:
        return make_error("Error getting backup list. Please check the system is reachable", 500)

    return make_ok(backups=backup_list)
コード例 #9
0
ファイル: status.py プロジェクト: zoe-mora-imdc/Ossim
def is_system_reachable(system_id):
    """Find out if a system is reachable or not.

    The blueprint handle the following url:
    GET /av/api/1.0/system/<system_id>/status/ping

    Args:
        system_id (str): String with system id (uuid) or local

    """
    no_cache = is_json_true(request.args.get('no_cache', None))
    try:
        reachable = ping_system(system_id, no_cache=no_cache)
        return make_ok(reachable=reachable)
    except APIException as e:
        make_error_from_exception(e)
コード例 #10
0
ファイル: status.py プロジェクト: jpalanco/alienvault-ossim
def is_system_reachable(system_id):
    """Find out if a system is reachable or not.

    The blueprint handle the following url:
    GET /av/api/1.0/system/<system_id>/status/ping

    Args:
        system_id (str): String with system id (uuid) or local

    """
    no_cache = is_json_true(request.args.get('no_cache', None))
    try:
        reachable = ping_system(system_id, no_cache=no_cache)
        return make_ok(reachable=reachable)
    except APIException as e:
        make_error_from_exception(e)
コード例 #11
0
ファイル: network.py プロジェクト: qiwihui/alienvault-ossim
def put_system_network_interface(system_id, iface):
    promisc = request.args.get("promisc")
    if promisc is not None:
        if not is_json_boolean(promisc):
            current_app.logger.error("network: put_system_network_interface error: Bad param 'promisc='%s'" % promisc)
            return make_bad_request("Bad param 'promisc=%s'" % promisc)
    else:
        current_app.logger.error("network: put_system_network_interface error: Missing parameter 'promisc'")
        return make_bad_request("Missing parameters")

    (success, msg) = put_interface(system_id, iface, is_json_true(promisc))
    if not success:
        current_app.logger.error("network: put_system_network_interface error: " + str(msg))
        return make_error(msg, 500)

    return make_ok()
コード例 #12
0
def get_system_backup_list(system_id):
    """
    Get the list of configuration backups in the system
    """
    backup_type = request.args.get('type', '')
    no_cache = request.args.get('no_cache', 'false')
    no_cache = is_json_true(no_cache)

    success, backup_list = get_backup_list(system_id=system_id,
                                           backup_type=backup_type,
                                           no_cache=no_cache)
    if not success:
        return make_error(
            "Error getting backup list. Please check the system is reachable",
            500)

    return make_ok(backups=backup_list)
コード例 #13
0
ファイル: status.py プロジェクト: jpalanco/alienvault-ossim
def get_pending_packages(system_id):
    """Get pending update packages from a given AlienVault system

    The blueprint handle the following url:
    GET /av/api/1.0/system/<system_id>/status/pending_packages

    Args:
        system_id (str): String with system id (uuid) or local

    """
    no_cache = request.args.get('no_cache')
    if not is_json_boolean(no_cache):
        return make_error("Invalid value for the no_cache parameter", 500)
    no_cache = is_json_true(no_cache)
    success, result = apimethod_get_pending_packges(system_id, no_cache)
    if not success:
        api_log.error("Error: " + str(result))
        return make_error("Cannot retrieve packages status " + str(result), 500)
    return make_ok(available_updates=result)
コード例 #14
0
def get_pending_packages(system_id):
    """Get pending update packages from a given AlienVault system

    The blueprint handle the following url:
    GET /av/api/1.0/system/<system_id>/status/pending_packages

    Args:
        system_id (str): String with system id (uuid) or local

    """
    no_cache = request.args.get('no_cache')
    if not is_json_boolean(no_cache):
        return make_error("Invalid value for the no_cache parameter", 500)
    no_cache = is_json_true(no_cache)
    success, result = apimethod_get_pending_packges(system_id, no_cache)
    if not success:
        api_log.error("Error: " + str(result))
        return make_error("Cannot retrieve packages status " + str(result), 500)
    return make_ok(available_updates=result)
コード例 #15
0
ファイル: status.py プロジェクト: jpalanco/alienvault-ossim
def get_remote_software_status(system_id):
    """Get the software status from a given AlienVault system or all systems

    The blueprint handle the following url:
    GET /av/api/1.0/system/<system_id>/status/software

    Args:
        system_id (str): String with system id (uuid) local or all

    """
    no_cache = request.args.get('no_cache')
    if not is_json_boolean(no_cache):
        return make_error("Invalid value for the no_cache parameter", 500)
    no_cache = is_json_true(no_cache)

    success, result = only_one_call_without_caching(apimethod_get_remote_software_update)(system_id, no_cache)
    if not success:
        api_log.error("Error: " + str(result))
        return make_error("Cannot retrieve packages status " + str(result), 500)

    return make_ok(**result)
コード例 #16
0
ファイル: network.py プロジェクト: zoe-mora-imdc/Ossim
def put_system_network_interface(system_id, iface):
    promisc = request.args.get("promisc")
    if promisc is not None:
        if not is_json_boolean(promisc):
            current_app.logger.error(
                "network: put_system_network_interface error: Bad param 'promisc='%s'"
                % promisc)
            return make_bad_request("Bad param 'promisc=%s'" % promisc)
    else:
        current_app.logger.error(
            "network: put_system_network_interface error: Missing parameter 'promisc'"
        )
        return make_bad_request("Missing parameters")

    (success, msg) = put_interface(system_id, iface, is_json_true(promisc))
    if not success:
        current_app.logger.error(
            "network: put_system_network_interface error: " + str(msg))
        return make_error(msg, 500)

    return make_ok()
コード例 #17
0
def get_remote_software_status(system_id):
    """Get the software status from a given AlienVault system or all systems

    The blueprint handle the following url:
    GET /av/api/1.0/system/<system_id>/status/software

    Args:
        system_id (str): String with system id (uuid) local or all

    """
    no_cache = request.args.get('no_cache')
    if not is_json_boolean(no_cache):
        return make_error("Invalid value for the no_cache parameter", 500)
    no_cache = is_json_true(no_cache)

    success, result = apimethod_get_remote_software_update(system_id, no_cache)
    if not success:
        api_log.error("Error: " + str(result))
        return make_error("Cannot retrieve packages status " + str(result), 500)

    return make_ok(**result)