Key duration above i64::MAX seconds returns 500 instead of a duration error

Abierto
#3,055 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
42/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
mysql, postgresql, rust, sqlite

Línea de trabajo

Read the key creation and duration validation flow for POST /api/v1/keys and the generate-key endpoint, then trace add_key_to_keys in the SQLite, PostgreSQL, and MySQL stores. Compare the clock validation with each store’s expiry conversion and review the #3051 spec PR context. Done means the chosen limit or error mapping returns a duration error for the reported overflow cases, including pre-generated keys.

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

Descripción

Problem

An admin who sends a seconds_valid that makes the key's expiry (now plus the duration) exceed i64::MAX seconds while still fitting the clock (for example 9223372036854775808, 2^63; durations just below i64::MAX fail the same way, because the stores convert the expiry, not the duration) to POST /api/v1/keys or the generate-key endpoint gets 500 failed to add key instead of the 400 "invalid auth key duration" returned for values that overflow the clock. The clock check passes, then add_key_to_keys in the SQLite, PostgreSQL and MySQL stores converts the expiry with i64::try_from(value.as_secs()) and fails with Error::MalformedDatabaseRecord, which becomes PeerKeyError::DatabaseError and then AuthKeyError::Database. The pre-generated-key branch behaves the same way.

No panic is involved. This is a different root cause from #3051 (a persistence range limit, not the clock): the maximum expiry a key can have is decided by the database column type, but the request is validated only against the clock.

Open design question

Where the limit lives: bound the duration check by the largest expiry the stores accept (a shared constant), or map MalformedDatabaseRecord on insert to a duration error. To be decided in the spec.

Found by the automated review of the #3051 spec PR (torrust/torrust-tracker#3054).

Lenguaje dominante
Rust
Estrellas
532
Forks
56
Merge medio
11 h 20 min
PR fusionados (30 d)
282

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 torrust/torrust-tracker

Todos los issues de torrust/torrust-tracker

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.