fix: address auth-hardening verify findings

Drop the body-limit rule from HAProxy (user decision 2026-11-18): the
replica middleware answers 400 with X-Instance-Id, tests require the
header again. Widen the failure_checks selection in the trust matrix,
name 13fdd18 in the evidence header, document Valkey LRU eviction of
login counters and the allowlist as trusted X-Forwarded-For senders,
check waited_ms of KDF budget rejections in the queue scenario.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 10:31:57 +03:00
co-authored by Claude Opus 5.5
parent 4d117f0297
commit 3f4771c9d9
22 changed files with 372 additions and 127 deletions
+5 -15
View File
@@ -142,15 +142,10 @@ def assert_accepted(resp: httpx.Response) -> dict[str, Any]:
return attachment
def assert_error(
resp: httpx.Response,
status: int,
*,
instance_id: bool = True,
) -> dict[str, Any]:
def assert_error(resp: httpx.Response, status: int) -> dict[str, Any]:
"""Ошибка в формате контракта; `code` соответствует статусу."""
assert resp.status_code == status, describe(resp, f"expected {status}")
body = json_body(resp, instance_id=instance_id)
body = json_body(resp)
check_body(body, "Error")
error = body["error"]
assert error["code"] == ERROR_CODES[status], describe(
@@ -319,16 +314,11 @@ def assert_replicas(values: Iterable[str], expected: int) -> set[str]:
return seen
def json_body(resp: httpx.Response, *, instance_id: bool = True) -> Any:
"""JSON-тело в UTF-8, непустые `X-Request-Id` и `X-Instance-Id`.
`instance_id=False` — ответ мог построить сам LB (предел тела, change
auth-hardening): у его ответов `X-Instance-Id` нет, контракт допускает.
"""
def json_body(resp: httpx.Response) -> Any:
"""JSON-тело в UTF-8, непустые `X-Request-Id` и `X-Instance-Id`."""
request_id = resp.headers.get("X-Request-Id", "")
assert request_id.strip(), describe(resp, "no X-Request-Id")
if instance_id:
assert_instance_id(resp)
assert_instance_id(resp)
media_type, _, params = resp.headers.get("Content-Type", "").partition(
";",
)