How to use the greynoise.cli.decorator.handle_exceptions function in greynoise

To help you get started, we’ve selected a few greynoise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GreyNoise-Intelligence / pygreynoise / src / greynoise / cli / subcommand.py View on Github external
@handle_exceptions
def analyze(
    context, api_client, api_key, input_file, output_file, output_format, verbose
):
    """Analyze the IP addresses in a log file, stdin, etc."""
    if input_file is None:
        if sys.stdin.isatty():
            output = [
                context.command.get_usage(context),
                (
                    "Error: at least one text file must be passed "
                    "either through the -i/--input_file option or through a shell pipe."
                ),
            ]
            click.echo("\n\n".join(output))
            context.exit(-1)
        else:
github GreyNoise-Intelligence / pygreynoise / src / greynoise / cli / subcommand.py View on Github external
@handle_exceptions
def filter(context, api_client, api_key, input_file, output_file, noise_only):
    """Filter the noise from a log file, stdin, etc."""
    if input_file is None:
        if sys.stdin.isatty():
            output = [
                context.command.get_usage(context),
                (
                    "Error: at least one text file must be passed "
                    "either through the -i/--input_file option or through a shell pipe."
                ),
            ]
            click.echo("\n\n".join(output))
            context.exit(-1)
        else:
            input_file = click.open_file("-")
    if output_file is None:
github GreyNoise-Intelligence / pygreynoise / src / greynoise / cli / subcommand.py View on Github external
@handle_exceptions
def interesting(context, api_client, api_key, input_file, ip_address):
    """Report one or more IP addresses as "interesting"."""
    ip_addresses = get_ip_addresses(context, input_file, ip_address)
    results = [
        api_client.interesting(ip_address=ip_address) for ip_address in ip_addresses
    ]
    return results