@@ -8,21 +8,21 @@ export class AttackWaveDetector {
88
99 constructor (
1010 // How many suspicious requests are allowed before triggering an alert
11- private readonly ATTACK_WAVE_THRESHOLD = 6 ,
11+ private readonly attackWaveThreshold = 6 ,
1212 // In what time frame must these requests occur
13- private readonly ATTACK_WAVE_TIME_FRAME = 60 * 1000 , // 60 seconds
13+ private readonly attackWaveTimeFrame = 60 * 1000 , // 60 seconds
1414 // Minimum time before reporting a new event for the same ip
15- private readonly MIN_TIME_BETWEEN_EVENTS = 60 * 60 * 1000 , // 1 hour
15+ private readonly minTimeBetweenEvents = 60 * 60 * 1000 , // 1 hour
1616 // Maximum number of entries in the LRU cache
17- private readonly MAX_LRU_ENTRIES = 10_000
17+ private readonly maxLRUEntries = 10_000
1818 ) {
1919 this . suspiciousRequestsMap = new LRUMap (
20- this . MAX_LRU_ENTRIES ,
21- this . ATTACK_WAVE_TIME_FRAME
20+ this . maxLRUEntries ,
21+ this . attackWaveTimeFrame
2222 ) ;
2323 this . sentEventsMap = new LRUMap (
24- this . MAX_LRU_ENTRIES ,
25- this . MIN_TIME_BETWEEN_EVENTS
24+ this . maxLRUEntries ,
25+ this . minTimeBetweenEvents
2626 ) ;
2727 }
2828
@@ -52,7 +52,7 @@ export class AttackWaveDetector {
5252 const suspiciousRequests = ( this . suspiciousRequestsMap . get ( ip ) || 0 ) + 1 ;
5353 this . suspiciousRequestsMap . set ( ip , suspiciousRequests ) ;
5454
55- if ( suspiciousRequests < this . ATTACK_WAVE_THRESHOLD ) {
55+ if ( suspiciousRequests < this . attackWaveThreshold ) {
5656 return false ;
5757 }
5858
0 commit comments