Ejemplo n.º 1
0
def cli_runner(options):
    """Main Stream Alert CLI handler

    Args:
        options (dict): command line arguments passed from the argparser.
            Contains the following keys for terraform commands:
                (command, subcommand, target)
            Contains the following keys for lambda commands:
                (command, subcommand, env, func, source)
    """
    cli_load_message = 'Issues? Report here: https://github.com/airbnb/streamalert/issues'
    LOGGER_CLI.info(cli_load_message)

    if options.debug:
        set_logger_levels('DEBUG')

    if options.command == 'output':
        configure_output(options)

    elif options.command == 'lambda':
        lambda_handler(options, CONFIG)

    elif options.command == 'live-test':
        stream_alert_test(options, CONFIG)

    elif options.command == 'validate-schemas':
        stream_alert_test(options, CONFIG)

    elif options.command == 'terraform':
        terraform_handler(options, CONFIG)

    elif options.command == 'configure':
        configure_handler(options)

    elif options.command == 'athena':
        athena_handler(options, CONFIG)

    elif options.command == 'metrics':
        _toggle_metrics(options)

    elif options.command == 'create-alarm':
        _create_alarm(options)

    elif options.command == 'app':
        _app_handler(options)

    elif options.command == 'kinesis':
        kinesis_handler(options, CONFIG)

    elif options.command == 'threat_intel':
        _threat_intel_handler(options, CONFIG)

    elif options.command == 'threat_intel_downloader':
        threat_intel_downloader_handler(options, CONFIG)

    elif options.command == 'rule-table':
        rule_table_handler(options, CONFIG)
Ejemplo n.º 2
0
def cli_runner(args):
    """Main StreamAlert CLI handler

    Args:
        options (argparse.Namespace): command line arguments passed from the argparser.
            Contains the following keys for terraform commands:
                (command, subcommand, target)
            Contains the following keys for lambda commands:
                (command, subcommand, env, func, source)
    Returns:
        bool: False if errors occurred, True otherwise
    """
    config = CLIConfig()

    set_logger_levels(args.debug)

    LOGGER.info(
        'Issues? Report here: https://github.com/airbnb/streamalert/issues')

    cmds = {
        'app':
        lambda opts: app_handler(opts, config),
        'athena':
        lambda opts: athena_handler(opts, config),
        'build':
        lambda opts: terraform_build_handler(opts, config),
        'clean':
        lambda opts: terraform_clean_handler(),
        'configure':
        lambda opts: configure_handler(opts, config),
        'create-alarm':
        lambda opts: _create_alarm_handler(opts, config),
        'create-cluster-alarm':
        lambda opts: _create_alarm_handler(opts, config),
        'custom-metrics':
        lambda opts: _custom_metrics_handler(opts, config),
        'deploy':
        lambda opts: deploy_handler(opts, config),
        'destroy':
        lambda opts: terraform_destroy_handler(opts, config),
        'generate':
        lambda opts: terraform_generate_handler(config, check_creds=False),
        'init':
        lambda opts: terraform_init(opts, config),
        'kinesis':
        lambda opts: kinesis_handler(opts, config),
        'list-targets':
        lambda opts: terraform_list_targets(config),
        'output':
        lambda opts: output_handler(opts, config),
        'rollback':
        lambda opts: rollback_handler(opts, config),
        'rule-staging':
        lambda opts: rule_staging_handler(opts, config),
        'status':
        lambda opts: _status_handler(config),
        'test':
        lambda opts: test_handler(opts, config),
        'threat-intel':
        lambda opts: _threat_intel_handler(opts, config),
        'threat-intel-downloader':
        lambda opts: threat_intel_downloader_handler(opts, config),
    }

    result = cmds[args.command](args)
    LOGGER.info('Completed')
    return result