mentat.services.whois module

Internal whois library.

Module contents

mentat.services.whois.WhoisModule

Generic whois lookup module.

mentat.services.whois.FileWhoisModule

Whois lookup module capable of loading data from JSON files.

mentat.services.whois.SqldbWhoisModule

Whois lookup module capable of loading data from SQL databases.

mentat.services.whois.WhoisService

Whois lookup service, container for multiple whois lookup modules.

mentat.services.whois.WhoisServiceManager

Whois lookup service manager, capable of understanding Mentat core configurations.

class mentat.services.whois.FileWhoisModule(whois_file)[source]

Bases: WhoisModule

This whois module is capable of loading network records from JSON files.

setup(**kwargs)[source]

Perform full setup of internal whois lookup table by loading the data from external file.

class mentat.services.whois.SqldbWhoisModule(storage_manager=None)[source]

Bases: WhoisModule

This whois module is capable of loading network records from SQL database.

setup(**kwargs)[source]

Perform full setup of internal whois lookup table by loading the data from SQL database.

class mentat.services.whois.WhoisModule[source]

Bases: object

Base class for all whois lookup modules. This class provides general lookup algorithm. More modules may be build on top of this module simply by overriding the mentat.services.whois.WhoisModule.setup() method and focus on the task of obtaining list of mentat.datatype.internal.NetworkRecord objects, which can be then simply passed to the parent implementation.

add_network(network)[source]

Add given network into internal whois lookup table.

Parameters

network (list) – Instance of mentat.datatype.internal.NetworkRecord.

Returns

Self

Return type

mentat.services.whois.WhoisModule

lookup(arg)[source]

Search for relevant records for given IP or email address withing internal whois lookup table.

lookup_abuse(arg, getall=False)[source]

Search for relevant records for given IP or email address withing internal whois lookup table.

setup(networks)[source]

Setup whois module internals. This method is intended to be subclassed and then called from subclass with a list of neworks that should be processed into internal database format. The subclasses should only take care of providing this list of network and use the service of this method for the rest.

This method does full rewrite of all internal structures to enable easy refresh feature.

Parameters

networks (list) – List of mentat.datatype.internal.NetworkRecord objects.

Returns

Self

Return type

mentat.services.whois.WhoisModule

status()[source]

Determine and return the status of internal whois lookup table.

Returns

Dictionary containing various subkeys.

Return type

dict

class mentat.services.whois.WhoisService(modules=None)[source]

Bases: object

Implementation of more complex whois service capable of encapsulating multiple instances of mentat.services.whois.WhoisModule.

add_module(module)[source]

Add given module into internal registry.

lookup(arg)[source]

Perform lookup of given IP address and return list of all relevant network records.

lookup_abuse(arg, getall=False)[source]

Search for relevant records for given IP or email address withing internal whois lookup table.

setup()[source]

Perform setup of all whois modules in internal registry. This method will cause refreshing/reloading of all internal lookup tables.

status()[source]

Determine the status of all whois modules in internal registry.

class mentat.services.whois.WhoisServiceManager(core_config, updates=None)[source]

Bases: object

Class representing a custom whois service manager capable of understanding and parsing Mentat system core configurations and enabling easy way of unified bootstrapping of mentat.services.whois.WhoisService service.

service()[source]

Return handle to whois service according to internal configurations.

Returns

Reference to whois service object.

Return type

mentat.services.whois.WhoisService

mentat.services.whois.init(core_config, updates=None)[source]

(Re-)Initialize WhoisServiceManager instance at module level and store the refence within module.

mentat.services.whois.manager()[source]

Obtain reference to WhoisServiceManager instance stored at module level.

mentat.services.whois.service()[source]

Obtain reference to WhoisService instance from module level manager.