예제 #1
0
    def setup_subparser(cls, subparser):
        """Add the output get subparser: manage.py output get [options]"""
        outputs = sorted(StreamAlertOutput.get_all_outputs().keys())

        get_parser = generate_subparser(
            subparser,
            'get',
            description=cls.description,
            help=cls.description,
            subcommand=True,
        )

        # Add the positional arg of service
        get_parser.add_argument(
            'service',
            choices=outputs,
            metavar='SERVICE',
            help=
            'Service to pull configured outputs and their secrets, select from: {}'
            .format(', '.join(outputs)))

        # Add the optional ability to pass multiple descriptors
        get_parser.add_argument(
            '--descriptors',
            '-d',
            nargs="+",
            default=False,
            help=
            'Pass descriptor and service to pull back the relevant configuration'
        )
예제 #2
0
    def setup_subparser(cls, subparser):
        """Add generate-skeleton subparser to the output subparser"""
        outputs = sorted(StreamAlertOutput.get_all_outputs().keys())

        # Create the generate-skeleton parser
        generate_skeleton_parser = generate_subparser(
            subparser,
            'generate-skeleton',
            description=cls.description,
            help=cls.description,
            subcommand=True)

        # Add the optional ability to pass services
        generate_skeleton_parser.add_argument(
            '--services',
            choices=outputs,
            nargs='+',
            metavar='SERVICE',
            default=outputs,
            help=
            'Pass the services to generate the skeleton for from services: {}'.
            format(', '.join(outputs)))

        # Add the optional file flag
        generate_skeleton_parser.add_argument(
            '--file',
            '-f',
            default=OUTPUTS_FILE,
            help='File to write to, relative to the current working directory')
예제 #3
0
    def setup_subparser(cls, subparser):
        """Setup: manage.py output set [options]

        Args:
            outputs (list): List of available output services
        """
        outputs = sorted(StreamAlertOutput.get_all_outputs().keys())

        set_parser = generate_subparser(subparser,
                                        'set',
                                        description=cls.description,
                                        help=cls.description,
                                        subcommand=True)

        # Add the required positional arg of service
        set_parser.add_argument(
            'service',
            choices=outputs,
            metavar='SERVICE',
            help=
            'Create a new StreamAlert output for one of the available services: {}'
            .format(', '.join(outputs)))

        # Add the optional update flag, which allows existing outputs to be updated
        set_parser.add_argument(
            '--update',
            '-u',
            action='store_true',
            default=False,
            help='If the output already exists, overwrite it')
예제 #4
0
def test_output_loading():
    """OutputDispatcher - Loading Output Classes"""
    loaded_outputs = set(StreamAlertOutput.get_all_outputs())
    # Add new outputs to this list to make sure they're loaded properly
    expected_outputs = {
        'aws-firehose', 'aws-lambda', 'aws-s3', 'aws-ses', 'aws-sns',
        'aws-sqs', 'aws-cloudwatch-log', 'carbonblack', 'demisto', 'github',
        'jira', 'komand', 'pagerduty', 'pagerduty-v2', 'pagerduty-incident',
        'phantom', 'slack', 'teams'
    }
    assert_count_equal(loaded_outputs, expected_outputs)
예제 #5
0
    def setup_subparser(cls, subparser):
        """Add the output list subparser: manage.py output list [options]"""
        outputs = sorted(StreamAlertOutput.get_all_outputs().keys())

        list_parser = generate_subparser(
            subparser,
            'list',
            description=cls.description,
            help=cls.description,
            subcommand=True,
        )

        # Add the optional arg of service
        list_parser.add_argument(
            '--service',
            '-s',
            choices=outputs,
            default=outputs,
            nargs='*',
            metavar='SERVICE',
            help=
            'Pass Services to list configured output descriptors, select from: {}'
            .format(', '.join(outputs)))
예제 #6
0
def test_user_defined_properties():
    """OutputDispatcher - User Defined Properties"""
    for output in list(StreamAlertOutput.get_all_outputs().values()):
        props = output.get_user_defined_properties()
        # The user defined properties should at a minimum contain a descriptor
        assert_is_not_none(props.get('descriptor'))