Repository navigation
fix(adapters): set explicit text/plain content type on blocked responses - #25
Conversation
|
Thanks for opening your first pull request on flaskapi-guard! Quick checklist before review (most of these are enforced by CI, but worth a glance):
See CONTRIBUTING.md for the full workflow and the Code of Conduct for the community standards we follow. Welcome aboard — a maintainer will review shortly. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe response factory now sets blocked responses to ChangesBlocked response content type
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The blocked-response content-type change appears ready to merge after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Blocked responses now declare plain text explicitly. The available tests show that nosniff and application-defined content-type overrides still work; no new access path or weakened control was identified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
FlaskResponseFactory.create_responsefell back to Flask's defaulttext/html. UnderX-Content-Type-Options: nosniff(applied by default), that is exactly the gap fastapi-guard fixed in #144: the block page should be explicittext/plain.create_responsenow passesmimetype="text/plain"(wire value:text/plain; charset=utf-8). Redirect responses are untouched (no body, no content type).custom_error_responsestext staystext/plain, and acustom_response_modifiercan still set its own content type.Tests
tests/test_block_response_content_type.py, mirroring fastapi-guard's test of the same name: block response is plain text with nosniff, custom error message stays plain text, modifier override wins.test_flask_response_factory_createwith the header assertion.Summary by CodeRabbit
text/plain; charset=utf-8by default, including responses for blocked requests.application/problem+json.