Skip to main content

DetectMate Library for log processing components

Project description

DetectMateLibrary

Main library to run the different components in DetectMate.

Main structure

The library contains the next components:

  • Parsers: parse the logs received from the reader.
  • Detectors: return alerts if anomalies are detected.
  • Alert Aggregation: aggregate the alerts produced by the detectors.
  • Schemas: standard data classes use in DetectMate.
 +--------+     +-----------+    +-------------------+
 | Parser | --> |  Detector | -> | Alert Aggregation |
 +--------+     +-----------+    +-------------------+

Developer setup:

Step 1: Install python dependencies

Set up the dev environment and install pre-commit hooks:

uv sync --dev
uv run prek install

Step 2: Install Protobuf dependencies

To install in Linux do:

sudo apt install -y protobuf-compiler
protoc --version

This dependency is only needed if a proto file is modified. To compile the proto file do:

protoc --proto_path=src/detectmatelibrary/schemas/ --python_out=src/detectmatelibrary/schemas/ src/detectmatelibrary/schemas/schemas.proto

Step 3: Run unit tests

Run the tests:

uv run pytest -q

Run the tests with coverage (add --cov-report=html to generate an HTML report):

uv run pytest --cov=. --cov-report=term-missing

Workspace generator (mate create)

DetectMateLibrary includes a small CLI helper to bootstrap standalone workspaces for custom parsers and detectors. This is useful if you want to develop and test components in isolation while still using the same library and schemas.

Usage

The CLI entry point is mate with a create command:

mate create --type <parser|detector> --name <workspace_name> --dir <target_dir>
Option Description
--type Component type to generate:
- parser: CoreParser-based template
- detector: CoreDetector-based template
--name Name of the component and package:
- Creates package dir: <target_dir>/<name>/
- Creates main file: <name>.py
- Derives class names: <Name> and <Name>Config
--dir Directory where the workspace will be created

What gets generated

For example:

mate create --type parser --name custom_parser --dir ./workspaces/custom_parser

will create:

workspaces/custom_parser/          # workspace root
├── custom_parser/                 # Python package
│   ├── __init__.py
│   └── custom_parser.py           # CoreParser-based template
├── tests/
│   └── test_custom_parser.py      # generated from template to test custom_parser
├── data.json                      # example data to run the code
├── LICENSE.md                     # copied from main project
├── .gitignore                     # copied from main project
├── .pre-commit-config.yaml        # copied from main project
├── pyproject.toml                 # minimal project + dev extras
└── README.md                      # setup instructions

Documentation

Contribution

We're happily taking patches and other contributions. Please see the following links for how to get started:

If you encounter any bugs, please create an issue on Github.

License

EUPL-1.2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

detectmatelibrary-0.3.2.tar.gz (89.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

detectmatelibrary-0.3.2-py3-none-any.whl (129.9 kB view details)

Uploaded Python 3

File details

Details for the file detectmatelibrary-0.3.2.tar.gz.

File metadata

  • Download URL: detectmatelibrary-0.3.2.tar.gz
  • Upload date:
  • Size: 89.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for detectmatelibrary-0.3.2.tar.gz
Algorithm Hash digest
SHA256 7d245600ebc741fe65b33c6703534fb75d3a8f2645d30f6f195c33c5ca29db70
MD5 3b19618829868cd2980f5868289c02aa
BLAKE2b-256 c8f3dfd1442490cb74794864914152615c8823065085b281ec02e4f3ba043522

See more details on using hashes here.

Provenance

The following attestation bundles were made for detectmatelibrary-0.3.2.tar.gz:

Publisher: python-publish.yml on ait-detectmate/DetectMateLibrary

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file detectmatelibrary-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for detectmatelibrary-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 002c9c1912474048d6a0de05e3fc5b44ab9064aea76a45dc3354a936e820fb5d
MD5 2cb3cb2fc0abf59ec2ae7ed5f14d63d8
BLAKE2b-256 f19e85f85435a3048eb242583dfd7e0f67dd77d4b6c94700da9895ad2095f7a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for detectmatelibrary-0.3.2-py3-none-any.whl:

Publisher: python-publish.yml on ait-detectmate/DetectMateLibrary

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page