fix(pdf): brand-spoof + median=0 empty-state + SSRF + дисклеймер + sources (Refs #772) #789
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#789
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/772-pdf-security"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Что
5 связанных client-facing + legal дефектов PDF-генерации (audit #7/#8/#9/#13/#33). PDF уходит клиентам, демо 2026-06-01. Все 5 частей сделаны.
Части
estimate.created_by(get_brand_for_user), НЕ из?brand=query. Query-param удалён → юзер не может подставить чужой бренд.generate_trade_in_pdfгейтит поestimate.insufficient_data→ empty-state «недостаточно данных» вместо «0,0 млн» + фабрикованной таблицы потерь._build_coverрендеритbrand.pdf_disclaimer+ валидированныйbrand.logo_urlна обложке (были=None).base_url="file:///"→base_url=None+_make_safe_url_fetcher(блокируетfile://, allowdata:/CDN);_safe_logo_url+_safe_color(^#RRGGBB$) валидируют перед вставкой в HTML/CSS.grep base_url="file:///"→ 0.n_with_repair=n_total(убран фабрикованный 40%-эвристик); sources изestimate.sources_used(не хардкод); None-guard в_examples_rows(рендер—, не краш).report_numberоставлен как есть (estimate_id UUID уникален; смена display-формата сломала бы нумерацию без явного спека — зафиксировано).brand.pyизменений не потребовал.Тесты
tests/test_pdf_security.py(новый): brand-from-owner, insufficient→empty-state, safe_url/safe_color allow-deny, file:// blocked, None-fields no-crash.pytest -k "pdf or brand"→ 54 pass, ruff clean.Refs #772
✅ APPROVE
PDF security, 5 частей (#772). trade_in.py + trade_in_pdf.py + новый тест (config.py НЕ тронут → нет конфликта с #790). Security tripwire clear: allowlist-домены публичны, нет hex/key/JWT.
Correctness (все 5 частей проверены в диффе)
brandquery-param; бренд теперьget_brand_for_user(row.created_by)— server-side двойник #765, блокирует brand-skinned PDF чужого бренда (чейн IDOR #690/#710). Тест ассертит удаление param из сигнатуры.generate_trade_in_pdfгейтит наinsufficient_data→_build_insufficient_data_pageвместо фабрикованного 0-млн отчёта + loss-таблицы. Согласовано с #697/#740/#748.pdf_disclaimer+ валидированный logo (fallback на name).base_url="file:///"→None+_make_safe_url_fetcher(только data:/https:, блок file://);_safe_logo_url(https+allowlist или data:);_safe_color(^#RRGGBB$). Двухслойная защита (allowlist + scheme-block). Закрывает file:// exfiltration-вектор.~40%(n_with_repair=n_total), sources изestimate.sources_usedне хардкод, None-guards в_examples_rows.report_numberоставлен (задокументировано — UUID уникален, нет спека на формат).Tests — тщательный
test_pdf_security.py: empty-state, disclaimer/logo, safe_logo_url allow/deny (file/http/unknown/data/None), safe_color, url_fetcher (file блок, data/https allow, http блок), base_url≠file:///, n_with_repair, sources-from-estimate, None-guards, signature. WeasyPrint stubbed. 54 pass, ruff clean.Scope/security — trade_in.py + trade_in_pdf.py + тест; нет config.py, нет миграции, нет литеральных secrets, нет self-extending триггера.
Verdict: ✅ APPROVE (Praktika security #772). Client-facing/legal PDF → qa.