Skip to content

feat(ops): 同步代理农场 ASN 至 Vercel WAF#99

Draft
AsperforMias wants to merge 2 commits into
hikariming:mainfrom
AsperforMias:fix/waf-asn-denylist
Draft

feat(ops): 同步代理农场 ASN 至 Vercel WAF#99
AsperforMias wants to merge 2 commits into
hikariming:mainfrom
AsperforMias:fix/waf-asn-denylist

Conversation

@AsperforMias

Copy link
Copy Markdown
Collaborator

改动

  • 将已用于流量归因的高置信代理农场 ASN 收敛到 config/proxy-farm-asns.json,作为报表与 WAF 的唯一来源。
  • 新增 pnpm waf:sync:默认 dry-run;显式 --apply 时先读取 Vercel Firewall,再以 geo_as_number + deny 创建规则。
  • 已存在同名规则且内容一致时无操作;内容不一致时返回 drift 并停止,避免脚本覆盖其他线上 WAF 配置。
  • 明确排除 AWS 等通用云、消费级 VPN/加速器、居民网络,避免把可能的真人流量纳入农场封禁。
  • 更新中英文部署说明和 .env.example,声明 Vercel token 仅用于运维终端,不能写入线上运行时环境。

验证

  • 本地 HTTP mock 控制面 E2E:验证 GET 当前 Firewall、PATCH 精确规则、幂等重复执行与 drift fail-closed。
  • pnpm typecheck 通过。
  • pnpm build 通过。
  • 定向 ESLint、bash -n scripts/traffic-report.sh、JSON 校验、dry-run 和无凭据 --apply fail-closed 均通过。
  • 全仓 pnpm lint 仍被上游已有脚本的显式 any 与未使用导入阻断,和本 PR 无关。

@AsperforMias
AsperforMias requested a review from hikariming as a code owner July 17, 2026 13:37
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

@AsperforMias is attempting to deploy a commit to the hikariming's projects Team on Vercel.

A member of the Team first needs to authorize it.

@hikariming

hikariming commented Jul 18, 2026

Copy link
Copy Markdown
Owner

1. ASN 清单基于旧版 main,8 个新农场段缺失

main 昨天刚在 scripts/traffic-report.sh 增补 8 个农场 ASN(cae9c64):30058 FDCservers、398781 Oculus、153371 Back Waves、51847 Nearoute、25820 IT7、199524 G-Core、45102 Alibaba US、396982 GCP。本 PR 的 config/proxy-farm-asns.json 只有 20 个,按现状合并会让报表农场层静默丢掉这 8 段——恰好违背了"单一事实源、防止口径漂移"的立项理由,而且数据搬进 JSON 后更隐蔽。

2. 单一清单在结构上表达不了"算农场但不该硬 deny"的 ASN

JSON 声明排除通用云厂商,但 45102(Alibaba US)/ 396982(GCP)在运营口径里是"报表计入农场层、challenge 可过、不该 WAF 硬 deny"。一份共享清单无法表达这个二分:加进去 → waf:sync 会对 GCP/Alibaba 硬 deny,有误杀真人的风险;不加 → 报表口径回退。建议 schema 拆成 denyAsns(WAF)+ reportOnlyAsns(仅报表),traffic-report.sh 侧用 jq -c '.denyAsns + .reportOnlyAsns'

其他 rebase 时注意:

  • 会与 cae9c64traffic-report.sh 头部冲突(交叉表重写部分不受影响),请保留 2026-07-17 的归因注释;
  • 建议 JSON 加 per-ASN notes 字段——现在归因知识(哪家农场、哪波暴露的)写在 shell 注释里,数据搬进 JSON 后就没地方写了;
  • Vercel condition value 上限 75 条,值得在 JSON description 里记一笔;
  • pnpm typecheck 实际不覆盖 scripts/ 入口(tsconfig exclude),"typecheck 已通过"对入口脚本不成立。

修改方向:rebase 到 main、补齐 8 个 ASN、拆分 deny/report-only schema。脚本本体改动不大

@hikariming hikariming closed this Jul 18, 2026
@AsperforMias AsperforMias reopened this Jul 18, 2026
@AsperforMias

Copy link
Copy Markdown
Collaborator Author

暂时重复waf,后续会改为网关完善,网关建设是核心功能链路之一

@AsperforMias
AsperforMias marked this pull request as draft July 18, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants