Extended Validation in Schemas

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

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
java

調査の方向性

まず、issue に記載されているリンク先の protovalidate 標準制約、PGV、および PBJ parser と code-generator のスコープを確認します。どのバリデーションルールと互換性アプローチが適切かを判断し、そのうえで parse-time のチェックとルールのドキュメントをどのようにカバーするかを定義します。プロジェクトに、文書化された制約とテストを備えた、合意済みで高性能なバリデーション設計があれば完了です。

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

説明

Problem

We would like the ability to provide extended validation rules for fields in the schema and then validate them at parse time in PBJ. The primary reason for this is security to limit the effects of badly written binary protobuf to cause the reader to spend more resources than absolutely necessary. The secondary reason is improved rigor in schemas so they are more precise and there is less scope for mistakes. The rules covered should include:

  • Min/Max sizes for Strings, Bytes and Sub-Message fields
  • Min/Max for repeated fields
  • Number ranges for numeric types, accepted options.
  • Max recursive message depth
  • Message max size in bytes

The rules we choose should be very fast to check at parse time and not have a noticeable performance impact on parsing.

There is also the aim that this can be used for tightening the specification documentation for protobuf APIs. So ideally rules documentation will be supported for explaining these rules and what they exist etc.

Solution

We could define our own or choose to be compatible with an existing option. For example "protovalidate" library from Buf.
https://github.com/bufbuild/protovalidate
The full options are way too much with full Google Common Expression Language support but maybe the Standard Constraints subset is applicable.
https://github.com/bufbuild/protovalidate/blob/main/docs/standard-constraints.md

There is also an older version called "protoc-gen-validate (PGV)" https://github.com/bufbuild/protoc-gen-validate that seems more widely used and might be a better fit.

History blog on V1 and V2 https://buf.build/blog/protoc-gen-validate-v1-and-v2

Alternatives

No response

主要言語
Java
スター
44
フォーク
16
平均マージ
1日 3時間
マージ済み PR(30日)
18

環境構築

はじめの一歩

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

hashgraph/pbj のほかの issue

hashgraph/pbj の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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