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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1291087f1497698a7be02b3f54cb749edb61b7ed257df50a0e824dab0966ccb8 |
|
MD5 | da719e21d5fa8977402f86641b0ec1a5 |
|
BLAKE2b-256 | 1ed6b6b3d1fcfa0a8121403b77e89fc88e2d5681259915e3055ba59ad94e9bb5 |
Hashes for nats_scan_wrapper-0.1.9.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dae599dcec09fe1d7f95ef2b83b6dceec1db5c1178667c375774682238d2c753 |
|
MD5 | 6409c366f8aeb6381b1582f7c4277087 |
|
BLAKE2b-256 | 19139aaf0174fb10465ffefc3148fb54aa75efadf4cf4b88514db71b3ed3eeec |