Spamhaus module

class Spamhaus.Spamhaus(config: Config)

Bases: object

Class used for reading responses from Spamhaus API

Initializes the client with API key provided in config file

Parameters:

config – Config object

get_json(*args)
static is_security_flagged(response: dict) bool
static read(ip: str, key: str, log: Log, config: Config, cache: Cache)

Returns response from API and writes to cache

Parameters:
  • path – path to API endpoint

  • key – key to use when writing to cache

  • log – Log object

  • config – Config object

  • cache – Cache object

Returns:

response from API

Return type:

dict | None

search(value)

Returns response from spamhaus api. We search the databases defined in the configuration variables, they can be: [“Spamhaus”][“Ip_list”] : “SBL” - Spamhaus Block List “XBL” - Exploits Block List “PBL” - The Policy Block List “AUTHBL” - Auth Blocklist [“Spamhaus”][“Domains_list”] : “DBL” - Domain Block List “ZRD” - Zero Reputation Domains :param value: value of the searched object :return: searched object :rtype: dict