Skip to content

Commit e5c858b

Browse files
github-actions[bot]copilot-pull-request-reviewer[bot]
andcommitted
fix(proxy): 删 BOT_PATH 里的 dot-path 死规则(Copilot CR PR#346)
Copilot 指出 matcher `.*\\..*` 排除所有含 `.` 的路径,所以 BOT_PATH_PATTERNS 里 .php / .env / .git/ / .(war|jar|sql|bak|key|pem|pfx) 等正则**从来不会被 执行**,是死代码。 实际行为没问题——这些 dot-path scanner 直接走到 Next 默认 404 → 命中 ○ Static /_not-found,由 CDN-served,不烧 Fluid。但写在 regex 列表里给人 "已在 edge 早返"的错觉。 删 5 条死规则,留下 4 条无 dot 真正生效的:wp-* / graphql / werkzeug / phpmyadmin。注释里写明 dot-path 不要再加(已被 static 404 兜底)。 Co-authored-by: copilot-pull-request-reviewer[bot] <copilot-pull-request-reviewer[bot]@users.noreply.github.com>
1 parent c634821 commit e5c858b

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

proxy.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,22 @@ const LEETCODE_OLD_PATH_TAIL = "/docs/CommunityShare/Leetcode";
3030
const intlMiddleware = createMiddleware(routing);
3131

3232
// Bot / vulnerability scanner path patterns —— 在 edge 早返 404,不让进 Fluid。
33-
// 维护约束:只能放 100% 业务用不到的指纹(不要加 admin / login,业务有真路由)。
34-
// 参考 OWASP top-10 + nikto / dirbuster 常见探测字串。
33+
// 维护约束:
34+
// 1. 只放 100% 业务用不到的指纹(不要加 admin / login,业务有真路由)
35+
// 2. **不要放含 `.` 的路径**:下面 matcher 用 `.*\\..*` 排除所有 dot-path,
36+
// middleware 根本不会被调起。带点的 scanner(.env / .php / .git/ / .war
37+
// 等)会直接走到 Next 默认 404 → 命中我们的 ○ Static `/_not-found`,
38+
// 已经是 CDN-served,不烧 Fluid。重复在这里写 dot-path 是死代码。
3539
const BOT_PATH_PATTERNS = [
36-
// PHP / 老 CMS:本站根本没装 PHP,所有 *.php 都是扫描
37-
/\.php(?:$|[?#/])/i,
3840
// wp-* 系列:WordPress 扫描
3941
/\/wp-(admin|content|includes|login|json|config)(?:$|[/?#])/i,
40-
// .env / config 文件直接探测
41-
/\.env(?:\.[a-z]+)?(?:$|[?#/])/i,
42-
/\/(config|settings|secrets|credentials)\.(yml|yaml|json|ini|toml|xml)(?:$|[?#])/i,
4342
// GraphQL / GQL endpoint 扫描(本站没 GraphQL)
4443
/\/(graphql|gql|api\/graphql|v\d+\/graphql)(?:$|[/?#])/i,
4544
// Werkzeug / Flask debug console
4645
/\/werkzeug\/console/i,
4746
// 常见 admin / debug panels 探测路径(本站 admin 在 /[locale]/admin,
4847
// 这些是其他平台特有路径,扫到必是 bot)
4948
/\/(phpmyadmin|adminer|pma|dbadmin|mysqladmin)(?:$|[/?#])/i,
50-
// git / svn 仓库文件暴露探测
51-
/\/\.(git|svn|hg|bzr)\/(?:config|HEAD|entries)/i,
52-
// 已知敏感文件(war/jar/key/pem)扫描
53-
/\.(war|jar|sql|bak|key|pem|pfx)$/i,
5449
];
5550

5651
function isBotScanPath(pathname: string): boolean {

0 commit comments

Comments
 (0)