fix(voice): enforce flow authorization on websocket#14043
Conversation
WalkthroughThe voice flow-as-tool WebSocket now retrieves and authorizes the flow before reading its description, resolving voice configuration, or opening connections. New tests cover owner, shared, public, missing, and denied-flow scenarios. ChangesVoice flow authorization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 9✅ Passed checks (9 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
✅ Test Coverage AdvisorNo source changes detected without accompanying tests. Thanks for keeping coverage up! 🎉
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/backend/tests/unit/api/v1/test_voice_mode_flow_authz.py (1)
37-164: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider adding one DB-backed integration test alongside the mock-based suite.
All five tests mock
_read_flow/ensure_flow_permission(and, in the WS test, the OpenAI connection, DB writes, and voice config). This is reasonable for asserting call ordering, but none exercise the real_read_flow/ensure_flow_permissionimplementations against an actual flow, so drift between the mocked contract and the real authorization logic wouldn't be caught here. As per coding guidelines, "Backend unit tests should avoid mocking when possible and prefer real integrations for more reliable tests" and reviewers should "prefer integration tests when unit tests are overly mocked." Theflowfixture inconftest.pyalready provides a DB-backed flow that could back at least one end-to-end_get_authorized_voice_flowtest.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/backend/tests/unit/api/v1/test_voice_mode_flow_authz.py` around lines 37 - 164, Add one DB-backed integration test using the existing conftest.py flow fixture, without mocking _read_flow or ensure_flow_permission, and exercise _get_authorized_voice_flow with a real session and user authorization path. Assert the real flow is returned and preserve the existing mocked tests for call-order coverage.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/backend/tests/unit/api/v1/test_voice_mode_flow_authz.py`:
- Around line 37-164: Add one DB-backed integration test using the existing
conftest.py flow fixture, without mocking _read_flow or ensure_flow_permission,
and exercise _get_authorized_voice_flow with a real session and user
authorization path. Assert the real flow is returned and preserve the existing
mocked tests for call-order coverage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 13cadc2a-c5c0-41a8-a6c2-8eeacad01108
📒 Files selected for processing (2)
src/backend/base/langflow/api/v1/voice_mode.pysrc/backend/tests/unit/api/v1/test_voice_mode_flow_authz.py
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-1.10.3 #14043 +/- ##
=================================================
Coverage ? 58.90%
=================================================
Files ? 2307
Lines ? 221052
Branches ? 34259
=================================================
Hits ? 130201
Misses ? 89366
Partials ? 1485
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
* fix(kb): enforce per-user path containment * fix(security): protect Docling Serve outbound requests (#14033) * fix(security): protect Docling Serve requests * fix(docling): support Self on Python 3.10 * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * fix(auth): verify current password on password changes (#14034) * fix(security): harden MCP stdio configuration (#14036) * fix(security): restrict MCP stdio package sources * fix(security): block MCP Docker host access * fix(security): validate embedded MCP stdio configs * fix: require executable-only MCP commands * test: use allowed MCP commands in timeout tests * fix(security): harden component code module access (#14032) * fix(security): harden component code module access * fix(security): block native FFI imports in generated code * fix: track module assignment aliases in code scanner * fix(security): address alias review findings * fix: correct deprecated model settings behavior (#14047) * fix: prevent deprecated model enablement * test: use supported model in credential cleanup * fix(voice): enforce flow authorization on websocket (#14043) * fix(security): block native FFI imports in generated code (#14040) * fix(security): block native FFI imports in generated code * fix: track module assignment aliases in code scanner * chore: resolve code security conflicts * fix(security): confine AssemblyAI audio file access (#14037) * fix(security): confine AssemblyAI audio file access * [autofix.ci] apply automated fixes * test: stub optional AssemblyAI dependency * fix(security): harden AssemblyAI file submission --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> * fix: track assignment aliases in component code scanner (#14041) fix: bind loop and comprehension aliases --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Summary
Testing
Summary by CodeRabbit
Bug Fixes
Tests