Skip to content

Commit 0b7c047

Browse files
pwizlaweb-flow
andauthored
Add sanitize/validation callout to Controllers documentation (#2847)
* docs(backend): correct TypeScript code fences in TS tabs (controllers, services, middlewares, routes) * docs(bundlers): clarify webpack config example rename and JS/TS filenames * docs(routes): add guidance to prefer fully-qualified handler names in custom routers * docs(api-tokens): add concise security tip (least privilege, rotation, secrets manager) * docs(controllers): add caution about validateQuery/sanitizeQuery/sanitizeOutput when overriding actions * Limit PR scope based on title; keep only intended doc(s); revert unrelated files --------- Co-authored-by: GitHub Actions <[email protected]>
1 parent d2f5766 commit 0b7c047

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docusaurus/docs/cms/backend-customization/controllers.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ In most cases, the controllers will contain the bulk of a project's business log
2929
<em><figcaption style={{fontSize: '12px'}}>The diagram represents a simplified version of how a request travels through the Strapi back end, with controllers highlighted. The backend customization introduction page includes a complete, <a href="/cms/backend-customization#interactive-diagram">interactive diagram</a>.</figcaption></em>
3030
</figure>
3131

32+
:::caution Sanitize inputs and outputs
33+
When overriding core actions, always validate and sanitize queries and responses to avoid leaking private fields or bypassing access rules. Use `validateQuery` (optional), `sanitizeQuery` (recommended), and `sanitizeOutput` before returning data from custom actions. See the example below for a safe `find` override.
34+
:::
35+
3236
## Implementation
3337

3438
Controllers can be [generated or added manually](#adding-a-new-controller). Strapi provides a `createCoreController` factory function that automatically generates core controllers and allows building custom ones or [extend or replace the generated controllers](#extending-core-controllers).

0 commit comments

Comments
 (0)