Extended Validation in Schemas

Aperta
#209 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
java

Direzione di ricerca

Inizia esaminando i vincoli standard di protovalidate collegati, PGV e l’ambito di PBJ parser e code-generator descritto nell’issue. Determina quali regole di validazione e quale approccio alla compatibilità siano appropriati, quindi definisci come debbano essere coperte le verifiche al momento del parsing e la documentazione delle regole. Il lavoro sarà considerato completato quando il progetto avrà un design di validazione concordato e performante, con constraints e test documentati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Java
Stelle
44
Fork
16
Merge medio
1g 3h
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hashgraph/pbj

Tutte le issue di hashgraph/pbj

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.