Granting a permission to a user id with no account answers 500 instead of 404

オープン 初心者向け
#1,002 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
2/5
見積もり時間
半日
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api, backend

調査の方向性

RBAC の付与ルート POST /api/v1/rbac/users/{user_id}/grant のハンドラーと、すでに 404 を返す兄弟の permissions ルートで使用されているユーザー検索から始めます。存在しない UUID がデータベースエラーではなく 404 を返すように、付与を挿入する前に不足している検索を追加します。また、本文の user_id を破棄するか、パスの ID と一致しない場合に拒否するかを決めます。ユーザー付与と permissions に関する RBAC API テストを実行し、新しい 404 と既存の付与が引き続き機能することを確認します。

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

説明

bug post-launch
  • Sent: POST /api/v1/rbac/users/{user_id}/grant with a valid body, where {user_id} is a well-formed UUID that
    belongs to no account.
  • Comes back: 500 with the generic error body. The grant is inserted without looking the user up, and the database
    refuses the row. Nothing is saved.
  • Expected: 404 "User not found", as GET /api/v1/rbac/users/{user_id}/permissions answers for the same id.
  • Also: the body's required user_id is not used (the path's id is); either drop it or refuse a body whose
    user_id differs from the path, as the counter routes do (#95).
  • Reproduction (ADMIN):
    curl -X POST -H "Authorization: Bearer <ADMIN token>" -H 'Content-Type: application/json' \
         -d '{"user_id":"00000000-0000-0000-0000-000000000001","resource":"experiment","actions":["read"]}' \
         http://localhost:8000/api/v1/rbac/users/00000000-0000-0000-0000-000000000001/grant
    

Found by API fuzzing (a local run), reproduced by hand.

主要言語
Python
スター
0
フォーク
4
平均マージ
5時間 19分
マージ済み PR(30日)
503

環境構築

はじめの一歩

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

Controlvar/controlvar のほかの issue

Controlvar/controlvar の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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