Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
ad5ef58
update github workflow to use the right DetectMateService branch for …
ernstleierzopf Feb 1, 2026
8b821a3
update variable in github workflow.
ernstleierzopf Feb 1, 2026
e108c62
first doc commit
ipmach Feb 2, 2026
4689b1c
Merge pull request #48 from ait-detectmate/main
whotwagner Feb 2, 2026
ebbe23f
First working version of the docs and first draft of the schemas doc
ipmach Feb 2, 2026
400ea01
first draft overall_architecture
ipmach Feb 2, 2026
17b02b6
removed branch matching between DetectMateService and DetectMateLibrary.
ernstleierzopf Feb 2, 2026
ec3d85b
add first draft parser documentation
ipmach Feb 3, 2026
8733397
add detector first draft
ipmach Feb 3, 2026
f910763
first draft databuffer
ipmach Feb 4, 2026
794b458
minor doc changes
ipmach Feb 4, 2026
f962f48
first draft version template matcher
ipmach Feb 4, 2026
1ffeb6b
ADD json parser draft
ipmach Feb 4, 2026
d700212
add randome detetor draft
ipmach Feb 4, 2026
d38cbdc
fix github workflow to use shared venv for testing.
ernstleierzopf Feb 6, 2026
f227a17
add --dev to tests.
ernstleierzopf Feb 6, 2026
1bcffc0
Merge pull request #50 from ait-detectmate/development
ernstleierzopf Feb 6, 2026
0e303de
Merge pull request #45 from ait-detectmate/workflow-actions-branching
whotwagner Feb 9, 2026
26fc64c
add persistency
viktorbeck98 Feb 11, 2026
a058d43
move persistency to utils
viktorbeck98 Feb 11, 2026
455dcf7
resolve prek issues
viktorbeck98 Feb 11, 2026
1818de9
add numpy as dependency
viktorbeck98 Feb 11, 2026
d344623
add polars and pandas as dependency (temporary -> will open new issue)
viktorbeck98 Feb 11, 2026
c755b93
add pipeline
ipmach Feb 11, 2026
9750bae
temporally remove detect service from pipeline
ipmach Feb 11, 2026
a55b409
Merge branch 'development' into docs_impl
ipmach Feb 11, 2026
8156971
test pipeline
ipmach Feb 11, 2026
10216e1
correct type
ipmach Feb 11, 2026
e6a72d2
Move persistency tests to test_utils folder
ipmach Feb 11, 2026
5c69311
Detector now only returns booleans
ipmach Feb 11, 2026
359f98e
Merge pull request #51 from ait-detectmate/feat/persistency
ipmach Feb 11, 2026
5a411d6
adapt detector config and detectors + write and adapt tests
viktorbeck98 Feb 11, 2026
b75f4e3
Add first version of fromto
ipmach Feb 11, 2026
aaa4599
Remove readers
ipmach Feb 11, 2026
6f13d8f
Modify config default
ipmach Feb 11, 2026
b1c083b
remove outputs
ipmach Feb 11, 2026
e8364d8
update readme
ipmach Feb 11, 2026
bef2bc0
add docs for persistency and auto-config
viktorbeck98 Feb 11, 2026
17f83df
remove None
ipmach Feb 11, 2026
9af6527
add json compatibility
ipmach Feb 12, 2026
39b678d
improve tests code
ipmach Feb 12, 2026
b15dae1
Add compatibility with yaml
ipmach Feb 12, 2026
0608408
add more tests
ipmach Feb 12, 2026
6c0bf2d
change log to debug
ipmach Feb 12, 2026
dcb4632
improve intallation page
ipmach Feb 13, 2026
c15872b
improve overall architecture
ipmach Feb 13, 2026
abb87e2
add -s to pytest to see details in CI runs.
ernstleierzopf Feb 13, 2026
81e5e61
Merge branch 'development' of github.com:ait-detectmate/DetectMateLib…
ernstleierzopf Feb 13, 2026
96e8c7f
improve schema.md
ipmach Feb 13, 2026
09abf9d
parser improve
ipmach Feb 13, 2026
b40baba
improve detector
ipmach Feb 13, 2026
5b2f0eb
imporve tempalte matcher
ipmach Feb 13, 2026
ba5a55b
add again the CI and update docs
ipmach Feb 13, 2026
b535866
Merge branch 'development' into docs_impl
ipmach Feb 13, 2026
930707b
update uv.lock
ipmach Feb 13, 2026
9071efb
remove empty instances from .to_dict() output
viktorbeck98 Feb 13, 2026
8f1cd94
add another default config
viktorbeck98 Feb 13, 2026
1dc5295
remove unused logs file
viktorbeck98 Feb 13, 2026
7e38482
Remove checks from schemas
ipmach Feb 13, 2026
305f277
minor change
ipmach Feb 13, 2026
c606304
move from_to to helper folder
ipmach Feb 13, 2026
225e7c3
Merge pull request #55 from ait-detectmate/refactor-common
viktorbeck98 Feb 13, 2026
842d2f3
merge with development
ipmach Feb 13, 2026
4167223
Merge branch 'development' into adapt/config_and_config-engine
viktorbeck98 Feb 13, 2026
cb05a1b
integration tests with DetectMateService temporal comment it
ipmach Feb 13, 2026
9afde22
resolve failing test
viktorbeck98 Feb 13, 2026
d6dccd3
remove unnecessary comments
viktorbeck98 Feb 13, 2026
b26ee4e
Merge pull request #54 from ait-detectmate/adapt/config_and_config-en…
ipmach Feb 13, 2026
ae5b91f
exchange old config with new config
viktorbeck98 Feb 17, 2026
6d8d3fb
update documentation detectors
ipmach Feb 17, 2026
a80fa80
remove kafka dependency
ipmach Feb 17, 2026
f7f29d6
improve index
ipmach Feb 17, 2026
3f73e0c
Merge branch 'development' into docs_impl
ipmach Feb 17, 2026
216dcd9
Merge branch 'docs_impl' of https://github.com/ait-detectmate/DetectM…
ipmach Feb 17, 2026
dbead25
update detectors with current
ipmach Feb 17, 2026
d07f124
add helper fromto
ipmach Feb 17, 2026
d241ed0
minor correction
ipmach Feb 17, 2026
577c3ba
Merge pull request #56 from ait-detectmate/schema_refactor
whotwagner Feb 18, 2026
524b79b
Update .github/workflows/python-app.yml
ipmach Feb 24, 2026
5026532
Apply suggestion from @thorinaboenke
thorinaboenke Feb 24, 2026
9b25807
improve consistency betweeen manual an python-app.yml
ipmach Feb 24, 2026
93b356a
Merge pull request #53 from ait-detectmate/docs_impl
whotwagner Feb 25, 2026
8646b09
Adding data to workspace and change a log to debug mode
ipmach Feb 25, 2026
6bf881d
update logs.json
ipmach Feb 25, 2026
6e627c1
add data.json in documentation
ipmach Feb 25, 2026
56c5297
add basic usage - parser tutorial
ipmach Feb 25, 2026
968661f
add random detector in basic usage
ipmach Feb 25, 2026
9646242
minor change
ipmach Feb 25, 2026
f3c4860
minor change
ipmach Feb 25, 2026
063b5a2
change relative paths
ipmach Feb 26, 2026
9359c82
correct small bug in method name
ipmach Feb 26, 2026
20666c0
correct unittest and update readme
ipmach Feb 26, 2026
33f7983
Add links to official documentations
ipmach Feb 26, 2026
ff7f1d8
update docs and remove a print statement
ipmach Feb 26, 2026
7b7463c
remove special regex character usage in log_format_utils/generate_log…
ernstleierzopf Mar 1, 2026
e77c7aa
Update docs/basic_usage.md
viktorbeck98 Mar 2, 2026
d207fbb
Update docs/basic_usage.md
viktorbeck98 Mar 2, 2026
4406442
Update docs/basic_usage.md
viktorbeck98 Mar 2, 2026
8876fc8
Update src/tools/workspace/utils.py
viktorbeck98 Mar 2, 2026
bdf8a8a
Bump regex from 2026.1.15 to 2026.2.28
dependabot[bot] Mar 4, 2026
2e8b8b3
prevent cross event comparison for NVD and NVCD
viktorbeck98 Mar 4, 2026
81ced78
Merge pull request #69 from ait-detectmate/fix/detectors-cross-event-…
viktorbeck98 Mar 5, 2026
c45a028
detector extracts timestamps from human readable formats
thorinaboenke Mar 6, 2026
3c42bb2
prek
thorinaboenke Mar 6, 2026
18a0bf4
Merge pull request #62 from ait-detectmate/adapt/workspace
viktorbeck98 Mar 6, 2026
2c9129c
add configuration to process function
viktorbeck98 Mar 6, 2026
f206764
adapt tests
viktorbeck98 Mar 7, 2026
1586fcb
create logbatcher parser
viktorbeck98 Mar 7, 2026
51f464c
create logbatcher parser
viktorbeck98 Mar 7, 2026
e5c00f3
update dependencies
viktorbeck98 Mar 7, 2026
3e2b3de
allow non-event-specific detector instances
viktorbeck98 Mar 7, 2026
0515217
add a roundtrip test
viktorbeck98 Mar 7, 2026
75fc8d0
forgot to add this test to the commit
viktorbeck98 Mar 7, 2026
a54c431
fix pipeline config to use correct log_format.
ernstleierzopf Mar 8, 2026
6170fec
Merge pull request #74 from ait-detectmate/development
ernstleierzopf Mar 8, 2026
14b3901
fix new value detector test.
ernstleierzopf Mar 8, 2026
6a220f2
prek
thorinaboenke Mar 9, 2026
936cb69
re-add colon separation
thorinaboenke Mar 9, 2026
553a1f0
Merge pull request #64 from ait-detectmate/fix/logformat-regex
viktorbeck98 Mar 9, 2026
f63a569
Merge branch 'main' into development
ernstleierzopf Mar 9, 2026
ea43d81
fix uv.lock
ernstleierzopf Mar 9, 2026
737b2e9
remove invalid format from test data, use _extract_timestamp in detec…
thorinaboenke Mar 9, 2026
f5163a6
prek
thorinaboenke Mar 9, 2026
2766333
Add CodeQL analysis workflow configuration
viktorbeck98 Mar 9, 2026
448bb78
prek
thorinaboenke Mar 9, 2026
076039a
Merge pull request #76 from ait-detectmate/viktorbeck98-patch-1
ernstleierzopf Mar 9, 2026
0b0ba10
change codeql from main branch to development branch.
ernstleierzopf Mar 9, 2026
61915ad
add more comprehensive tests for testing the process function
viktorbeck98 Mar 9, 2026
c7b69d6
Merge branch 'development' into integrate/config-engine
viktorbeck98 Mar 9, 2026
1aca09d
merge development + fix tests
viktorbeck98 Mar 9, 2026
0c6c062
Merge pull request #71 from ait-detectmate/fix/timestamp_bug
ipmach Mar 10, 2026
dda31df
Merge pull request #72 from ait-detectmate/integrate/config-engine
ipmach Mar 10, 2026
9142860
Add CodeQL analysis workflow configuration
viktorbeck98 Mar 10, 2026
6a1e5d9
Merge branch 'development' into viktorbeck98-patch-1
ernstleierzopf Mar 11, 2026
f19f820
Merge pull request #79 from ait-detectmate/viktorbeck98-patch-1
ernstleierzopf Mar 11, 2026
96b42f6
sort arguments in CoreComponent
ipmach Mar 13, 2026
e782111
move fitlogic outside core component
ipmach Mar 13, 2026
402d261
split core component into two, the empty methods and the rest
ipmach Mar 13, 2026
45defce
Move schema pipeline to a different file
ipmach Mar 13, 2026
be8f911
move fit logic to a new file
ipmach Mar 13, 2026
6dd2f70
chage codeql settings to fail on existing issues.
ernstleierzopf Mar 14, 2026
89c06d6
fix codeql syntax.
ernstleierzopf Mar 14, 2026
1564b3f
fix codeql.
ernstleierzopf Mar 14, 2026
da7dfbd
test codeql.
ernstleierzopf Mar 14, 2026
2a2f6ca
fix codeql config.
ernstleierzopf Mar 14, 2026
7684f02
fix syntax error.
ernstleierzopf Mar 14, 2026
7b7706d
fix sarif path.
ernstleierzopf Mar 14, 2026
81ed374
add unsafe code to test codeql.
ernstleierzopf Mar 14, 2026
92c2b57
remove unsafe test code.
ernstleierzopf Mar 14, 2026
ec74369
rename files
ipmach Mar 16, 2026
3a5f8be
minor unittest issue corrected
ipmach Mar 16, 2026
d174faf
add setup
ipmach Mar 16, 2026
a783b16
update installation documentation
ipmach Mar 16, 2026
76a3970
update schemas documentation
ipmach Mar 16, 2026
5597a6e
update dependencies
ipmach Mar 16, 2026
c6d19b9
Merge pull request #66 from ait-detectmate/dependabot/uv/regex-2026.2.28
ipmach Mar 16, 2026
f3ddc19
Merge pull request #89 from ait-detectmate/feat/pip
viktorbeck98 Mar 16, 2026
7285d85
Merge pull request #87 from ait-detectmate/feature/codeql-ci
whotwagner Mar 16, 2026
a2d3573
add missing dependencies
ipmach Mar 17, 2026
e313dde
add dependencies that generate merge conflict
ipmach Mar 17, 2026
b890a85
Merge branch 'development' into feat/LLM_parser
ipmach Mar 17, 2026
fcfdc53
solve lock issue
ipmach Mar 17, 2026
bdbf6b8
rename file
ipmach Mar 17, 2026
51ecf0f
Merge pull request #86 from ait-detectmate/refact/core
viktorbeck98 Mar 17, 2026
db55467
adapt LogBatcher to be gpt agnostic and remove dead code
viktorbeck98 Mar 17, 2026
e8ab855
add documentation
viktorbeck98 Mar 17, 2026
92eb298
Merge pull request #73 from ait-detectmate/feat/LLM_parser
viktorbeck98 Mar 17, 2026
46c1b14
update config docs
viktorbeck98 Mar 17, 2026
b1f02b7
move events and global parameters to core detector
viktorbeck98 Mar 17, 2026
5f53b97
add inline comments for config
viktorbeck98 Mar 17, 2026
b3504fd
Merge pull request #93 from ait-detectmate/config_docs
ipmach Mar 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL Advanced"

on:
push:
branches: [ "development" ]
pull_request:
branches: [ "development" ]
schedule:
- cron: '23 23 * * 4'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: actions
build-mode: none
- language: python
build-mode: none
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Add any setup steps before running the `github/codeql-action/init` action.
# This includes steps like installing compilers or runtimes (`actions/setup-node`
# or others). This is typically only required for manual builds.
# - name: Setup runtime (example)
# uses: actions/setup-example@v1

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- name: Run manual build steps
if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"

- name: Install jq
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y jq

- name: Fail if CodeQL found issues
shell: bash
run: |
if [ -f /home/runner/work/DetectMateLibrary/results/python.sarif ]; then
SARIF=/home/runner/work/DetectMateLibrary/results/python.sarif
elif [ -f /home/runner/work/DetectMateLibrary/results/actions.sarif ]; then
SARIF=/home/runner/work/DetectMateLibrary/results/actions.sarif
else
echo "SARIF file not found. Analysis may have failed."
exit 1
fi
count=$(jq '.runs[].results | length' $SARIF)
if [ "$count" -gt 0 ]; then
echo "CodeQL found $count issue(s)!"
jq -r '.runs[].results[] | "Rule: \(.ruleId)\nSeverity: \(.level)\nMessage: \(.message.text)\nFile: \(.locations[0].physicalLocation.artifactLocation.uri)\nLine: \(.locations[0].physicalLocation.region.startLine)\n---"' $SARIF
exit 1
else
echo "No CodeQL issues found"
fi
40 changes: 40 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish Docs
on:
push:
branches: [ "development" ]
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up uv (Python 3.12)
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
enable-cache: true

- name: Install dependencies
run: uv pip install -e .[dev]

- name: Configure Git user
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"

- name: Deploy docs
run: |
# Extract version from tag (remove 'v' prefix if present)
VERSION=${GITHUB_REF_NAME#v}
echo "Deploying version $VERSION"
uv run mike deploy --push --update-aliases $VERSION latest
# Optional: make the released version the default shown when visiting the site
# it's enough to run this once
# uv run mike set-default --push latest
10 changes: 5 additions & 5 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Python application

on:
push:
branches: [ "main"]
branches: [ "main", "development"]
pull_request:

permissions:
Expand All @@ -30,7 +30,7 @@ jobs:
run: uv run --dev prek run -a

- name: Test with pytest
run: uv run --dev pytest
run: uv run --dev pytest -s

# integration tests for DetectMateService
- name: Checkout DetectMateService
Expand All @@ -49,6 +49,6 @@ jobs:
working-directory: DetectMateService
run: uv pip install .

- name: Run DetectMateService library integration tests
working-directory: DetectMateService
run: pytest tests/library_integration
#- name: Run DetectMateService library integration tests
# working-directory: DetectMateService
# run: uv run --dev pytest tests/library_integration -s
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ __pycache__/
# C extensions
*.so

dummy*

# Distribution / packaging
.Python
build/
Expand Down
102 changes: 102 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

DetectMateLibrary is a Python library for log processing and anomaly detection. It provides composable, stream-friendly components (parsers and detectors) that communicate via Protobuf-based schemas. The library is designed for both single-process and microservice deployments.

## Development Commands

```bash
# Install dependencies and pre-commit hooks
uv sync --dev
uv run prek install

# Run tests
uv run pytest -q
uv run pytest -s # verbose with stdout
uv run pytest --cov=. --cov-report=term-missing # with coverage
uv run pytest tests/test_foo.py # single test file

# Run linting/formatting (all pre-commit hooks)
uv run prek run -a

# Recompile Protobuf (only if schemas.proto is modified)
protoc --proto_path=src/detectmatelibrary/schemas/ \
--python_out=src/detectmatelibrary/schemas/ \
src/detectmatelibrary/schemas/schemas.proto

# Scaffold a new component workspace
mate create --type <parser|detector> --name <name> --dir <target_dir>
```

## Architecture

### Data Flow

```
Raw Logs → Parser → ParserSchema → Detector → DetectorSchema (Alerts)
```

All data flows through typed Protobuf-backed schema objects. Components are stateful and support an optional training phase before detection.

### Core Abstractions (`src/detectmatelibrary/common/`)

- **`CoreComponent`** — base class managing buffering, ID generation, and training state
- **`CoreParser(CoreComponent)`** — parse raw logs into `ParserSchema`
- **`CoreDetector(CoreComponent)`** — detect anomalies in `ParserSchema`, emit `DetectorSchema`
- **`CoreConfig`** / **`CoreParserConfig`** / **`CoreDetectorConfig`** — Pydantic-based configuration hierarchy

### Schema System (`src/detectmatelibrary/schemas/`)

- `BaseSchema` wraps generated Protobuf messages with dict-like access (`schema["field"]`)
- Key schemas: `LogSchema`, `ParserSchema`, `DetectorSchema`
- Support serialization to/from bytes for transport and persistence

### Buffering Modes (`src/detectmatelibrary/utils/data_buffer.py`)

Three modes via `ArgsBuffer` config:
- **NO_BUF** — one item at a time (default)
- **BATCH** — accumulate N items, process as batch
- **WINDOW** — sliding window of size N

### Implementations

- **Parsers** (`src/detectmatelibrary/parsers/`): `JsonParser`, `DummyParser`, `TemplateMatcherParser` (uses Drain3 for template mining)
- **Detectors** (`src/detectmatelibrary/detectors/`): `NewValueDetector`, `NewValueComboDetector`, `RandomDetector`, `DummyDetector`
- **Utilities** (`src/detectmatelibrary/utils/`): `DataBuffer`, `EventPersistency`, `KeyExtractor`, `TimeFormatHandler`, `IdGenerator`

## Extending the Library

Implement a custom detector by subclassing `CoreDetector`:

```python
class MyDetectorConfig(CoreDetectorConfig):
method_type: str = "my_detector"
my_param: int = 10

class MyDetector(CoreDetector):
def __init__(self, name="MyDetector", config=MyDetectorConfig()):
super().__init__(name=name, config=config)

def train(self, input_: ParserSchema) -> None:
pass # optional

def detect(self, input_: ParserSchema, output_: DetectorSchema) -> bool:
output_["detectorID"] = self.name
output_["score"] = 0.0
return False # True = anomaly detected
```

Same pattern applies for `CoreParser` — implement `parse(input_: LogSchema, output_: ParserSchema) -> bool`.

## Code Quality

Pre-commit hooks enforce:
- **mypy** strict mode
- **flake8** linting, **autopep8** formatting (max line 110)
- **bandit** security checks, **vulture** dead-code detection (70% threshold)
- **docformatter** docstring style

Python 3.12 is required (see `.python-version`).
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@ Main library to run the different components in DetectMate.

The library contains the next components:

* **Readers**: insert logs into the system.
* **Parsers**: parse the logs receive from the reader.
* **Detectors**: return alerts if anomalies are detected.
* **Outputs**: return alerts as outputs.
* **Schemas**: standard data classes use in DetectMate.
```
+---------+ +--------+ +-----------+ +--------+
| Reader | --> | Parser | --> | Detector | --> | Output |
+---------+ +--------+ +-----------+ +--------+
+--------+ +-----------+
| Parser | --> | Detector |
+--------+ +-----------+
```
## Developer setup:

### Step 1: Install python dependencies
Set up the dev environment and install pre-commit hooks:

```bash
uv pip install -e .[dev]
uv sync --dev
uv run prek install
```

Expand Down Expand Up @@ -91,6 +89,7 @@ workspaces/custom_parser/ # workspace root
│ └── 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
Expand Down
40 changes: 40 additions & 0 deletions config/NVD_audit_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
detectors:
NewValueDetector:
auto_config: false
events:
0:
NewValueDetector:
header_variables:
- pos: Type
params: {}
variables:
- name: var_2
pos: 2
- name: var_4
pos: 4
- name: var_5
pos: 5
- name: var_6
pos: 6
- name: var_7
pos: 7
- name: var_8
pos: 8
- name: var_9
pos: 9
1:
NewValueDetector:
header_variables:
- pos: Type
params: {}
2:
NewValueDetector:
params: {}
variables:
- name: var_3
pos: 3
method_type: new_value_detector
params:
data_use_training: null
parser: <PLACEHOLDER>
start_id: 10
Loading
Loading