fix(security): guard OpenhumanLinkModal against arbitrary event paths (closes #1945)#1949
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe modal introduces an ALLOWED_PATHS allowlist and ALLOWED_PATHS_SET, validates incoming ChangesPath validation and type safety
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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 |
…closes tinyhumansai#1945) Convert the runtime allowlist to a const array with a derived AllowedPath union type, giving TypeScript exhaustiveness checking in the two switch functions — same pattern as Rust enum matching with no default arm.
3950abb to
078bb7f
Compare
Summary
Guard
OpenhumanLinkModalagainst arbitrary event paths by defining a strict allowlist of 5 known paths. Unknown paths are silently dropped instead of opening the modal.Changes
ALLOWED_PATHSasas constarray with all 5 valid pathsAllowedPathunion type from the array for compile-time exhaustivenessALLOWED_PATHS_SETfor O(1) runtime lookupactivePathstate asAllowedPath | nulltitleForPathandrenderBodyswitched fromstringtoAllowedPathparamdefaultswitch arms — TS catches missing cases at compile timeChecklist
pnpm typecheckpassespnpm lintpassespnpm format:checkpassespnpm testpasses (2192 tests)Summary by CodeRabbit