惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
月光博客
月光博客
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
IT之家
IT之家
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
S
SegmentFault 最新的问题
宝玉的分享
宝玉的分享
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
博客园 - 司徒正美
爱范儿
爱范儿

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(gateway): default non-finite auth guard limits · open...
unauthorized-flood-guard.test.ts · 2026-05-29 · via Recent Commits to openclaw:main

File tree

  • src/gateway/server/ws-connection

Original file line numberDiff line numberDiff line change

@@ -47,6 +47,31 @@ describe("HandshakeAuthLogLimiter", () => {

4747

});

4848

});

4949
50+

it("uses default limits for non-finite options", () => {

51+

const limiter = new HandshakeAuthLogLimiter({

52+

intervalMs: Number.NaN,

53+

maxEntries: Number.POSITIVE_INFINITY,

54+

});

55+
56+

expect(limiter.register("first", 0)).toEqual({

57+

shouldLog: true,

58+

suppressedSinceLastLog: 0,

59+

});

60+

expect(limiter.register("first", 1_000)).toEqual({

61+

shouldLog: false,

62+

suppressedSinceLastLog: 0,

63+

});

64+
65+

for (let i = 0; i < 256; i += 1) {

66+

limiter.register(`key-${i}`, i);

67+

}

68+
69+

expect(limiter.register("first", 2_000)).toEqual({

70+

shouldLog: true,

71+

suppressedSinceLastLog: 0,

72+

});

73+

});

74+
5075

it("only rate-limits benign missing-credential startup retries", () => {

5176

expect(

5277

shouldLimitMissingCredentialAuthLog({

Original file line numberDiff line numberDiff line change

@@ -1,3 +1,5 @@

1+

import { resolveIntegerOption } from "../../../shared/number-coercion.js";

2+
13

export type HandshakeAuthLogDecision = {

24

shouldLog: boolean;

35

suppressedSinceLastLog: number;

@@ -14,8 +16,8 @@ export class HandshakeAuthLogLimiter {

1416

private readonly entries = new Map<string, HandshakeAuthLogState>();

1517
1618

constructor(options?: { intervalMs?: number; maxEntries?: number }) {

17-

this.intervalMs = Math.max(1, Math.floor(options?.intervalMs ?? 30_000));

18-

this.maxEntries = Math.max(1, Math.floor(options?.maxEntries ?? 256));

19+

this.intervalMs = resolveIntegerOption(options?.intervalMs, 30_000, { min: 1 });

20+

this.maxEntries = resolveIntegerOption(options?.maxEntries, 256, { min: 1 });

1921

}

2022
2123

register(key: string, nowMs = Date.now()): HandshakeAuthLogDecision {

Original file line numberDiff line numberDiff line change

@@ -31,6 +31,25 @@ describe("UnauthorizedFloodGuard", () => {

3131

});

3232

});

3333
34+

it("uses default thresholds for non-finite options", () => {

35+

const guard = new UnauthorizedFloodGuard({

36+

closeAfter: Number.NaN,

37+

logEvery: Number.POSITIVE_INFINITY,

38+

});

39+
40+

for (let i = 0; i < 10; i += 1) {

41+

expect(guard.registerUnauthorized().shouldClose).toBe(false);

42+

}

43+
44+

const eleventh = guard.registerUnauthorized();

45+

expect(eleventh).toMatchObject({

46+

shouldClose: true,

47+

shouldLog: true,

48+

count: 11,

49+

suppressedSinceLastLog: 9,

50+

});

51+

});

52+
3453

it("resets counters", () => {

3554

const guard = new UnauthorizedFloodGuard({ closeAfter: 10, logEvery: 50 });

3655

guard.registerUnauthorized();

Original file line numberDiff line numberDiff line change

@@ -1,4 +1,5 @@

11

import { ErrorCodes, type ErrorShape } from "../../../../packages/gateway-protocol/src/index.js";

2+

import { resolveIntegerOption } from "../../../shared/number-coercion.js";

23
34

export type UnauthorizedFloodGuardOptions = {

45

closeAfter?: number;

@@ -22,8 +23,8 @@ export class UnauthorizedFloodGuard {

2223

private suppressedSinceLastLog = 0;

2324
2425

constructor(options?: UnauthorizedFloodGuardOptions) {

25-

this.closeAfter = Math.max(1, Math.floor(options?.closeAfter ?? DEFAULT_CLOSE_AFTER));

26-

this.logEvery = Math.max(1, Math.floor(options?.logEvery ?? DEFAULT_LOG_EVERY));

26+

this.closeAfter = resolveIntegerOption(options?.closeAfter, DEFAULT_CLOSE_AFTER, { min: 1 });

27+

this.logEvery = resolveIntegerOption(options?.logEvery, DEFAULT_LOG_EVERY, { min: 1 });

2728

}

2829
2930

registerUnauthorized(): UnauthorizedFloodDecision {