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

Offen
#485 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
node.js, typescript

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
TypeScript
Sterne
7
Forks
2
Ø Merge
1 T. 17 Std.
Gemergte PRs (30 T.)
17

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus NanoForge-dev/Engine

Alle Issues in NanoForge-dev/Engine

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.