@@ -30,7 +30,7 @@ function newAttackWaveDetector() {
3030 attackWaveTimeFrame : 60 * 1000 ,
3131 minTimeBetweenEvents : 60 * 60 * 1000 ,
3232 maxLRUEntries : 10_000 ,
33- maxSamplesPerIP : 6 ,
33+ maxSamplesPerIP : 5 ,
3434 } ) ;
3535}
3636
@@ -160,13 +160,12 @@ t.test("it collects samples correctly", async (t) => {
160160 detector . check ( getTestContext ( ip , "/.git/config" , "GET" ) ) ;
161161 detector . check ( getTestContext ( ip , "/.env" , "GET" ) ) ;
162162 detector . check ( getTestContext ( ip , "/.htaccess" , "GET" ) ) ;
163- detector . check ( getTestContext ( ip , "/.htpasswd" , "GET" ) ) ;
164163
165164 detector . check ( getTestContext ( ip , "/.htaccess" , "GET" ) ) ; // Duplicate
166- detector . check ( getTestContext ( "::2" , "/.htpasswd " , "GET" ) ) ; // Different IP
165+ detector . check ( getTestContext ( "::2" , "/test/.env " , "GET" ) ) ; // Different IP
167166
168167 const samples = detector . getSamplesForIP ( ip ) ;
169- t . equal ( samples . length , 6 , "should have collected 6 samples" ) ;
168+ t . equal ( samples . length , 5 , "should have collected 5 samples" ) ;
170169
171170 t . same (
172171 samples ,
@@ -176,7 +175,6 @@ t.test("it collects samples correctly", async (t) => {
176175 { method : "GET" , url : "http://localhost:4000/.git/config" } ,
177176 { method : "GET" , url : "http://localhost:4000/.env" } ,
178177 { method : "GET" , url : "http://localhost:4000/.htaccess" } ,
179- { method : "GET" , url : "http://localhost:4000/.htpasswd" } ,
180178 ] ,
181179 "should have collected the correct samples"
182180 ) ;
@@ -191,5 +189,17 @@ t.test("it limits samples correctly", async (t) => {
191189 }
192190
193191 const samples = detector . getSamplesForIP ( ip ) ;
194- t . equal ( samples . length , 6 , "should have collected maximum 6 samples" ) ;
192+ t . equal ( samples . length , 5 , "should have collected maximum 5 samples" ) ;
193+
194+ t . same (
195+ samples ,
196+ [
197+ { method : "GET" , url : "http://localhost:4000/0/.env" } ,
198+ { method : "GET" , url : "http://localhost:4000/1/.env" } ,
199+ { method : "GET" , url : "http://localhost:4000/2/.env" } ,
200+ { method : "GET" , url : "http://localhost:4000/3/.env" } ,
201+ { method : "GET" , url : "http://localhost:4000/4/.env" } ,
202+ ] ,
203+ "should have collected the correct samples"
204+ ) ;
195205} ) ;
0 commit comments