fix: prevent infinite recursion and fix nanosecond vs second bug in session manager#28860
fix: prevent infinite recursion and fix nanosecond vs second bug in session manager#28860magic-peach wants to merge 1 commit into
Conversation
❗ Preview Environment deployment failed on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
PR Summary by QodoFix session-manager login failure tracking (duration units + safe eviction)
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
15 rules 1.
|
Bundle ReportBundle size has no change ✅ |
There was a problem hiding this comment.
@magic-peach thank you for your submission!
Please could you open issue(s) for the bugs you found in the session manager and link your PR to the issue(s) created?
Please could you write/modify unit tests for the changes you made?
Please could you make your PR draft and not submit it to the review until it passes the tests and complies with other requirements to PRs according to the Developer's Guide?
…ession manager - Replace recursive pickRandomNonAdminLoginFailure with iterative approach to prevent stack overflow when all entries are admin/username - Add bounds check for len(failures) <= 1 to prevent panic from rand.Intn(0) - Fix getLoginFailureWindow returning nanoseconds instead of seconds by multiplying by time.Second - Fix expireOldFailedAttempts to use duration comparison directly instead of multiplying by time.Second again - Fix exceededFailedLoginAttempts to compare durations directly instead of converting to float64 seconds Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
ab223f4 to
39aca3a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #28860 +/- ##
==========================================
+ Coverage 65.33% 65.38% +0.04%
==========================================
Files 426 426
Lines 60031 60166 +135
==========================================
+ Hits 39221 39339 +118
+ Misses 17211 17208 -3
- Partials 3599 3619 +20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Summary
Fixed multiple bugs in
util/session/sessionmanager.gorelated to login failure tracking.Fixes #28870
Changes
pickRandomNonAdminLoginFailurewith iterative approach to prevent stack overflow when all entries are admin/usernamelen(failures) <= 1to prevent panic fromrand.Intn(0)getLoginFailureWindowreturning nanoseconds instead of seconds by multiplying bytime.SecondexpireOldFailedAttemptsto use duration comparison directly instead of multiplying bytime.SecondagainexceededFailedLoginAttemptsto compare durations directly instead of converting tofloat64seconds