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
24 changes: 24 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,27 @@ jobs:
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
6 changes: 6 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ uv sync

**Result**: the package is installed into the active Python environment and changes to the source tree are reflected immediately.

To install it in a different venv as a library:

```bash
uv pip install --no-cache-dir <directory_detectmatelibrary>
```

## Developer setup

**Purpose**: prepare a development environment with test and lint tooling.
Expand Down
10 changes: 5 additions & 5 deletions docs/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ from detectmatelibrary import schemas
kwargs = load_somewhere() # load the dict
kwargs["log"] = "Test log"

log_schema = LogSchema(kwargs)
log_schema = schemas.LogSchema(kwargs)
print(log_schema.log == "Test log") # True
```

Expand All @@ -132,11 +132,11 @@ print(log_schema.log == "Test log") # True
```python
from detectmatelibrary import schemas

log_schema = LogSchema()
log_schema = schemas.LogSchema()
log_schema.log = "Test log"
print(log_schema["log"] == log_schema.log) # True

log_schema2 = LogSchema()
log_schema2 = schemas.LogSchema()
print(log_schema == log_schema2) # False

log_schema2.log = "Test log"
Expand All @@ -148,12 +148,12 @@ print(log_schema == log_schema2) # True
```python
from detectmatelibrary import schemas

log_schema = LogSchema()
log_schema = schemas.LogSchema()
log_schema.log = "Test log"
serialized = log_schema.serialize()
print(isinstance(serialized, bytes)) # True

new_log_schema = LogSchema()
new_log_schema = schemas.LogSchema()
new_log_schema.deserialize(serialized)
print(new_log_schema.schema_id == log_schema.schema_id) # True
```
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ name = "detectmatelibrary"
version = "0.1.0"
description = "DetectMate Library for log processing components"
readme = "README.md"
dynamic = ["authors"]
requires-python = ">=3.12"
dependencies = [
"drain3>=0.9.11",
"protobuf>=6.32.1",
"pydantic>=2.11.7",
"pyyaml>=6.0.3",
"regex>=2025.11.3",
"numpy>=2.3.2",
"pandas>=2.3.2",
"polars>=1.38.1",
]

[dependency-groups]
Expand All @@ -21,8 +23,6 @@ dev = [
"prek>=0.2.8",
"pytest>=8.4.2",
"pytest-cov>=6.2.1",
"pandas>=2.3.2",
"polars>=1.38.1",
]

[build-system]
Expand Down
28 changes: 28 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from setuptools import setup, find_packages
import tomllib


def gather_dependencies(toml_path: str = "pyproject.toml") -> list[str]:
with open(toml_path, "rb") as f:
data = tomllib.load(f)

# Try Poetry first
poetry_deps = data.get("tool", {}).get("poetry", {}).get("dependencies", {})
if poetry_deps:
return [f"{dep}{version}" for dep, version in poetry_deps.items()]

# Fall back to PEP 621
project_deps: list[str] = data.get("project", {}).get("dependencies", [])
return project_deps


setup(
name="detectmatelibrary",
version="0.1.0",
package_dir={"": "src"},
packages=find_packages(where="src"),
description="DetectMate Library for log processing components",
author="voice",
author_email="voice@example.com",
install_requires=gather_dependencies(),
)
4 changes: 2 additions & 2 deletions src/detectmatelibrary/common/_config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from detectmatelibrary.common._config._compile import ConfigMethods, generate_detector_config
from detectmatelibrary.common._config._formats import EventsConfig
from ._compile import ConfigMethods, generate_detector_config
from ._formats import EventsConfig

__all__ = ["ConfigMethods", "generate_detector_config", "EventsConfig", "BasicConfig"]

Expand Down
11 changes: 9 additions & 2 deletions src/detectmatelibrary/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@



from detectmatelibrary.schemas._classes import (
from ._classes import (
BaseSchema,
LogSchema,
ParserSchema,
Expand All @@ -13,4 +13,11 @@
)


__all__ = ["BaseSchema", "LogSchema", "ParserSchema", "DetectorSchema", "OutputSchema", "FieldNotFound"]
__all__ = [
"BaseSchema",
"LogSchema",
"ParserSchema",
"DetectorSchema",
"OutputSchema",
"FieldNotFound"
]
Loading
Loading