def __set_server_keys(client, prints_manager, integration_params,
                      integration_name):
    """Adds server configuration keys using the demisto_client.

    Args:
        client (demisto_client): The configured client to use.
        prints_manager (ParallelPrintsManager): Print manager object.
        integration_params (dict): The values to use for an integration's parameters to configure an instance.
        integration_name (str): The name of the integration which the server configurations keys are related to.

    """
    if 'server_keys' not in integration_params:
        return

    prints_manager.add_print_job(
        'Setting server keys for integration: {}'.format(integration_name),
        print_color, 0, LOG_COLORS.GREEN)

    data = {'data': {}, 'version': -1}

    for key, value in integration_params.get('server_keys').items():
        data['data'][key] = value

    update_server_configuration(
        client=client,
        server_configuration=integration_params.get('server_keys'),
        error_msg='Failed to set server keys')
def __set_server_keys(client, logging_manager, integration_params, integration_name):
    """Adds server configuration keys using the demisto_client.

    Args:
        client (demisto_client): The configured client to use.
        logging_manager (ParallelLoggingManager): logging manager object.
        integration_params (dict): The values to use for an integration's parameters to configure an instance.
        integration_name (str): The name of the integration which the server configurations keys are related to.

    """
    if 'server_keys' not in integration_params:
        return

    logging_manager.debug(f'Setting server keys for integration: {integration_name}')

    data = {
        'data': {},
        'version': -1
    }

    for key, value in integration_params.get('server_keys').items():
        data['data'][key] = value

    update_server_configuration(
        client=client,
        server_configuration=integration_params.get('server_keys'),
        error_msg='Failed to set server keys',
        logging_manager=logging_manager
    )
def set_docker_hardening_for_build(client, prints_manager):
    """Sets docker hardening configuration

    Args:
        client (demisto_client): The configured client to use.
        prints_manager (ParallelPrintsManager): Print manager object

    Returns:
        response_data: The response data
        status_code: The response status code
    """
    host = client.api_client.configuration.host
    installed_content_message = \
        '\nMaking "POST" request to server - "{}" to set docker hardening server configuration.'.format(host)
    prints_manager.add_print_job(installed_content_message, print_color, 0, LOG_COLORS.GREEN)

    # make request to update server configs
    server_configuration = {
        'docker.cpu.limit': '1.0',
        'docker.run.internal.asuser': '******',
        'limit.docker.cpu': 'true',
        'python.pass.extra.keys': '--memory=1g##--memory-swap=-1##--pids-limit=256##--ulimit=nofile=1024:8192'
    }
    error_msg = "Failed to set docker hardening server config - with status code "

    return update_server_configuration(client, server_configuration, error_msg)
def set_marketplace_gcp_bucket_for_build(client, prints_manager, branch_name, ci_build_number):
    """Sets custom marketplace GCP bucket based on branch name and build number

    Args:
        client (demisto_client): The configured client to use.
        prints_manager (ParallelPrintsManager): Print manager object
        branch_name (str): GitHub branch name
        ci_build_number (str): CI build number

    Returns:
        response_data: The response data
        status_code: The response status code
    """
    host = client.api_client.configuration.host
    installed_content_message = \
        '\nMaking "POST" request to server - "{}" to set GCP bucket server configuration.'.format(host)
    prints_manager.add_print_job(installed_content_message, print_color, 0, LOG_COLORS.GREEN)

    # make request to update server configs
    server_configuration = {
        'content.pack.verify': 'false',
        'marketplace.initial.sync.delay': '0',
        'content.pack.ignore.missing.warnings.contentpack': 'true',
        'marketplace.bootstrap.bypass.url':
            'https://storage.googleapis.com/marketplace-ci-build/content/builds/{}/{}'.format(
                branch_name, ci_build_number)

    }
    error_msg = "Failed to set GCP bucket server config - with status code "
    return update_server_configuration(client, server_configuration, error_msg)
Beispiel #5
0
import argparse

import demisto_client

from Tests.tools import update_server_configuration

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description=
        "Unlocks an integration, script or a playbook in Cortex XSOAR.")
    parser.add_argument("type", choices=["integration", "script", "playbook"])
    parser.add_argument("name")
    args = parser.parse_args()
    client = demisto_client.configure(verify_ssl=False)
    update_server_configuration(
        client,
        {f"content.unlock.{args.type}s": args.name},
        "Could not update configurations",
    )
    print(f"{args.type}: {args.name} unlocked.")