From 7c71b1e1b217449c39a45beb52edc9742c64f0bc Mon Sep 17 00:00:00 2001 From: Lucas Druschke Date: Sat, 8 Jun 2024 14:20:26 +0000 Subject: [PATCH 1/4] bump dependencies, bump version to 0.9.0 --- Makefile | 4 ++-- dev-requirements.txt | 14 +++++++------- enochecker3/logging.py | 9 +++++++-- enochecker3/types.py | 12 ++++++++---- requirements.txt | 10 +++++----- setup.py | 2 +- 6 files changed, 30 insertions(+), 21 deletions(-) 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..b2de268 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,7 @@ -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 diff --git a/enochecker3/logging.py b/enochecker3/logging.py index 5f35ad4..ab125da 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.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", From 1547b7775be83a16998e6a2f83541b34863e7997 Mon Sep 17 00:00:00 2001 From: Lucas Druschke Date: Sat, 8 Jun 2024 14:24:58 +0000 Subject: [PATCH 2/4] migrate to datetime.timezone.utc to be compatible with old python versions --- enochecker3/logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enochecker3/logging.py b/enochecker3/logging.py index ab125da..406f9c7 100644 --- a/enochecker3/logging.py +++ b/enochecker3/logging.py @@ -67,7 +67,7 @@ def create_message(self, record: logging.LogRecord) -> EnoLogMessage: type="infrastructure", severity=record.levelname, severity_level=self.to_level(record.levelname), - timestamp=datetime.datetime.now(datetime.UTC).strftime( + timestamp=datetime.datetime.now(datetime.timezone.utc).strftime( "%Y-%m-%dT%H:%M:%S.%fZ" ), message=record.msg, From f2907a022513375365d2d2cc0599e93c6471b747 Mon Sep 17 00:00:00 2001 From: Lucas Druschke Date: Sat, 8 Jun 2024 14:27:21 +0000 Subject: [PATCH 3/4] add setuptools to dev-dependencies --- dev-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-requirements.txt b/dev-requirements.txt index b2de268..54e4083 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -5,3 +5,4 @@ flake8==7.0.0 coverage==7.5.3 pytest==8.2.2 pytest-asyncio==0.23.7 +setuptools=70.0.0 From 9677ae84e1f9ab00b180730fe6310931a4381359 Mon Sep 17 00:00:00 2001 From: Lucas Druschke Date: Sat, 8 Jun 2024 14:27:38 +0000 Subject: [PATCH 4/4] fix typo --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 54e4083..727299a 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -5,4 +5,4 @@ flake8==7.0.0 coverage==7.5.3 pytest==8.2.2 pytest-asyncio==0.23.7 -setuptools=70.0.0 +setuptools==70.0.0