spamtrap_backend.core package

Subpackages

Submodules

spamtrap_backend.core.database module

class spamtrap_backend.core.database.DatabaseHandler(host, port, database_name, indexttl=None)

Bases: object

collection_map = {<class 'spamtrap_backend.datamodels.Email'>: CollectionEnum.email, <class 'spamtrap_backend.datamodels.FeedMsg'>: CollectionEnum.raw, <class 'spamtrap_backend.datamodels.File'>: CollectionEnum.file, <class 'spamtrap_backend.datamodels.NetworkEntity'>: CollectionEnum.network_entity, <class 'spamtrap_backend.datamodels.NetworkEvent'>: CollectionEnum.events, <class 'spamtrap_backend.datamodels.Url'>: CollectionEnum.url}
async connect_db(io_loop=None)
async ensure_index(indexttl=2592000)
async find_file_by_sha512(sha512)
async init_db()
async insert_dm(elem)
async insert_file(elem)
async insert_generic(_id, elem)
async insert_gridfs(filename, data, metadata=None)
async insert_network_entity(_id, elem)
async insert_url(_id, elem)
is_database_up()

Synchronous check of availability of DB host (pymongo is needed anyway).

async retrieve_file(file_id, out_file='./retrieved_')

spamtrap_backend.core.mediator module

class spamtrap_backend.core.mediator.Mediator(docs_to_enrich, docs_to_report, **config)

Bases: object

static check_dir(dump_path)
async dump_to_file(filename, data)
async mediate(in_q, process_q=None, enrich_q=None, report_q=None)

spamtrap_backend.core.message_ingestor module

class spamtrap_backend.core.message_ingestor.AMQPIngestor(ident, secret, host, port, vhost, exchange, routing_key, tls, check_cert)

Bases: MessageIngestor

async ingest(queue)
class spamtrap_backend.core.message_ingestor.HpFeedIngestor(ident, secret, host, port, channels, tls)

Bases: MessageIngestor

async ingest(queue)
class spamtrap_backend.core.message_ingestor.MessageIngestor

Bases: ABC

MAX_RETRIES = 10
RETRY_INTERVAL = 1
static get_message_ingestor(**kwargs)
abstract async ingest(queue)
static populate_ingestors()

Module contents