diff --git a/end2end/server/src/zen/config.js b/end2end/server/src/zen/config.js index 53fe7e9a2..977a252ed 100644 --- a/end2end/server/src/zen/config.js +++ b/end2end/server/src/zen/config.js @@ -9,7 +9,6 @@ function generateConfig(app) { endpoints: [], blockedUserIds: [], allowedIPAddresses: [], - receivedAnyStats: false, }; } diff --git a/library/agent/Agent.test.ts b/library/agent/Agent.test.ts index 446c6f97b..ba2a2a66a 100644 --- a/library/agent/Agent.test.ts +++ b/library/agent/Agent.test.ts @@ -421,7 +421,6 @@ t.test( blockedUserIds: [], allowedIPAddresses: [], block: true, - receivedAnyStats: false, }); const agent = createTestAgent({ api, @@ -490,7 +489,6 @@ t.test( blockedUserIds: [], allowedIPAddresses: [], block: true, - receivedAnyStats: false, }); const agent = createTestAgent({ api, diff --git a/library/agent/Agent.ts b/library/agent/Agent.ts index a5165a2a6..3fd3a3766 100644 --- a/library/agent/Agent.ts +++ b/library/agent/Agent.ts @@ -50,15 +50,7 @@ export class Agent { private timeoutInMS = 30 * 1000; private hostnames = new Hostnames(200); private users = new Users(1000); - private serviceConfig = new ServiceConfig( - [], - Date.now(), - [], - [], - true, - [], - [] - ); + private serviceConfig = new ServiceConfig([], Date.now(), [], [], [], []); private routes: Routes = new Routes(200); private rateLimiter: RateLimiter = new RateLimiter(5000, 120 * 60 * 1000); private statistics = new InspectionStatistics({ @@ -310,10 +302,7 @@ export class Agent { response.allowedIPAddresses && Array.isArray(response.allowedIPAddresses) ? response.allowedIPAddresses - : [], - typeof response.receivedAnyStats === "boolean" - ? response.receivedAnyStats - : true + : [] ); } diff --git a/library/agent/Config.ts b/library/agent/Config.ts index 7816ed6c6..e31ca8f82 100644 --- a/library/agent/Config.ts +++ b/library/agent/Config.ts @@ -27,5 +27,4 @@ export type Config = { blockedUserIds: string[]; allowedIPAddresses: string[]; block?: boolean; - receivedAnyStats?: boolean; }; diff --git a/library/agent/ServiceConfig.test.ts b/library/agent/ServiceConfig.test.ts index 695f7a492..c57edeeaf 100644 --- a/library/agent/ServiceConfig.test.ts +++ b/library/agent/ServiceConfig.test.ts @@ -2,7 +2,7 @@ import * as t from "tap"; import { ServiceConfig } from "./ServiceConfig"; t.test("it returns false if empty rules", async () => { - const config = new ServiceConfig([], 0, [], [], false, [], []); + const config = new ServiceConfig([], 0, [], [], [], []); t.same(config.getLastUpdatedAt(), 0); t.same(config.isUserBlocked("id"), false); t.same(config.isBypassedIP("1.2.3.4"), false); @@ -53,7 +53,6 @@ t.test("it works", async () => { 0, ["123"], [], - false, [], [] ); @@ -83,7 +82,7 @@ t.test("it works", async () => { }); t.test("it checks if IP is bypassed", async () => { - const config = new ServiceConfig([], 0, [], ["1.2.3.4"], false, [], []); + const config = new ServiceConfig([], 0, [], ["1.2.3.4"], [], []); t.same(config.isBypassedIP("1.2.3.4"), true); t.same(config.isBypassedIP("1.2.3.5"), false); }); @@ -94,7 +93,6 @@ t.test("ip blocking works", async () => { 0, [], [], - false, [ { key: "geoip/Belgium;BE", @@ -143,7 +141,7 @@ t.test("ip blocking works", async () => { }); t.test("it blocks bots", async () => { - const config = new ServiceConfig([], 0, [], [], true, [], []); + const config = new ServiceConfig([], 0, [], [], [], []); config.updateBlockedUserAgents("googlebot|bingbot"); t.same(config.isUserAgentBlocked("googlebot"), { blocked: true }); @@ -161,7 +159,6 @@ t.test("restricting access to some ips", async () => { 0, [], [], - true, [], [ { @@ -189,7 +186,6 @@ t.test("only allow some ips: empty list", async () => { 0, [], [], - true, [], [ { @@ -211,7 +207,6 @@ t.test("bypassed ips support cidr", async () => { 0, [], ["192.168.2.0/24", "::1"], - false, [], [] ); @@ -221,13 +216,7 @@ t.test("bypassed ips support cidr", async () => { t.same(config.isBypassedIP("::2"), false); t.same(config.isBypassedIP("10.0.0.1"), false); - config.updateConfig( - [], - 0, - [], - ["invalid", "2002::1/124", "127.0.0.1"], - false - ); + config.updateConfig([], 0, [], ["invalid", "2002::1/124", "127.0.0.1"]); t.same(config.isBypassedIP("2002::6"), true); t.same(config.isBypassedIP("2002::f"), true); @@ -240,8 +229,7 @@ t.test("bypassed ips support cidr", async () => { [], 0, [], - ["0", "123.123.123.1/32", "234.0.0.0/8", "999.999.999.999", "::1/128"], - false + ["0", "123.123.123.1/32", "234.0.0.0/8", "999.999.999.999", "::1/128"] ); t.same(config.isBypassedIP("123.123.123.1"), true); @@ -253,14 +241,14 @@ t.test("bypassed ips support cidr", async () => { t.same(config.isBypassedIP("::1"), true); t.same(config.isBypassedIP("::2"), false); - config.updateConfig([], 0, [], [], false); + config.updateConfig([], 0, [], []); t.same(config.isBypassedIP("123.123.123.1"), false); t.same(config.isBypassedIP("999.999.999.999"), false); }); t.test("it sets and updates monitored IP lists", async (t) => { - const config = new ServiceConfig([], 0, [], [], false, [], []); + const config = new ServiceConfig([], 0, [], [], [], []); t.same(config.getMatchingMonitoredIPListKeys("9.9.9.9"), []); t.same(config.getMatchingMonitoredIPListKeys("1.2.3.4"), []); @@ -284,7 +272,7 @@ t.test("it sets and updates monitored IP lists", async (t) => { }); t.test("it returns matching IP lists keys", async (t) => { - const config = new ServiceConfig([], 0, [], [], false, [], []); + const config = new ServiceConfig([], 0, [], [], [], []); config.updateMonitoredIPAddresses([ { @@ -340,7 +328,7 @@ t.test("it returns matching IP lists keys", async (t) => { }); t.test("should return all matching user agent patterns", async (t) => { - const config = new ServiceConfig([], 0, [], [], false, [], []); + const config = new ServiceConfig([], 0, [], [], [], []); config.updateUserAgentDetails([ { key: "list1", @@ -359,7 +347,7 @@ t.test("should return all matching user agent patterns", async (t) => { }); t.test("it clears RegExp when updating with empty pattern", async (t) => { - const config = new ServiceConfig([], 0, [], [], false, [], []); + const config = new ServiceConfig([], 0, [], [], [], []); config.updateBlockedUserAgents("googlebot"); config.updateMonitoredUserAgents("googlebot"); config.updateUserAgentDetails([ @@ -381,7 +369,7 @@ t.test("it clears RegExp when updating with empty pattern", async (t) => { t.test( "it does not throw error when updating user agent lists with invalid patterns", async (t) => { - const config = new ServiceConfig([], 0, [], [], false, [], []); + const config = new ServiceConfig([], 0, [], [], [], []); config.updateBlockedUserAgents("googlebot"); config.updateMonitoredUserAgents("googlebot"); diff --git a/library/agent/ServiceConfig.ts b/library/agent/ServiceConfig.ts index a813af021..e4d92f426 100644 --- a/library/agent/ServiceConfig.ts +++ b/library/agent/ServiceConfig.ts @@ -32,7 +32,6 @@ export class ServiceConfig { private lastUpdatedAt: number, blockedUserIds: string[], bypassedIPAddresses: string[], - private receivedAnyStats: boolean, blockedIPAddresses: IPList[], allowedIPAddresses: IPList[] ) { @@ -261,21 +260,15 @@ export class ServiceConfig { endpoints: EndpointConfig[], lastUpdatedAt: number, blockedUserIds: string[], - bypassedIPAddresses: string[], - hasReceivedAnyStats: boolean + bypassedIPAddresses: string[] ) { this.setEndpoints(endpoints); this.setBlockedUserIds(blockedUserIds); this.setBypassedIPAddresses(bypassedIPAddresses); this.lastUpdatedAt = lastUpdatedAt; - this.receivedAnyStats = hasReceivedAnyStats; } getLastUpdatedAt() { return this.lastUpdatedAt; } - - hasReceivedAnyStats() { - return this.receivedAnyStats; - } } diff --git a/library/ratelimiting/getRateLimitedEndpoint.test.ts b/library/ratelimiting/getRateLimitedEndpoint.test.ts index defd2f610..ab5f530ce 100644 --- a/library/ratelimiting/getRateLimitedEndpoint.test.ts +++ b/library/ratelimiting/getRateLimitedEndpoint.test.ts @@ -18,10 +18,7 @@ const context: Context = { t.test("it returns undefined if no endpoints", async () => { t.same( - getRateLimitedEndpoint( - context, - new ServiceConfig([], 0, [], [], true, [], []) - ), + getRateLimitedEndpoint(context, new ServiceConfig([], 0, [], [], [], [])), undefined ); }); @@ -47,7 +44,6 @@ t.test("it returns undefined if no matching endpoints", async () => { 0, [], [], - false, [], [] ) @@ -77,7 +73,6 @@ t.test("it returns undefined if matching but not enabled", async () => { 0, [], [], - false, [], [] ) @@ -107,7 +102,6 @@ t.test("it returns endpoint if matching and enabled", async () => { 0, [], [], - false, [], [] ) @@ -158,7 +152,6 @@ t.test("it returns endpoint with lowest max requests", async () => { 0, [], [], - false, [], [] ) @@ -209,7 +202,6 @@ t.test("it returns endpoint with smallest window size", async () => { 0, [], [], - false, [], [] ) @@ -260,7 +252,6 @@ t.test("it always returns exact matches first", async () => { 0, [], [], - false, [], [] ) diff --git a/library/sinks/Undici.tests.ts b/library/sinks/Undici.tests.ts index 4f2acac73..5edbd3102 100644 --- a/library/sinks/Undici.tests.ts +++ b/library/sinks/Undici.tests.ts @@ -55,7 +55,6 @@ export async function createUndiciTests(undiciPkgName: string, port: number) { blockedUserIds: [], allowedIPAddresses: ["1.2.3.4"], block: true, - receivedAnyStats: false, }); const agent = startTestAgent({ api, diff --git a/library/sinks/Undici2.tests.ts b/library/sinks/Undici2.tests.ts index c260af1b5..b39bc35f6 100644 --- a/library/sinks/Undici2.tests.ts +++ b/library/sinks/Undici2.tests.ts @@ -96,7 +96,6 @@ export async function createUndiciTests(undiciPkgName: string, port: number) { blockedUserIds: [], allowedIPAddresses: ["1.2.3.4"], block: true, - receivedAnyStats: false, }); const agent = startTestAgent({ api,