Repository navigation
test(update-check-proxy): 假服务器对非目标请求回 404,避免端口扫描器致偶发失败 - #2885
Merged
deepcoldy merged 1 commit intoNov 6, 2026
Merged
Conversation
假代理/假 registry 的 request listener 会把任意请求记进断言列表, listener 里还同步 expect(req.headers.accept),宿主机扫描器打来 GET / 时 变成未捕获异常或多出一条记录。非目标路径改回 404 不入记录, 非目标 POST 记入 strayRequests,afterEach 清理后断言为空。 Closes deepcoldy#2878 Co-Authored-By: Claude Opus 5.5 <[email protected]>
swtxbling
requested review from
47seek,
LucasIcarus,
deepcoldy,
xiaoxueSunn and
xiongz-c
as code owners
November 5, 2026 19:53
Owner
|
已合并,感谢修复! 评审过程中额外验证了两个边界行为,都不阻塞本 PR,记录在这里供后续参考:
本地用注入式探针(扫描器形态的 |
This was referenced Nov 6, 2026
|
🚀 Released in v3.58.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改了什么
test/update-check-proxy.test.ts里的假服务器(假代理、假 registry)对非目标路径一律回 404,不进入断言用的请求记录;非目标的 POST 记入strayRequests,afterEach清理完资源后断言为空。做法参考 #2867。为什么
宿主机端口扫描器向假服务器打来
GET /时:listener 里同步的expect(req.headers.accept)抛出变成未捕获异常;其他用例则多记一条/,toEqual失败,env 模式还会httpRequest('/')抛Invalid URL。测试因此偶发失败。影响面
只改一个测试文件,不涉及 src、CLI、会话类型。四个用例原有的精确
toEqual请求列表未改动。验证
listen()返回前对每个假服务器加一次fetch(base + '/')探针,master 版测试变红(多个用例失败 + Unhandled ErrorsInvalid URL)。npx vitest run --project unit test/update-check-proxy.test.ts连跑 2 次 25/25 通过。npx tsc --noEmit -p tsconfig.json无报错。审查
独立审查提出 5 条加若干 nit:采纳 afterEach 中断言挪到清理之后、strayRequests 只记 POST(不让 HEAD/OPTIONS 探测再造成失败)、
isProxyForm改名isAbsoluteHttpUrl;驳回白名单口径诊断变弱(与 #2867 一致,目标请求精确列表仍在断言)以及 stalled/CONNECT 两个服务器加过滤(实测不失败,本 PR 不扩范围)。Closes #2878
🤖 Generated with Claude Code