Единая валидация context в публичном каталоге - #665
Open
Ibochkarev wants to merge 1 commit into
Open
Conversation
Reject invalid explicit context (charset, length, mgr*) with HTTP 400 across product/category catalog paths, and sanitize fallback keys so manager context cannot slip into queries via modx->context->key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
Публичные каталожные эндпоинты принимали
contextтолько черезtrim(). Правила выровнены сCatalogResolve::sanitizeContextиз #644 (на beta ещё нет): charset[a-zA-Z0-9_-]+, длина ≤ 100, запрет префиксаmgr.Явный невалидный
context→ HTTP 400 (ms3_err_catalog_context_invalid). Пустой / отсутствующий параметр → прежний fallback. Fallback-ключ тоже проходит тот же валидатор (иначеweb). Вproduct/filtersконтекст проверяется до чтения facet-кэша.Тип изменений
Клиенты, которые слали
context=mgrили мусор и получали пустой список / «как получится», теперь получают 400.Связанные Issues
Closes #658
Как это было протестировано?
cd core/components/minishop3 php -l src/Services/Catalog/CatalogQuery.php php -l src/Services/Catalog/CatalogContextException.php php -l src/Services/Product/ProductFacetService.php php -l src/Controllers/Api/Web/ProductController.php php -l src/Controllers/Api/Web/CategoryController.php php tests/CatalogQueryTest.phpРезультаты:
php -lOK,CatalogQueryTestOK, exit 0.composer ci:php/composer test,npm run lint:ci,composer stan/ GitHub Actions CI)Конфигурация тестирования:
fix/issue-658-catalog-context-validationотbetaСкриншоты (если применимо)
Чеклист
composer stan/ CI jobPHPStan)npm run lint:ciдля Vue)Дополнительные заметки
CatalogResolveна beta ещё нет:CatalogQuery::sanitizeContext()готов к делегированию после merge #644. ОбъединениеCatalogContextExceptionсProductCatalogFilterExceptionв один base-тип отложено.