diff --git a/Makefile b/Makefile index 55798d3..4a9510e 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,8 @@ format: test: pip3 install . ifdef GITHUB_ACTIONS - coverage run -m pytest -v --with_mongodb + coverage run -m pytest -W error -v --with_mongodb else - coverage run -m pytest -v + coverage run -m pytest -W error -v endif coverage report -m diff --git a/dev-requirements.txt b/dev-requirements.txt index 2f0d7fb..727299a 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,8 @@ -mypy==1.6.0 -black==22.3.0 -isort==5.10.1 -flake8==6.1.0 -coverage==6.3.2 -pytest==7.1.2 -pytest-asyncio==0.18.3 +mypy==1.10.0 +black==24.4.2 +isort==5.13.2 +flake8==7.0.0 +coverage==7.5.3 +pytest==8.2.2 +pytest-asyncio==0.23.7 +setuptools==70.0.0 diff --git a/enochecker3/logging.py b/enochecker3/logging.py index 5f35ad4..406f9c7 100644 --- a/enochecker3/logging.py +++ b/enochecker3/logging.py @@ -41,7 +41,7 @@ def format(self, record: logging.LogRecord) -> str: trunc: int = message_size + len(suffix) - 32766 msg.message = msg.message[:-trunc] + suffix - return LOGGING_PREFIX + msg.json(by_alias=True) + return LOGGING_PREFIX + msg.model_dump_json(by_alias=True) def to_level(self, levelname: str) -> int: if levelname == "CRITICAL": @@ -67,7 +67,9 @@ def create_message(self, record: logging.LogRecord) -> EnoLogMessage: type="infrastructure", severity=record.levelname, severity_level=self.to_level(record.levelname), - timestamp=datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ"), + timestamp=datetime.datetime.now(datetime.timezone.utc).strftime( + "%Y-%m-%dT%H:%M:%S.%fZ" + ), message=record.msg, module=record.module, function=record.funcName, @@ -81,4 +83,7 @@ def create_message(self, record: logging.LogRecord) -> EnoLogMessage: flag=getattr(checker_task, "flag", None), variant_id=getattr(checker_task, "variant_id", None), task_chain_id=getattr(checker_task, "task_chain_id", None), + flag_regex=getattr(checker_task, "flag_regex", None), + flag_hash=getattr(checker_task, "flag_hash", None), + attack_info=getattr(checker_task, "attack_info", None), ) diff --git a/enochecker3/types.py b/enochecker3/types.py index 8e938ad..f349941 100644 --- a/enochecker3/types.py +++ b/enochecker3/types.py @@ -2,7 +2,10 @@ from enum import Enum from typing import ClassVar, Optional +from pydantic import AliasGenerator from pydantic import BaseModel as PydanticBaseModel +from pydantic import ConfigDict +from pydantic.alias_generators import to_camel SNAKE_CASE_PATTERN = re.compile("(_[a-z])") @@ -12,10 +15,11 @@ def _to_camel_case(x: str) -> str: class BaseModel(PydanticBaseModel): - class Config: - use_enum_values = True - alias_generator = _to_camel_case - allow_population_by_field_name = True + model_config = ConfigDict( + use_enum_values=True, + alias_generator=AliasGenerator(serialization_alias=to_camel), + populate_by_name=True, + ) class CheckerTaskResult(str, Enum): diff --git a/requirements.txt b/requirements.txt index 7c54154..3f056c7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -httpx>=0.23.0,<0.24.0 -motor>=3.1.2,<4.0.0 -fastapi>=0.75.2,<0.76.0 -uvicorn>=0.17.6,<0.18.0 -gunicorn==20.1.0 +httpx>=0.27.0,<0.28.0 +motor>=3.4.0,<4.0.0 +fastapi>=0.111.0,<0.112.0 +uvicorn>=0.30.1,<0.31.0 +gunicorn==22.0.0 diff --git a/setup.py b/setup.py index e341766..23ed778 100755 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setuptools.setup( name="enochecker3", - version="0.8.1", + version="0.9.0", author="ldruschk", author_email="ldruschk@posteo.de", description="FastAPI based library for building async python checkers for the EnoEngine A/D CTF Framework",