NATS wrapper for fast scanner development
Project description
from scanner_api.wrappers import scanner_wrapper
- Define the worker function which takes two argumentw (source, data).
source - infromation about publisher (e.g. nmap.reporter.masscan - this can catch only in ‘nmap.**’) data - dict with JSON data for scanner, which NATS scheduler send
worker returns a list with data to be sent to next scanner or reporter. (each element of list will be sent as separate message)
You can redefine log format according logging module.
- def worker(source, data, meta):
result = [] result = processing…(data) logging.info(“i do work”) logging.warning(“i warn you”) logging.error(“i made a mistake”) return result
Make a wrapper with define scanner name. The data will be collected from NATS by this name. (e.g. name.***.*** or name). Also name its a queue name.
Define NATS host addr.
- wrapper = scanner_wrapper(
nats=[“nats://127.0.0.1:4222”], name=”reporter”)
Run by passing an argument worker function. This is blocking call!
wrapper.run(worker)
LOG FORMAT: Connected to nats. Started module named ‘{name}’ Received from ‘{subject}’: {data} Starting ‘{name}’ Result: {result} n Was sent to ‘{pipeline}’
- Here:
{name} - scanner name {subject} - queue name {data} - json from NATS {result} - out data from worker function {pipeline} - new addr in NATS queue
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for nats-scan-wrapper-0.1.9.9.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c9cb9998a58d84c107b693586183c63ac0e1427996a53d730a904146329f5da |
|
MD5 | 004ce83e61cc4dd8317bbd419afbf9b3 |
|
BLAKE2b-256 | 0533f85db293b5aa64f8e041faae1301610d873dd99681ae9b92e2d25a96f544 |
Hashes for nats_scan_wrapper-0.1.9.9.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b9dd3ffb2e8d5ab07281586dbc0e5a24f7f2a1be2965e59e8c283e80172ff79 |
|
MD5 | ddec2e3181b8c17d03e6211b9b3b2d5a |
|
BLAKE2b-256 | 2fc79d0ff981bfe76daeefeb718e3dc0c1f3edbe6196cd21941160df47a4f853 |