NATS wrapper for fast scanner development
Project description
NATS wrapper for fast scanner development
=======================
----
Some instructions for add a new instance of scanner.
----
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
=======================
----
Some instructions for add a new instance of scanner.
----
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
Close
Hashes for nats-scan-wrapper-0.0.3b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaea26c7a809ab6a6a0987e419e64cb20427209e1b5b6911f356d09223fc08f8 |
|
MD5 | 74c9e387339b2a3c14a6139ce0e1e016 |
|
BLAKE2b-256 | 0dcc4699b72709af160fb0214e73b1916e501ab9c279cab33a1ac43d534e743c |
Close
Hashes for nats_scan_wrapper-0.0.3b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac2faeb631885a8d3ff3f731abdc1743807cce9e11268a0b6269735e93da1705 |
|
MD5 | d11791d635f8dc46bba94d979c867481 |
|
BLAKE2b-256 | 2c8ba267be6066a6f7558cae0085c5f7cb84882440c7fac5ea3f3c9a2e1b1446 |