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

オープン
#3,055 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
mysql, postgresql, rust, sqlite
領域
api, backend, databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
Rust
スター
532
フォーク
56
平均マージ
11時間 20分
マージ済み PR(30日)
282

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

torrust/torrust-tracker のほかの issue

torrust/torrust-tracker の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。