refactor(codeql): decompose complex conditions + harden Vite web-root check#227
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #227 +/- ##
==========================================
- Coverage 44.51% 44.49% -0.02%
==========================================
Files 895 895
Lines 51760 51778 +18
Branches 4827 4834 +7
==========================================
Hits 23041 23041
- Misses 28149 28165 +16
- Partials 570 572 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Bundle ReportBundle size has no change ✅ |
There was a problem hiding this comment.
Pull request overview
Refactors several complex boolean conditions into named sub-conditions / guard clauses to address CodeQL cs/complex-condition findings while keeping behavior the same.
Changes:
CMS.CheckFilePermission: adds an early-return for public files and extracts permission checks into named booleans.ScheduleEditService: deduplicates duplicate/constraint message checks via a helper method.ViteProxyHelpers.CreateProxyRequest: extracts named booleans for “method supports body” and “has readable body”.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| web/ViteProxyHelpers.cs | Simplifies proxy request body-copy condition via named booleans. |
| web/Areas/CMS/Data/CMS.cs | Refactors CMS file permission logic into guard clause + named condition variables. |
| web/Areas/ClinicalScheduler/Services/ScheduleEditService.cs | Extracts DB constraint/duplicate detection into a helper for reuse. |
36fb462 to
472d0e8
Compare
472d0e8 to
65a70be
Compare
3199d4b to
3ceffd8
Compare
3ceffd8 to
f9850b1
Compare
Extract named sub-conditions / guard clauses to clear cs/complex-condition findings, behavior-preserving: - CMS.CheckFilePermission: early-return guard clauses; resolve the user's permissions once into an OrdinalIgnoreCase HashSet instead of re-querying per file permission (removes an O(n^2) scan). - ViteProxyHelpers.CreateProxyRequest: methodSupportsBody / hasReadableBody named bools, comparing the request method with OrdinalIgnoreCase rather than allocating an uppercased copy.
f9850b1 to
2d26d38
Compare
|
@coderabbitai full review |
✅ Action performedFull review finished. |
📝 WalkthroughWalkthroughThe PR refactors CMS file-permission evaluation into ordered early returns and updates Vite proxy helpers to gate request-body copying and tighten static-file fallback path containment checks. ChangesCMS file permission evaluation
Vite proxy request and fallback handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Append a trailing separator to the resolved web root before the StartsWith containment check so a sibling directory (e.g. wwwroot-secret) cannot satisfy the prefix check against wwwroot and bypass the directory-traversal guard when serving Vite static files.
2d26d38 to
933006c
Compare
What
1. Decompose complex boolean conditions (
cs/complex-condition), behavior-preserving:CMS.CheckFilePermission— early-return guard clauses; resolve the user's permissions once into anOrdinalIgnoreCaseHashSet instead of an O(n²) per-permission scan.ViteProxyHelpers.CreateProxyRequest—methodSupportsBody/hasReadableBodynamed bools.2. Fix a directory-boundary bug (folded-in follow-up): the Vite static-file path check used
resolvedPhysical.StartsWith(resolvedWebRoot), which a sibling likewwwroot-secretwould pass. Append a trailing separator (viaPath.EndsInDirectorySeparator) so the check respects the directory boundary.