Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4d04910
unfinished draft for NewEventDetector.
ernstleierzopf Mar 9, 2026
8fbb34d
unfinished draft NewEventDetector.
ernstleierzopf Mar 10, 2026
1076a8f
Merge pull request #91 from ait-detectmate/development
ernstleierzopf Mar 16, 2026
3ca95de
test outputs.
ernstleierzopf Mar 16, 2026
6328a43
Merge branch 'feature/new-event-detector' of github.com:ait-detectmat…
ernstleierzopf Mar 16, 2026
c5ed199
add STATIC classification trackers to all detectors.
ernstleierzopf Mar 16, 2026
d9ab23d
fix prek issues.
ernstleierzopf Mar 16, 2026
ad04055
fix prek issues.
ernstleierzopf Mar 16, 2026
fc7cc18
update gitignore
viktorbeck98 Mar 17, 2026
f5bdc8c
add option for combo and value detector to use static or stable varia…
viktorbeck98 Mar 17, 2026
a52aa36
fix prek issues
viktorbeck98 Mar 17, 2026
f5e4801
fix prek issues
viktorbeck98 Mar 17, 2026
0a55953
path_templates is not longer required by the MatcherParser
viktorbeck98 Mar 30, 2026
faea48c
Merge pull request #109 from ait-detectmate/small_fixes
ipmach Mar 30, 2026
0641866
Merge branch 'main' into development
ipmach Mar 30, 2026
b2e00b3
add security file
ipmach Mar 30, 2026
04cb190
Merge branch 'development' into fix/new_value_detector
viktorbeck98 Mar 30, 2026
67dc28b
Warn when detector config doesn't match training data
viktorbeck98 Mar 30, 2026
fe9f7c8
fix minor issue
viktorbeck98 Mar 30, 2026
3e73ae8
Merge pull request #110 from ait-detectmate/feat/security
viktorbeck98 Mar 30, 2026
f410dff
add issue and PR templates
viktorbeck98 Mar 31, 2026
f574b55
feat(config): support named wildcards and named event IDs in template…
viktorbeck98 Mar 31, 2026
1190139
Merge pull request #92 from ait-detectmate/fix/new_value_detector
ipmach Mar 31, 2026
f159791
Merge branch 'main' into development
ipmach Mar 31, 2026
467f50d
Merge pull request #113 from ait-detectmate/feat/templates
ipmach Mar 31, 2026
e7f0bf7
Merge pull request #114 from ait-detectmate/feat/configuration2.0
ipmach Mar 31, 2026
3ad3c58
Merge pull request #111 from ait-detectmate/feat/warnings
ipmach Mar 31, 2026
3b21465
Merge branch 'feature/new-event-detector' into development
ernstleierzopf Apr 1, 2026
a9112a1
Merge pull request #119 from ait-detectmate/development
ernstleierzopf Apr 1, 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
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/01_bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: 🐜 Bug report
about: If something isn't working 🔧
---

### Subject of the issue
Describe your issue here.

### Your environment
* Version of detectmate
* Version of python
* Docker or manual installation?

### Steps to reproduce
Tell us how to reproduce this issue.

### Expected behaviour
Tell us what should happen

### Actual behaviour
Tell us what happens instead
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/02_feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: 🚀 Feature request
about: If you have a feature request 💡
---

**Context**

What are you trying to do and how would you want to do it differently? Is it something you currently you cannot do? Is this related to an issue/problem?

**Alternatives**

Can you achieve the same result doing it in an alternative way? Is the alternative considerable?

**Has the feature been requested before?**

Please provide a link to the issue.

**If the feature request is approved, would you be willing to submit a PR?**

Yes / No _(Help can be provided if you need assistance submitting a PR)_
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Task
<!-- Please add link a relevant issue or task -->

# Description
<!-- Please include a summary of the change -->
<!-- Any details that you think are important to review this PR? -->
<!-- Are there other PRs related to this one? -->

# How Has This Been Tested?
<!-- Please describe how you tested your changes -->

# Checklist
<!-- Go over all the following points, and put an `x` in all the boxes that apply -->

- [ ] This Pull-Request goes to the **development** branch.
- [ ] I have successfully run prek locally.
- [ ] I have added tests to cover my changes.
- [ ] I have linked the issue-id to the task-description.
- [ ] I have performed a self-review of my own code.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,6 @@ cython_debug/
local/
test.ipynb
test.py

# claude code
CLAUDE.md
32 changes: 32 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Security Policy

## Supported Versions

| Version | Supported |
| ------- | ------------------ |
| 1.x.x | :white_check_mark: |
| < 1.0.0 | :x: |

> [!IMPORTANT]
> Currently DetectMateService is a work in progress and heavily under development. Possible vulnerabilities will not be treated any special and can be issued using [GitHub-Issues](https://github.com/ait-detectmate/DetectMateService/issues)

## Reporting a Vulnerability

Please email reports about any security related issues you find to aecid@ait.ac.at. This mail is delivered to a small developer team. Your email will be acknowledged within one business day, and you'll receive a more detailed response to your email within 7 days indicating the next steps in handling your report.

Please use a descriptive subject line for your report email. After the initial reply to your report, our team will endeavor to keep you informed of the progress being made towards a fix and announcement.

In addition, please include the following information along with your report:

* Your name and affiliation (if any).
* A description of the technical details of the vulnerabilities. It is very important to let us know how we can reproduce your findings.
* An explanation who can exploit this vulnerability, and what they gain when doing so -- write an attack scenario. This will help us evaluate your report quickly, especially if the issue is complex.
* Whether this vulnerability public or known to third parties. If it is, please provide details.
* Whether we could mention your name in the changelogs.

Once an issue is reported we use the following disclosure process:

* When a report is received, we confirm the issue and determine its severity.
* If we know of specific third-party services or software based on DetectMateService that require mitigation before publication, those projects will be notified.
* Fixes are prepared for the last minor release of the latest major release.
* Patch releases are published for all fixed released versions.
2 changes: 0 additions & 2 deletions config/pipeline_config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ detectors:
NewValueComboDetector:
method_type: new_value_combo_detector
auto_config: False
params:
comb_size: 3
events:
1:
test:
Expand Down
3 changes: 2 additions & 1 deletion docs/detectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ List of detectors:
* [Random detector](detectors/random_detector.md): Generates random alerts.
* [New Value](detectors/new_value.md): Detect new values in the variables in the logs.
* [Combo Detector](detectors/combo.md): Detect new combination of variables in the logs.
* [New Event](detectors/new_event.md): Detect new events in the variables in the logs.

## Configuration

Expand Down Expand Up @@ -192,7 +193,7 @@ The `set_configuration()` method queries the tracker results and generates the f
def set_configuration(self):
variables = {}
for event_id, tracker in self.auto_conf_persistency.get_events_data().items():
stable_vars = tracker.get_variables_by_classification("STABLE")
stable_vars = tracker.get_features_by_classification("STABLE")
variables[event_id] = stable_vars

config_dict = generate_detector_config(
Expand Down
2 changes: 1 addition & 1 deletion docs/detectors/combo.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ detectors:
method_type: new_value_combo_detector
auto_config: False
params:
comb_size: 3
max_combo_size: 3
events:
1:
test:
Expand Down
7 changes: 7 additions & 0 deletions docs/detectors/new_event.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TODO PAGE

TODO: new_event_detector
TODO: test_new_event_detector
- Tests need to be reworked, just copied from new_value_detector

TODO: pipeline_config_Default.yaml
4 changes: 2 additions & 2 deletions src/detectmatelibrary/common/_config/_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def generate_detector_config(
detector_name: Name of the detector, used as the base instance_id.
method_type: Type of detection method (e.g., "new_value_detector").
**additional_params: Additional parameters for the detector's params
dict (e.g., comb_size=3).
dict (e.g., max_combo_size=3).

Returns:
Dictionary with structure compatible with detector config classes.
Expand All @@ -162,7 +162,7 @@ def generate_detector_config(
variable_selection={1: [("username", "src_ip"), ("var_0", "var_1")]},
detector_name="MyDetector",
method_type="new_value_combo_detector",
comb_size=2,
max_combo_size=2,
)
"""
var_pattern = re.compile(r"^var_(\d+)$")
Expand Down
11 changes: 6 additions & 5 deletions src/detectmatelibrary/common/_config/_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

# Sub-formats ********************************************************+
class Variable(BaseModel):
pos: int
name: str
pos: str | int
name: str = ""
params: Dict[str, Any] = {}

def to_dict(self) -> Dict[str, Any]:
"""Convert Variable to YAML-compatible dictionary."""
result: Dict[str, Any] = {
"pos": self.pos,
"name": self.name,
}
if self.name:
result["name"] = self.name
if self.params:
result["params"] = self.params
return result
Expand All @@ -38,7 +39,7 @@ def to_dict(self) -> Dict[str, Any]:
class _EventInstance(BaseModel):
"""Configuration for a specific instance within an event."""
params: Dict[str, Any] = {}
variables: Dict[int, Variable] = {}
variables: Dict[str | int, Variable] = {}
header_variables: Dict[str, Header] = {}

@classmethod
Expand Down Expand Up @@ -79,7 +80,7 @@ def _init(cls, instances_dict: Dict[str, Dict[str, Any]]) -> "_EventConfig":
return cls(instances=instances)

@property
def variables(self) -> Dict[int, Variable]:
def variables(self) -> Dict[str | int, Variable]:
"""Pass-through to first instance for compatibility."""
if self.instances:
return next(iter(self.instances.values())).variables
Expand Down
12 changes: 12 additions & 0 deletions src/detectmatelibrary/common/_core_op/_fit_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def __init__(
self._configuration_done = False
self.config_finished = False

self._training_done = False
self.training_finished = False

self.data_use_configure = data_use_configure
self.data_use_training = data_use_training

Expand All @@ -84,6 +87,13 @@ def finish_config(self) -> bool:

return False

def finish_training(self) -> bool:
if self._training_done and not self.training_finished:
self.training_finished = True
return True

return False

def run(self) -> FitLogicState:
if do_configure(
data_use_configure=self.data_use_configure,
Expand All @@ -103,5 +113,7 @@ def run(self) -> FitLogicState:
):
self.data_used_train += 1
return FitLogicState.DO_TRAIN
elif self.data_used_train > 0 and not self._training_done:
self._training_done = True

return FitLogicState.NOTHING
6 changes: 6 additions & 0 deletions src/detectmatelibrary/common/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def configure(
def set_configuration(self) -> None:
pass

def post_train(self) -> None:
pass

def get_config(self) -> Dict[str, Any]:
return self.config.get_config()

Expand Down Expand Up @@ -100,6 +103,9 @@ def process(self, data: BaseSchema | bytes) -> BaseSchema | bytes | None:
if fit_state == FitLogicState.DO_TRAIN:
logger.info(f"<<{self.name}>> use data for training")
self.train(input_=data_buffered)
elif self.fitlogic.finish_training():
logger.info(f"<<{self.name}>> finalizing training")
self.post_train()

output_ = self.output_schema()
logger.info(f"<<{self.name}>> processing data")
Expand Down
47 changes: 46 additions & 1 deletion src/detectmatelibrary/common/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

from detectmatelibrary.utils.data_buffer import ArgsBuffer, BufferMode
from detectmatelibrary.utils.aux import get_timestamp
from detectmatelibrary.utils.persistency.event_persistency import EventPersistency

from detectmatelibrary.schemas import ParserSchema, DetectorSchema

from typing_extensions import override
from typing import Dict, List, Optional, Any

from detectmatelibrary.utils.time_format_handler import TimeFormatHandler
from tools.logging import logger


_time_handler = TimeFormatHandler()
Expand Down Expand Up @@ -56,7 +58,7 @@ def get_configured_variables(
# Extract template variables by position
if hasattr(event_config, "variables"):
for pos, var in event_config.variables.items():
if pos < len(input_["variables"]):
if isinstance(pos, int) and pos < len(input_["variables"]):
result[var.name] = input_["variables"][pos]

# Extract header/log format variables by name
Expand Down Expand Up @@ -89,6 +91,45 @@ def get_global_variables(
return result


def validate_config_coverage(
detector_name: str,
config_events: EventsConfig | dict[str, Any],
persistency: EventPersistency,
) -> None:
"""Log warnings when configured EventIDs or variables have no training
data.

Args:
detector_name: Name of the detector (used in warning messages).
config_events: The detector's events configuration.
persistency: The persistency object populated during training.
"""
config_ids = (
config_events.events.keys()
if isinstance(config_events, EventsConfig)
else config_events.keys()
)
if not config_ids:
return

events_seen = persistency.get_events_seen()
events_with_data = set(persistency.get_events_data().keys())

for event_id in config_ids:
if event_id not in events_seen:
logger.warning(
f"[{detector_name}] EventID {event_id!r} is configured but was "
"never observed in training data. Verify that EventIDs in your "
"config match those produced by the parser."
)
elif event_id not in events_with_data:
logger.warning(
f"[{detector_name}] EventID {event_id!r} was observed in training "
"data but no configured variables were extracted. Verify that "
"variable names/positions in your config match those in the data."
)


class CoreDetectorConfig(CoreConfig):
component_type: str = "detectors"
method_type: str = "core_detector"
Expand Down Expand Up @@ -158,3 +199,7 @@ def configure(
@override
def set_configuration(self) -> None:
pass

@override
def post_train(self) -> None:
pass
5 changes: 4 additions & 1 deletion src/detectmatelibrary/detectors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from .random_detector import RandomDetector, RandomDetectorConfig
from .new_value_detector import NewValueDetector, NewValueDetectorConfig
from .new_event_detector import NewEventDetector, NewEventDetectorConfig

__all__ = [
"random_detector",
"RandomDetectorConfig",
"NewValueDetector",
"NewValueDetectorConfig",
"RandomDetector"
"RandomDetector",
"NewEventDetector",
"NewEventDetectorConfig"
]
Loading
Loading