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

Abierto
#485 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
node.js, typescript

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
TypeScript
Estrellas
7
Forks
2
Merge medio
1 d 17 h
PR fusionados (30 d)
17

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de NanoForge-dev/Engine

Todos los issues de NanoForge-dev/Engine

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.