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 receive from the reader.
  • Detectors: return alerts if anomalies are detected.
  • Schemas: standard data classes use in DetectMate.
 +--------+     +-----------+
 | Parser | --> |  Detector |
 +--------+     +-----------+

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.1.tar.gz (135.1 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.1-py3-none-any.whl (201.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: detectmatelibrary-0.3.1.tar.gz
  • Upload date:
  • Size: 135.1 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.1.tar.gz
Algorithm Hash digest
SHA256 11df9899ef47c800d9b3212519e38d8b97b89ca70896bd85826a212daf838b95
MD5 4227363665fb934d42c831f5e51e5950
BLAKE2b-256 7d8eac9ebd2d1bae9d7ab28292e938e4caa961c3a529bd99bb85683a0d7a66d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for detectmatelibrary-0.3.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for detectmatelibrary-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6cf54a586d9184ab93c0c5bca8dc31f4444ed7b104ecf0c220be7769bf055d32
MD5 49e27589fb2383c4aab01479b3529606
BLAKE2b-256 b14dbb0f2e4c2f6d45990f04510bb2d82fbf56072c8970dcafb8bae0741bf373

See more details on using hashes here.

Provenance

The following attestation bundles were made for detectmatelibrary-0.3.1-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