How to use the greynoise.api.GreyNoise 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 / tests / test_api.py View on Github external
def test_with_api_key(self):
        """API parameter is passed."""
        config = {
            "api_key": "",
            "api_server": "",
            "timeout": "",
        }
        with patch("greynoise.api.load_config") as load_config:
            client = GreyNoise(**config)
            assert client.api_key == config["api_key"]
            assert client.api_server == config["api_server"]
            assert client.timeout == config["timeout"]
            load_config.assert_not_called()
github GreyNoise-Intelligence / pygreynoise / tests / test_api.py View on Github external
def client_without_cache():
    """API client without cache fixture."""
    client = GreyNoise(api_key="", use_cache=False)
    yield client
github GreyNoise-Intelligence / pygreynoise / tests / test_api.py View on Github external
def test_without_api_key(self):
        """API parameter is not passed."""
        config = {
            "api_key": "",
            "api_server": "",
            "timeout": "",
        }
        with patch("greynoise.api.load_config") as load_config:
            load_config.return_value = config
            client = GreyNoise()
            assert client.api_key == config["api_key"]
            assert client.api_server == config["api_server"]
            assert client.timeout == config["timeout"]
            load_config.assert_called()
github GreyNoise-Intelligence / pygreynoise / tests / test_api.py View on Github external
def client():
    """API client fixture."""
    client = GreyNoise(api_key="")
    client.IP_QUICK_CHECK_CACHE.clear()
    client.IP_CONTEXT_CACHE.clear()
    yield client
github GreyNoise-Intelligence / pygreynoise / src / greynoise / cli / parser.py View on Github external
config = load_config()
        if not config["api_key"]:
            prog = os.path.basename(sys.argv[0])
            print(
                "Error: API key not found.\n\n"
                "To fix this problem, please use any of the following methods "
                "(in order of precedence):\n"
                "- Pass it using the -k/--api-key option.\n"
                "- Set it in the GREYNOISE_API_KEY environment variable.\n"
                "- Run {!r} to save it to the configuration file.\n".format(
                    "{} setup".format(prog)
                )
            )
            sys.exit(-1)
        args.api_key = config["api_key"]
        args.api_client = GreyNoise(args.api_key)

    return args
github GreyNoise-Intelligence / pygreynoise / src / greynoise / cli / decorator.py View on Github external
if not config["api_key"]:
                prog_name = context.parent.info_name
                click.echo(
                    "\nError: API key not found.\n\n"
                    "To fix this problem, please use any of the following methods "
                    "(in order of precedence):\n"
                    "- Pass it using the -k/--api-key option.\n"
                    "- Set it in the GREYNOISE_API_KEY environment variable.\n"
                    "- Run {!r} to save it to the configuration file.\n".format(
                        "{} setup".format(prog_name)
                    )
                )
                context.exit(-1)
            api_key = config["api_key"]

        api_client = GreyNoise(
            api_key=api_key, timeout=config["timeout"], integration_name="cli"
        )
        return function(api_client, *args, **kwargs)