fix(network): typed packets reach server listeners unvalidated by default

未关闭
#485 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃

调研方向

Read modules/network/src/shared/packet.ts around lines 261-263 and the guidance in modules/network/README.md around line 221; trace how server listeners register packet definitions and how received values are validated. Decide how missing validation should be handled on the server, then update the relevant documentation. Done means unvalidated server packets cannot reach listeners silently and the docs explain the rule.

由索引模型根据 Issue 内容生成。

描述

bug modules:network
Which package is this bug report for?

network

Issue description

The repo rule is to validate peer messages on the server side, but validate is optional: without it, the raw JSON.parse result from a peer is passed to packets.on(Def, …) typed as T, for example { key: { toString: 1 } } for a "up" | "down" field. The docs only recommend validate (README.md:221, docs/docs/network/network-peer.mdx:111).

Where:

Evidence:

const validate = this._definitions.get(received.name)?.validate;
received.valid = !validate || validate(received.value);

Suggested fix: On the server, warn once (or throw) when a packet with no validate is registered, or require validate in the server-side signature. Document it.

Found during a code audit of main at be72076.

Code sample

No response

Versions
  • Engine main at be72076
  • pnpm 12.0.0, Node.js 26, Bun 1.3.14
Issue priority

High (immediate attention needed)

I have tested this issue on a development release

be72076

主要语言
TypeScript
星标
7
派生
2
平均合并
1 天 17 小时
30 天内合并 PR
17

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NanoForge-dev/Engine 的其他 Issue

查看 NanoForge-dev/Engine 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。