Skip to content

Commit 8580d8e

Browse files
committed
Remove total and blocked
Simplifies the implementation and we don't need it in the dashboard
1 parent 3f58756 commit 8580d8e

File tree

6 files changed

+0
-134
lines changed

6 files changed

+0
-134
lines changed

library/agent/InspectionStatistics.test.ts

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,9 @@ t.test("it resets stats", async () => {
4141
},
4242
},
4343
userAgents: {
44-
total: 0,
45-
blocked: 0,
4644
breakdown: {},
4745
},
4846
ipAddresses: {
49-
total: 0,
50-
blocked: 0,
5147
breakdown: {},
5248
},
5349
});
@@ -66,13 +62,9 @@ t.test("it resets stats", async () => {
6662
},
6763
},
6864
userAgents: {
69-
total: 0,
70-
blocked: 0,
7165
breakdown: {},
7266
},
7367
ipAddresses: {
74-
total: 0,
75-
blocked: 0,
7668
breakdown: {},
7769
},
7870
});
@@ -102,13 +94,9 @@ t.test("it keeps track of amount of calls", async () => {
10294
},
10395
},
10496
userAgents: {
105-
total: 0,
106-
blocked: 0,
10797
breakdown: {},
10898
},
10999
ipAddresses: {
110-
total: 0,
111-
blocked: 0,
112100
breakdown: {},
113101
},
114102
});
@@ -144,13 +132,9 @@ t.test("it keeps track of amount of calls", async () => {
144132
},
145133
},
146134
userAgents: {
147-
total: 0,
148-
blocked: 0,
149135
breakdown: {},
150136
},
151137
ipAddresses: {
152-
total: 0,
153-
blocked: 0,
154138
breakdown: {},
155139
},
156140
});
@@ -186,13 +170,9 @@ t.test("it keeps track of amount of calls", async () => {
186170
},
187171
},
188172
userAgents: {
189-
total: 0,
190-
blocked: 0,
191173
breakdown: {},
192174
},
193175
ipAddresses: {
194-
total: 0,
195-
blocked: 0,
196176
breakdown: {},
197177
},
198178
});
@@ -222,13 +202,9 @@ t.test("it keeps track of amount of calls", async () => {
222202
},
223203
},
224204
userAgents: {
225-
total: 0,
226-
blocked: 0,
227205
breakdown: {},
228206
},
229207
ipAddresses: {
230-
total: 0,
231-
blocked: 0,
232208
breakdown: {},
233209
},
234210
});
@@ -264,13 +240,9 @@ t.test("it keeps track of amount of calls", async () => {
264240
},
265241
},
266242
userAgents: {
267-
total: 0,
268-
blocked: 0,
269243
breakdown: {},
270244
},
271245
ipAddresses: {
272-
total: 0,
273-
blocked: 0,
274246
breakdown: {},
275247
},
276248
});
@@ -306,13 +278,9 @@ t.test("it keeps track of amount of calls", async () => {
306278
},
307279
},
308280
userAgents: {
309-
total: 0,
310-
blocked: 0,
311281
breakdown: {},
312282
},
313283
ipAddresses: {
314-
total: 0,
315-
blocked: 0,
316284
breakdown: {},
317285
},
318286
});
@@ -367,13 +335,9 @@ t.test("it keeps track of amount of calls", async () => {
367335
},
368336
},
369337
userAgents: {
370-
total: 0,
371-
blocked: 0,
372338
breakdown: {},
373339
},
374340
ipAddresses: {
375-
total: 0,
376-
blocked: 0,
377341
breakdown: {},
378342
},
379343
});
@@ -424,13 +388,9 @@ t.test("it keeps track of requests", async () => {
424388
},
425389
},
426390
userAgents: {
427-
total: 0,
428-
blocked: 0,
429391
breakdown: {},
430392
},
431393
ipAddresses: {
432-
total: 0,
433-
blocked: 0,
434394
breakdown: {},
435395
},
436396
});
@@ -449,13 +409,9 @@ t.test("it keeps track of requests", async () => {
449409
},
450410
},
451411
userAgents: {
452-
total: 0,
453-
blocked: 0,
454412
breakdown: {},
455413
},
456414
ipAddresses: {
457-
total: 0,
458-
blocked: 0,
459415
breakdown: {},
460416
},
461417
});
@@ -475,13 +431,9 @@ t.test("it keeps track of requests", async () => {
475431
},
476432
},
477433
userAgents: {
478-
total: 0,
479-
blocked: 0,
480434
breakdown: {},
481435
},
482436
ipAddresses: {
483-
total: 0,
484-
blocked: 0,
485437
breakdown: {},
486438
},
487439
});
@@ -501,13 +453,9 @@ t.test("it keeps track of requests", async () => {
501453
},
502454
},
503455
userAgents: {
504-
total: 0,
505-
blocked: 0,
506456
breakdown: {},
507457
},
508458
ipAddresses: {
509-
total: 0,
510-
blocked: 0,
511459
breakdown: {},
512460
},
513461
});
@@ -528,13 +476,9 @@ t.test("it keeps track of requests", async () => {
528476
},
529477
},
530478
userAgents: {
531-
total: 0,
532-
blocked: 0,
533479
breakdown: {},
534480
},
535481
ipAddresses: {
536-
total: 0,
537-
blocked: 0,
538482
breakdown: {},
539483
},
540484
});
@@ -562,13 +506,9 @@ t.test("it force compresses stats", async () => {
562506
},
563507
},
564508
userAgents: {
565-
total: 0,
566-
blocked: 0,
567509
breakdown: {},
568510
},
569511
ipAddresses: {
570-
total: 0,
571-
blocked: 0,
572512
breakdown: {},
573513
},
574514
});
@@ -614,13 +554,9 @@ t.test("it keeps track of aborted requests", async () => {
614554
},
615555
},
616556
userAgents: {
617-
total: 0,
618-
blocked: 0,
619557
breakdown: {},
620558
},
621559
ipAddresses: {
622-
total: 0,
623-
blocked: 0,
624560
breakdown: {},
625561
},
626562
});
@@ -653,16 +589,12 @@ t.test("it keeps track of blocked IPs and user agents", async () => {
653589
},
654590
},
655591
userAgents: {
656-
total: 1,
657-
blocked: 1,
658592
breakdown: {
659593
// eslint-disable-next-line camelcase
660594
ai_bots: { total: 1, blocked: 1 },
661595
},
662596
},
663597
ipAddresses: {
664-
total: 1,
665-
blocked: 1,
666598
breakdown: {
667599
"known_threat_actors/public_scanners": { total: 1, blocked: 1 },
668600
},
@@ -697,16 +629,12 @@ t.test("it keeps track of monitored IPs and user agents", async () => {
697629
},
698630
},
699631
userAgents: {
700-
total: 1,
701-
blocked: 0,
702632
breakdown: {
703633
// eslint-disable-next-line camelcase
704634
ai_data_scrapers: { total: 1, blocked: 0 },
705635
},
706636
},
707637
ipAddresses: {
708-
total: 1,
709-
blocked: 0,
710638
breakdown: {
711639
"known_threat_actors/public_scanners": { total: 1, blocked: 0 },
712640
},
@@ -731,16 +659,12 @@ t.test("it keeps track of monitored IPs and user agents", async () => {
731659
},
732660
},
733661
userAgents: {
734-
total: 2,
735-
blocked: 0,
736662
breakdown: {
737663
// eslint-disable-next-line camelcase
738664
ai_data_scrapers: { total: 2, blocked: 0 },
739665
},
740666
},
741667
ipAddresses: {
742-
total: 2,
743-
blocked: 0,
744668
breakdown: {
745669
"known_threat_actors/public_scanners": { total: 2, blocked: 0 },
746670
},
@@ -767,8 +691,6 @@ t.test("should track multiple matches for the same key", (t) => {
767691

768692
const result = stats.getStats();
769693

770-
t.equal(result.ipAddresses.total, 1);
771-
t.equal(result.ipAddresses.blocked, 1);
772694
t.equal(
773695
result.ipAddresses.breakdown["known_threat_actors/public_scanners"].total,
774696
2
@@ -778,8 +700,6 @@ t.test("should track multiple matches for the same key", (t) => {
778700
1
779701
);
780702

781-
t.equal(result.userAgents.total, 1);
782-
t.equal(result.userAgents.blocked, 1);
783703
t.equal(result.userAgents.breakdown["ai_data_scrapers"].total, 2);
784704
t.equal(result.userAgents.breakdown["ai_data_scrapers"].blocked, 1);
785705

library/agent/InspectionStatistics.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ type UserAgentBotKey = string;
2525
type IPListKey = string;
2626

2727
type UserAgentStats = {
28-
total: number;
29-
blocked: number;
3028
breakdown: Record<UserAgentBotKey, { total: number; blocked: number }>;
3129
};
3230

3331
type IPAddressStats = {
34-
total: number;
35-
blocked: number;
3632
breakdown: Record<IPListKey, { total: number; blocked: number }>;
3733
};
3834

@@ -54,13 +50,9 @@ export class InspectionStatistics {
5450
attacksDetected: { total: 0, blocked: 0 },
5551
};
5652
private userAgents: UserAgentStats = {
57-
total: 0,
58-
blocked: 0,
5953
breakdown: {},
6054
};
6155
private ipAddresses: IPAddressStats = {
62-
total: 0,
63-
blocked: 0,
6456
breakdown: {},
6557
};
6658

@@ -97,13 +89,9 @@ export class InspectionStatistics {
9789
attacksDetected: { total: 0, blocked: 0 },
9890
};
9991
this.userAgents = {
100-
total: 0,
101-
blocked: 0,
10292
breakdown: {},
10393
};
10494
this.ipAddresses = {
105-
total: 0,
106-
blocked: 0,
10795
breakdown: {},
10896
};
10997
this.startedAt = Date.now();
@@ -121,13 +109,9 @@ export class InspectionStatistics {
121109
};
122110
};
123111
userAgents: {
124-
total: number;
125-
blocked: number;
126112
breakdown: Record<string, { total: number; blocked: number }>;
127113
};
128114
ipAddresses: {
129-
total: number;
130-
blocked: number;
131115
breakdown: Record<string, { total: number; blocked: number }>;
132116
};
133117
} {
@@ -227,15 +211,6 @@ export class InspectionStatistics {
227211
}
228212

229213
onIPAddressMatches(matches: { key: IPListKey; monitor: boolean }[]) {
230-
if (matches.length > 0) {
231-
this.ipAddresses.total += 1;
232-
}
233-
234-
const blockingMatch = matches.find((match) => !match.monitor);
235-
if (blockingMatch) {
236-
this.ipAddresses.blocked += 1;
237-
}
238-
239214
matches.forEach((match) => {
240215
if (!this.ipAddresses.breakdown[match.key]) {
241216
this.ipAddresses.breakdown[match.key] = { total: 0, blocked: 0 };
@@ -250,15 +225,6 @@ export class InspectionStatistics {
250225
}
251226

252227
onUserAgentMatches(matches: { key: UserAgentBotKey; monitor: boolean }[]) {
253-
if (matches.length > 0) {
254-
this.userAgents.total += 1;
255-
}
256-
257-
const blockingMatch = matches.find((match) => !match.monitor);
258-
if (blockingMatch) {
259-
this.userAgents.blocked += 1;
260-
}
261-
262228
matches.forEach((match) => {
263229
if (!this.userAgents.breakdown[match.key]) {
264230
this.userAgents.breakdown[match.key] = { total: 0, blocked: 0 };

library/agent/api/Event.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,9 @@ type Heartbeat = {
9494
};
9595
};
9696
userAgents: {
97-
total: number;
98-
blocked: number;
9997
breakdown: Record<string, { total: number; blocked: number }>;
10098
};
10199
ipAddresses: {
102-
total: number;
103-
blocked: number;
104100
breakdown: Record<string, { total: number; blocked: number }>;
105101
};
106102
};

0 commit comments

Comments
 (0)