fix(tradein): CIAN_REQUIRED_COOKIES — add real auth cookies (DMIR_AUTH + Cian session) (#480)
Updated CIAN_REQUIRED_COOKIES filter в cian_session.py по реальному DevTools-дампу logged-in cian.ru сессии (2026-05-23). Добавлены critical auth cookies: DMIR_AUTH (httpOnly), _CIAN_GK, _yasc, _ym_visorc, uxfb_card_satisfaction. Legacy entries сохранены как backward-compat fallback. Regression test test_required_cookies_includes_real_auth гарантирует что все реальные cookies проходят filter. Fixes Stage 4 PR #457 (filter guessed без real probe — DMIR_AUTH был dropped → verify_session falsey).
This commit is contained in:
parent
9643979d2c
commit
99dd403c45
2 changed files with 36 additions and 5 deletions
|
|
@ -19,18 +19,33 @@ from app.services.scrapers.cian_state_parser import extract_state
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Cookies критичные для Cian auth — фильтр перед сохранением.
|
||||
# Conservative set подтверждён в Stage 4 (probe через DevTools на live session).
|
||||
# Список обновлён по реальному DevTools-дампу из logged-in сессии cian.ru (2026-05-23).
|
||||
# Старые записи оставлены как fallback (backward compat).
|
||||
CIAN_REQUIRED_COOKIES: set[str] = {
|
||||
# --- Cian auth & session (critical) ---
|
||||
"DMIR_AUTH", # Cian auth token (httpOnly) — основной auth-сигнал
|
||||
"_CIAN_GK", # Cian session GUID
|
||||
|
||||
# --- Yandex Metrika (обычно присутствуют, не critical) ---
|
||||
"_ym_uid",
|
||||
"_ym_d",
|
||||
"_ym_isad",
|
||||
"_ym_visorc",
|
||||
"_yasc", # Yandex anti-spam
|
||||
|
||||
# --- Cian UX state ---
|
||||
"uxfb_card_satisfaction",
|
||||
|
||||
# --- Cian session IDs (fallback / legacy deployments) ---
|
||||
"_cian_visitor_session_id",
|
||||
"_cian_app_session_id",
|
||||
"_cian_uid",
|
||||
"_ga",
|
||||
"tlsr_id",
|
||||
"cf_clearance",
|
||||
"session-id",
|
||||
|
||||
# --- Misc (legacy / optional) ---
|
||||
"_ga", # Google Analytics
|
||||
"tlsr_id", # legacy fingerprint
|
||||
"cf_clearance", # Cloudflare bot check
|
||||
"session-id", # generic session cookie
|
||||
"anti_bot",
|
||||
"csrftoken",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,22 @@ def test_required_cookies_contains_key_names() -> None:
|
|||
assert "cf_clearance" in CIAN_REQUIRED_COOKIES
|
||||
|
||||
|
||||
def test_required_cookies_includes_real_auth() -> None:
|
||||
"""Real Cian DevTools probe (2026-05-23) — these cookies must pass filter."""
|
||||
real_cookies_from_browser = {
|
||||
"DMIR_AUTH",
|
||||
"_CIAN_GK",
|
||||
"_yasc",
|
||||
"_ym_uid",
|
||||
"_ym_d",
|
||||
"_ym_isad",
|
||||
"_ym_visorc",
|
||||
"uxfb_card_satisfaction",
|
||||
}
|
||||
missing = real_cookies_from_browser - CIAN_REQUIRED_COOKIES
|
||||
assert not missing, f"Filter missing real cookies: {missing}"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# save_session
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue