Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 1 addition & 21 deletions docs/detectors/deeplog.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,6 @@ detectors:
## Example usage

```python
from detectmatelibrary.detectors.deeplog_detector import DeeplogDetector

import detectmatelibrary.schemas as schemas

detector = DeeplogDetector(name="DeeplogDetector", config=cfg)

test_data = schemas.ParserSchema({
"parserType": "test",
"EventID": 12,
"template": "test template",
"variables": ["adsasd", "asdasd"],
"logID": "2",
"parsedLogID": "2",
"parserID": "test_parser",
"log": "test log message",
"logFormatVariables": {"level": "CRITICAL"}
})
output = schemas.DetectorSchema()

result = detector.detect(test_data, output)

--8<-- "docs/examples/detectors/deeplog_detector.py:example"
```
Go back [Index](../index.md)
30 changes: 1 addition & 29 deletions docs/detectors/ecvc_detector.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,7 @@ detectors:
## Example usage

```python
from detectmatelibrary.detectors.ecvc_detector import ECVCDetector
import detectmatelibrary.schemas as schemas

cfg = {
"detectors": {
"ECVCDetector": {
"method_type": "ecvc_detector_detector",
"window_size": 10,
"validation_per": 0.2,
"threshold_method": "mean" # mean, default (default = threshold 0)
}
}
}
detector = ECVCDetector(name="ECVCDetector", config=cfg)

parser_data = schemas.ParserSchema({
"parserType": "test",
"EventID": 1,
"template": "test template",
"variables": ["var1"],
"logID": "1",
"parsedLogID": "1",
"parserID": "test_parser",
"log": "test log message",
"logFormatVariables": {"timestamp": "123456"}
})


alert = detector.process(parser_data)
--8<-- "docs/examples/detectors/ecvc_detector.py:example"
```

Go back [Index](../index.md)
22 changes: 1 addition & 21 deletions docs/detectors/logbert.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,6 @@ detectors:
## Example usage

```python
from detectmatelibrary.detectors.logbert_detector import LogBertDetector

import detectmatelibrary.schemas as schemas

detector = LogBertDetector(name="LogBertDetector", config=cfg)

test_data = schemas.ParserSchema({
"parserType": "test",
"EventID": 12,
"template": "test template",
"variables": ["adsasd", "asdasd"],
"logID": "2",
"parsedLogID": "2",
"parserID": "test_parser",
"log": "test log message",
"logFormatVariables": {"level": "CRITICAL"}
})
output = schemas.DetectorSchema()

result = detector.detect(test_data, output)

--8<-- "docs/examples/detectors/logbert_detector.py:example"
```
Go back [Index](../index.md)
28 changes: 1 addition & 27 deletions docs/detectors/scvs_detector.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,7 @@ detectors:
## Example usage

```python
from detectmatelibrary.detectors.scvs_detector import SCVSDetector
import detectmatelibrary.schemas as schemas

cfg = {
"detectors": {
"SCVSDetector": {
"method_type": "scvs_detector",
"auto_config": False,
}
}
}
detector = SCVSDetector(name="NewValueTest", config=cfg)

parser_data = schemas.ParserSchema({
"parserType": "test",
"EventID": 1,
"template": "test template",
"variables": ["var1"],
"logID": "1",
"parsedLogID": "1",
"parserID": "test_parser",
"log": "test log message",
"logFormatVariables": {"timestamp": "123456"}
})


alert = detector.process(parser_data)
--8<-- "docs/examples/detectors/scvs_detector.py:example"
```

Go back [Index](../index.md)
31 changes: 31 additions & 0 deletions docs/examples/detectors/deeplog_detector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# --8<-- [start:example]
from detectmatelibrary.detectors.deeplog_detector import DeeplogDetector

import detectmatelibrary.schemas as schemas

cfg = {
"detectors": {
"DeeplogDetector": {
"method_type": "deeplog_detector",
"auto_config": True,
}
}
}

detector = DeeplogDetector(name="DeeplogDetector", config=cfg)

test_data = schemas.ParserSchema({
"parserType": "test",
"EventID": 12,
"template": "test template",
"variables": ["adsasd", "asdasd"],
"logID": "2",
"parsedLogID": "2",
"parserID": "test_parser",
"log": "test log message",
"logFormatVariables": {"level": "CRITICAL"}
})
output = schemas.DetectorSchema()

result = detector.detect([test_data], output)
# --8<-- [end:example]
31 changes: 31 additions & 0 deletions docs/examples/detectors/ecvc_detector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# --8<-- [start:example]
from detectmatelibrary.detectors.ecvc_detector import ECVCDetector
import detectmatelibrary.schemas as schemas

cfg = {
"detectors": {
"ECVCDetector": {
"method_type": "ecvc_detector_detector",
"window_size": 10,
"validation_per": 0.2,
"threshold_method": "mean" # mean, default (default = threshold 0)
}
}
}
detector = ECVCDetector(name="ECVCDetector", config=cfg)

parser_data = schemas.ParserSchema({
"parserType": "test",
"EventID": 1,
"template": "test template",
"variables": ["var1"],
"logID": "1",
"parsedLogID": "1",
"parserID": "test_parser",
"log": "test log message",
"logFormatVariables": {"timestamp": "123456"}
})


alert = detector.process(parser_data)
# --8<-- [end:example]
31 changes: 31 additions & 0 deletions docs/examples/detectors/logbert_detector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# --8<-- [start:example]
from detectmatelibrary.detectors.logbert_detector import LogBertDetector

import detectmatelibrary.schemas as schemas

cfg = {
"detectors": {
"LogBertDetector": {
"method_type": "logbert_detector",
"auto_config": True,
}
}
}

detector = LogBertDetector(name="LogBertDetector", config=cfg)

test_data = schemas.ParserSchema({
"parserType": "test",
"EventID": 12,
"template": "test template",
"variables": ["adsasd", "asdasd"],
"logID": "2",
"parsedLogID": "2",
"parserID": "test_parser",
"log": "test log message",
"logFormatVariables": {"level": "CRITICAL"}
})
output = schemas.DetectorSchema()

result = detector.detect([test_data], output)
# --8<-- [end:example]
29 changes: 29 additions & 0 deletions docs/examples/detectors/scvs_detector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# --8<-- [start:example]
from detectmatelibrary.detectors.scvs_detector import SCVSDetector
import detectmatelibrary.schemas as schemas

cfg = {
"detectors": {
"SCVSDetector": {
"method_type": "scvs_detector",
"auto_config": False,
}
}
}
detector = SCVSDetector(name="SCVSDetector", config=cfg)

parser_data = schemas.ParserSchema({
"parserType": "test",
"EventID": 1,
"template": "test template",
"variables": ["var1"],
"logID": "1",
"parsedLogID": "1",
"parserID": "test_parser",
"log": "test log message",
"logFormatVariables": {"timestamp": "123456"}
})


alert = detector.process(parser_data)
# --8<-- [end:example]
2 changes: 2 additions & 0 deletions tests/test_detectors/test_ecvc_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from tests.test_data import AUDIT_LOG, AUDIT_TEMPLATES, TRAIN_UNTIL

import numpy as np
import pytest


class TestECVCOP:
Expand Down Expand Up @@ -136,6 +137,7 @@ def test_ecvc(self):
class TestECVCDetectorEndToEnd:
"""Regression test: full configure/train/detect pipeline on audit.log."""

@pytest.mark.ignored
def test_audit_log_anomalies(self):
parser = MatcherParser(config=PIPELINE_CONFIG)
detector = ECVCDetector(config=PIPELINE_CONFIG)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_detectors/test_scvs_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from tests.test_data import AUDIT_LOG, AUDIT_TEMPLATES, TRAIN_UNTIL

import pytest


class TestSCVSDetector:
def test_build_count_vec(self):
Expand Down Expand Up @@ -81,6 +83,7 @@ def test_scvs(self):
class TestSCVSDetectorEndToEnd:
"""Regression test: full configure/train/detect pipeline on audit.log."""

@pytest.mark.ignored
def test_audit_log_anomalies(self):
parser = MatcherParser(config=PIPELINE_CONFIG)
detector = SCVSDetector(config=PIPELINE_CONFIG)
Expand Down
Loading