-
-
Notifications
You must be signed in to change notification settings - Fork 377
feat: 可选拦截 Anthropic Warmup 请求 #526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ALTER TABLE "system_settings" | ||
| ADD COLUMN IF NOT EXISTS "enable_anthropic_warmup_intercept" boolean NOT NULL DEFAULT false; | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import { ProxySensitiveWordGuard } from "./sensitive-word-guard"; | |
| import type { ProxySession } from "./session"; | ||
| import { ProxySessionGuard } from "./session-guard"; | ||
| import { ProxyVersionGuard } from "./version-guard"; | ||
| import { ProxyWarmupGuard } from "./warmup-guard"; | ||
|
|
||
| // Request type classification for pipeline presets | ||
| export enum RequestType { | ||
|
|
@@ -31,6 +32,7 @@ export type GuardStepKey = | |
| | "version" | ||
| | "probe" | ||
| | "session" | ||
| | "warmup" | ||
| | "requestFilter" | ||
| | "sensitive" | ||
| | "rateLimit" | ||
|
|
@@ -91,6 +93,12 @@ const Steps: Record<GuardStepKey, GuardStep> = { | |
| return null; | ||
| }, | ||
| }, | ||
| warmup: { | ||
| name: "warmup", | ||
| async execute(session) { | ||
| return ProxyWarmupGuard.ensure(session); | ||
| }, | ||
| }, | ||
| requestFilter: { | ||
| name: "requestFilter", | ||
| async execute(session) { | ||
|
|
@@ -170,6 +178,7 @@ export const CHAT_PIPELINE: GuardConfig = { | |
| "version", | ||
| "probe", | ||
| "session", | ||
| "warmup", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] [SECURITY-VULNERABILITY] Warmup intercept bypasses rate limiting on the chat pipeline Evidence ( steps: [
// ...
"session",
"warmup", // returns early before rate limiting
"requestFilter",
"sensitive",
"rateLimit",
// ...
]Why this is a problem: Suggested fix: // Keep `/v1/messages` requests rate-limited: run warmup after `rateLimit`
steps: [
// ...
"session",
"requestFilter",
"sensitive",
"rateLimit",
"warmup",
// ...
] |
||
| "requestFilter", | ||
| "sensitive", | ||
| "rateLimit", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: ding113/claude-code-hub
Length of output: 1314
🏁 Script executed:
Repository: ding113/claude-code-hub
Length of output: 1359
🏁 Script executed:
# Check if the file exists and get its structure wc -l src/actions/my-usage.tsRepository: ding113/claude-code-hub
Length of output: 94
🏁 Script executed:
Repository: ding113/claude-code-hub
Length of output: 2680
🏁 Script executed:
Repository: ding113/claude-code-hub
Length of output: 4394
🏁 Script executed:
Repository: ding113/claude-code-hub
Length of output: 88
添加
blockedBy列的索引以优化性能。过滤逻辑正确使用了
IS DISTINCT FROM操作符,能够正确排除blockedBy = 'warmup'的记录同时保留NULL值。但blockedBy列当前没有索引,在大数据量下会导致全表扫描。建议添加独立索引或将其包含在复合索引中,特别是对于频繁的统计查询。🤖 Prompt for AI Agents