@@ -8,10 +8,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
88<div align =" center " >
99<img width =" 60px " src =" https://pts-project.org/android-chrome-512x512.png " alt =" PTS logo " >
1010<h1 >Mongoose</h1 >
11- <p >
12- Lightweight dead-simple Python library to collect, enrich, store and forward
13- network events such as Suricata alerts and network flows
14- </p >
11+ <p >Collect, enrich, store and forward Suricata alerts and network flows.</p >
1512<p >
1613<img src =" https://img.shields.io/badge/License-GPL_v3-8A2BE2 " alt =" License: GPL v3 " >
1714</p >
@@ -25,41 +22,54 @@ network events such as Suricata alerts and network flows
2522
2623![ ] ( https://github.com/PiRogueToolSuite/mongoose/raw/main/docs/_static/diagram.png )
2724
28- Mongoose — a lightweight dead-simple Python library and daemon to collect, enrich, store and forward
29- network events such as Suricata alerts and Deep Packet Inspection flows.
30-
31- ### Purpose
32-
33- Mongoose provides a modular pipeline to ingest network events and flows,
34- enrich them with metadata (for example GeoIP and Community ID), persist
35- short-term state in a SQLite database, and forward processed records to
36- files, webhooks or other sinks. It is designed to be simple to configure,
37- extend and integrate into other applications.
25+ Mongoose is a Python daemon and library for collecting, enriching, storing and
26+ forwarding network events from Suricata and NFStream.
3827
39- ### Overview
40- ** Mongoose** is a versatile Python-based framework designed for the collection,
41- enrichment, and distribution of network security events and traffic flows. It acts
42- as a central hub for processing data from various network monitoring tools, providing a
43- modular and scalable pipeline for security analysts and researchers.
44-
45- At its core, Mongoose utilizes a thread-safe ** pub-sub engine** that allows for
46- concurrent processing of different data streams. Data is collected from sources
47- like Suricata EVE logs and NFStream, published to specific topics, and then
48- consumed by various modules for enrichment (e.g., GeoIP, Community ID), persistent
49- storage (SQLite), or forwarding to external endpoints via webhooks or local files.
50-
51- The project is built with extensibility in mind, making it easy to integrate new
52- data sources and processing logic to adapt to different network monitoring needs.
28+ It runs a thread-safe pub-sub pipeline (` ProcessingQueue ` ) where collectors
29+ publish raw events to topics and subscribers — enricher, SQLite store,
30+ forwarders — consume them concurrently.
5331
5432### Key features
5533
56- - Modular collectors: Suricata EVE, nfstream, file-based replay.
57- - Enrichment: GeoIP lookup, Community ID calculation and custom enrichers.
58- - Pluggable forwarders: file, webhook, Discord (extensible to new sinks).
59- - Lightweight SQLite storage for short-term persistence.
60- - Thread-safe pub-sub engine and safe caches for concurrent ingestion.
34+ - ** Modular collectors** : Suricata EVE (alerts and netflow via Unix socket),
35+ NFStream (live packet capture from a network interface).
36+ - ** Automatic enrichment** : traffic direction (inbound / outbound / local),
37+ Community ID calculation, reverse DNS hostname lookup, event type
38+ classification, and flow risk scoring via a configurable severity cache.
39+ - ** GeoIP enrichment** : MaxMind (GeoLite2-ASN, GeoLite2-City,
40+ GeoLite2-Country) and IP66 databases, with daily automatic database updates.
41+ - ** Pluggable forwarders** : local file output, HTTP(S) webhooks (immediate,
42+ bulk or periodic modes with retry logic and multiple authentication methods),
43+ and Discord (rich embed formatting).
44+ - ** Topic filtering** : forwarders can be scoped to specific topics and filtered
45+ by event attributes.
46+ - ** Drop-in webhook configuration** : new webhook forwarders can be added at
47+ runtime by dropping a YAML file into a watched directory — no restart
48+ required.
49+ - ** SQLite storage** : enriched events are persisted with configurable history
50+ pruning by record count or age.
51+ - ** Sharded LRU cache** : thread-safe severity cache with optional TTL used for
52+ flow risk scoring.
53+ - ** Singleton engine** : a single ` Engine ` instance manages the full component
54+ lifecycle (start, stop, reload).
55+ - ** Systemd and PiRogue integration** : the CLI daemon supports ` sd_notify ` and
56+ reads the isolated interface from ` pirogue-admin-client ` when available.
57+
58+ ### Pipeline topics
59+
60+ Events flow through the following pub-sub topics:
61+
62+ | Topic | Description |
63+ | ---| ---|
64+ | ` network-dpi ` | Raw DPI flows from NFStream |
65+ | ` network-alert ` | Raw Suricata alerts |
66+ | ` network-flow ` | Raw Suricata netflow records |
67+ | ` enriched-network-dpi ` | Enriched DPI flows |
68+ | ` enriched-network-alert ` | Enriched Suricata alerts |
69+ | ` enriched-network-flow ` | Enriched netflow records |
6170
6271### Installation
72+
6373Install in a virtual environment and editable mode for development:
6474
6575``` bash
@@ -68,27 +78,95 @@ pip install -e .
6878```
6979
7080### CLI usage
81+
82+ The package installs a ` mongoosed ` daemon entry-point:
83+
7184``` bash
7285# show top-level help
73- mongoose --help
86+ mongoosed --help
87+
88+ # run with a configuration file
89+ mongoosed --config /etc/mongoose/mongoose.yaml
7490
75- # run mongoose with a configuration file
76- mongoose --config docs/example_config_test.yaml
91+ # override the network interface used by NFStream
92+ mongoosed --config mongoose.yaml --interface eth0
93+
94+ # set logging verbosity
95+ mongoosed --config mongoose.yaml --logging-level DEBUG
7796```
7897
7998### Python library usage
80- Use Mongoose as a library when you can use in your application. The snippet
81- below shows how to instanciate the engine with a config and run it.
82- Replace the config path with your own file.
8399
84100``` python
85101import time
86102from mongoose.core.engine import Engine
87103
88- # Create an Engine from a configuration file and run a single cycle.
89- configuration_file = " config.yaml"
90- engine = Engine(configuration_file)
104+ engine = Engine(" config.yaml" )
91105engine.start()
92106time.sleep(6 )
93107engine.stop()
94108```
109+
110+ ### Configuration
111+
112+ Configured via a YAML file. All keys live under a top-level ` configuration ` key.
113+
114+ ``` yaml
115+ configuration :
116+ collector :
117+ suricata :
118+ socket_path : " /run/suricata.socket" # Suricata Unix socket
119+ collect_alerts : true # collect Suricata alerts
120+ collect_netflow : false # collect Suricata netflow records
121+ enable : true
122+
123+ nf_stream :
124+ interface : " eth0" # network interface for live capture
125+ active_timeout : 120 # seconds before an active flow expires
126+ enable : false
127+
128+ enrichment :
129+ geoip :
130+ source : " ip66" # "ip66" (default) or "maxmind"
131+ enable : true
132+
133+ forwarder :
134+ webhooks :
135+ - url : " https://hooks.example.com/ingest"
136+ auth_type : " bearer" # none | basic | bearer | header
137+ auth_token : " ${WEBHOOK_AUTH_TOKEN}"
138+ verify_ssl : true
139+ retry_count : 3
140+ retry_delay : 5.0
141+ timeout : 10.0
142+ mode : " immediate" # immediate | bulk | periodic
143+ bulk_size : 10
144+ periodic_interval : 5.0
145+ periodic_rate : 10
146+ topics :
147+ - " enriched-network-dpi"
148+ - " enriched-network-alert"
149+ enable : true
150+
151+ database_path : " mongoose.db"
152+
153+ history :
154+ max_duration_days : 14 # keep records for at most 14 days
155+ max_records : null # optional hard cap on row count per table
156+ enable : true
157+
158+ cache :
159+ severity :
160+ max_size : 1024 # maximum entries in the severity LRU cache
161+ ttl_seconds : null # optional TTL; null means entries never expire
162+ enable : true
163+
164+ extra_configuration_dir : " /var/lib/mongoose"
165+ ` ` `
166+
167+ #### Drop-in webhook configuration
168+
169+ Place a YAML file matching the ` WebhookForwarderConfiguration` schema inside
170+ ` <extra_configuration_dir>/webhook.d/` . The engine watches this directory and
171+ activates new forwarders when a file is created, and deactivates them when it
172+ is deleted.
0 commit comments