fastmcp/tests/resources
Jeremiah Lowin d779414f8a
Screen templated resource parameters for path traversal by default (#4482)
* Add ResourceSecurity screening for templated resources (defaults on)

* Add tests for resource path-security screening

* Document resource path-security; fix ty in tests

* Carry child template security policy through provider mount

Preserve a mounted template's explicit ResourceSecurity (per-param
exemptions or a deliberate opt-out) through FastMCPProviderResourceTemplate.wrap
so the parent read chokepoint honours it instead of the parent default.

* Defer mcp SDK import so fastmcp.resources loads without the [mcp] extra

* Make resource path-security docs examples self-contained and runnable

* Match exempt_params under both hyphen and underscore spellings

Template placeholders like {git-ref} extract as git_ref, so an exemption
written with the natural URI-template spelling never matched.

* Docs: describe net-depth traversal rule accurately; make example runnable

The screening only rejects .. segments that escape the starting depth
(foo/../bar passes) — saying any standalone .. is rejected overstated
the guarantee. Also define DOCS_ROOT so the example runs.
2026-07-17 17:42:48 -04:00
..
__init__.py restore 1.x code 2025-04-09 11:54:42 -04:00
test_file_resources.py Add encoding parameter to FileResource (#3580) 2026-03-22 09:55:16 -04:00
test_function_resources.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_resource_security.py Screen templated resource parameters for path traversal by default (#4482) 2026-07-17 17:42:48 -04:00
test_resource_template.py fix(resources): round-trip path values with reserved characters in URI templates (#4368) 2026-06-24 13:56:04 -04:00
test_resource_template_meta.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_resource_template_query_params.py Raise ValueError for invalid boolean query params in resource templates (#3424) (#3434) 2026-03-07 11:40:29 -05:00
test_resources.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_standalone_decorator.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00