Пример #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.command == 'output':
        configure_output(options)

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

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

    elif options.command == 'terraform':
        terraform_handler(options)
Пример #2
0
def lambda_handler(options, config):
    """Handle all Lambda CLI operations"""

    if options.subcommand == 'deploy':
        # Check for valid credentials
        if not check_credentials():
            return
        # Make sure the Terraform code is up to date
        if not terraform_generate(config=config):
            return
        LOGGER_CLI.info('Deploying: %s', ' '.join(options.processor))
        deploy(options, config)

    elif options.subcommand == 'rollback':
        # Check for valid credentials
        if not check_credentials():
            return
        # Make sure the Terraform code is up to date
        if not terraform_generate(config=config):
            return
        LOGGER_CLI.info('Rolling back: %s', ' '.join(options.processor))
        rollback(options, config)

    elif options.subcommand == 'test':
        LOGGER_CLI.info('Testing: %s', ' '.join(options.processor))
        stream_alert_test(options, config)
Пример #3
0
 def _lambda_runner(self, options):
     """Handle all Lambda CLI operations."""
     if options.subcommand == 'deploy':
         self.deploy(options)
     elif options.subcommand == 'rollback':
         raise NotImplementedError
     elif options.subcommand == 'test':
         stream_alert_test(options)
Пример #4
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)
Пример #5
0
def lambda_runner(options):
    """Handle all Lambda CLI operations"""
    if options.subcommand == 'deploy':
        deploy(options)

    elif options.subcommand == 'rollback':
        rollback(options)

    elif options.subcommand == 'test':
        stream_alert_test(options)
Пример #6
0
 def _lambda_runner(self, options):
     """Handle all Lambda CLI operations."""
     if options.subcommand == 'deploy':
         self.deploy(options)
     elif options.subcommand == 'rollback':
         self.rollback()
         targets = [
             'module.stream_alert_{}'.format(x)
             for x in self.config['clusters'].keys()
         ]
         self._tf_runner(targets=targets)
     elif options.subcommand == 'test':
         stream_alert_test(options)
Пример #7
0
def lambda_handler(options):
    """Handle all Lambda CLI operations"""

    if options.subcommand == 'deploy':
        # Make sure the Terraform code is up to date
        terraform_generate(config=CONFIG)
        deploy(options)

    elif options.subcommand == 'rollback':
        # Make sure the Terraform code is up to date
        terraform_generate(config=CONFIG)
        rollback(options)

    elif options.subcommand == 'test':
        stream_alert_test(options)