fix(security): address review findings for audit logging
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 19s
CI / build (pull_request) Successful in 16s
CI / quality (pull_request) Successful in 22s
CI / security (pull_request) Successful in 29s
CI / typecheck (pull_request) Successful in 52s
CI / integration_tests (pull_request) Successful in 2m19s
CI / unit_tests (pull_request) Successful in 6m55s
CI / docker (pull_request) Successful in 37s
CI / benchmark-regression (pull_request) Successful in 11m13s
CI / coverage (pull_request) Failing after 13m40s

This commit is contained in:
khyari hamza
2026-02-19 15:29:26 +00:00
parent 81928ce0f4
commit 201be39632
6 changed files with 159 additions and 35 deletions
+13 -4
View File
@@ -16,6 +16,9 @@ from cleveragents.config.settings import Settings
from cleveragents.infrastructure.database.models import AuditLogModel, Base
from cleveragents.application.services.audit_service import _TIMESTAMP_FMT
def _make_service() -> AuditService:
"""Create a service backed by in-memory SQLite."""
Settings._instance = None
@@ -109,16 +112,22 @@ class TimeQueryEntries:
class TimePrune:
"""Benchmark pruning old audit entries."""
"""Benchmark pruning old audit entries.
Uses ``setup`` to re-seed 200 backdated entries before *each*
benchmark iteration so that every call to ``prune()`` actually
deletes rows (ASV calls ``time_*`` multiple times per ``setup``
by default).
"""
timeout = 30
# ASV calls setup() before each iteration when number=1.
number = 1
def setup(self) -> None:
self.service = _make_service()
# Insert entries backdated to 60 days ago
old_time = (datetime.now(tz=UTC) - timedelta(days=60)).strftime(
"%Y-%m-%dT%H:%M:%S.%f"
)
old_time = (datetime.now(tz=UTC) - timedelta(days=60)).strftime(_TIMESTAMP_FMT)
for i in range(200):
row = AuditLogModel(
event_type="plan_applied",