-
Notifications
You must be signed in to change notification settings - Fork 2
fix: improve loan approval logic and add security hardening #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve loan approval logic and add security hardening #38
Conversation
- LoanApprovalController: validate pre-assigned copy before global slot counting to prevent false rejections when slots are at capacity but the loan already has a valid assigned copy - ReservationsAdminController: add date format validation for dataPrenotazione and dataScadenza in store method (matching update method) - Updater: improve path protection to also block deletion of files with protected basename in subdirectories (e.g., subdir/.env)
|
Caution Review failedThe pull request is closed. WalkthroughRifattorizzato il flusso di approvazione prestiti per preferire copie già assegnate, introdotte verifiche multi-step di disponibilità e lock post-selezione; aggiunta validazione formato date su prenotazioni; estesa protezione basename in cleanup post-install; modificata logica di ricalcolo disponibilità e guardia su ripristino copie scadute. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 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 |
- MaintenanceService.checkExpiredPickups: don't reset copies in perso/danneggiato/manutenzione states to 'disponibile' (non-restorable) - DataIntegrity: only mark copy as 'prestato' for in_corso/in_ritardo states, not for prenotato with reached date. With da_ritirare flow, the physical copy stays 'disponibile' until pickup is confirmed.
…ter-improvements fix: improve loan approval logic and add security hardening
Summary
Changes
LoanApprovalController
The global slot counting (checking total copies vs overlapping loans/reservations) was happening before validating if the loan already had a valid pre-assigned copy. This caused false rejections when:
Fix: Reordered the logic to validate pre-assigned copy first, skip global counting if valid.
ReservationsAdminController
Added missing date format validation (
/^\d{4}-\d{2}-\d{2}$/) fordataPrenotazioneanddataScadenzain thestore()method (already present inupdate()).Updater.php
Enhanced path protection to also block deletion of files with protected basename in any subdirectory (e.g.,
subdir/.env).Test plan
.envfiles in subdirectoriesSummary by CodeRabbit
Note di Rilascio
Bug Fixes
Refactor
Comportamento
✏️ Tip: You can customize this high-level summary in your review settings.