[BUG] `string.well_known_regex` cannot handle binary HTTP header values
まだ誰も着手していません。
評価
調査の方向性
まず、string.well_known_regex ルールの実装と bytes 検証の定義を見つけます。バイナリの HTTP ヘッダー値を対象とするリグレッションテストを追加し、有効な UTF-8 を必要とせずにルールで bytes を検証できることを確認します。HTTP ヘッダー仕様に従って報告されたケースが受け入れまたは拒否され、既存のテストに合格すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description
well_known_regex is on a string type. string must be a valid UTF-8 encoded Unicode code point sequence. But HTTP header values don't have to be. I.e. valid HTTP header values cannot be represented as a proto string. Yet the validation rule is on the string type.
Steps to Reproduce
message HeaderValues {
string val = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_VALUE];
}
func TestAbc(t *testing.T) {
val := []byte("\xff")
valid := utf8.Valid(val)
assert.True(t, valid, "Invalid UTF-8")
msg := &HeaderValues{
Val: "\xff",
}
_, err := proto.Marshal(msg)
assert.NoError(t, err, "proto.Marshal() failed")
v, err := protovalidate.New()
require.NoError(t, err)
err = v.Validate(msg)
assert.NoError(t, err)
}
Prints:
=== RUN TestAbc
prototool_test.go:16:
Error Trace: file_test.go:16
Error: Should be true
Test: TestAbc
Messages: Invalid UTF-8
prototool_test.go:27:
Error Trace: file_test.go:27
Error: Received unexpected error:
string field contains invalid UTF-8
Test: TestAbc
Messages: proto.Marshal() failed
--- FAIL: TestAbc (0.02s)
FAIL
Process finished with the exit code 1
Expected Behavior
Validation rule should be on bytes. At least there too, not just on string.
Actual Behavior
Validation rule on string that is problematic.
Possible Solution
Additional Context
HTTP header value spec: https://datatracker.ietf.org/doc/html/rfc9110#name-field-values
- 主要言語
- Go
- スター
- 1.6k
- フォーク
- 68
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bufbuild/protovalidate のほかの issue
-
Feature
難易度 2/5 1〜3時間 初心者へのやさしさ 50/100
bufbuild/protovalidate#538 ·
-
[BUG] Hostname rule rejects a 253-character name with a trailing dot, which the docs say is validオープン
難易度 4/5 3〜5日 初心者へのやさしさ 58/100
bufbuild/protovalidate#512 · コメント 2 件 ·
-
Feature
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
bufbuild/protovalidate#490 · コメント 1 件 ·
-
Feature
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
bufbuild/protovalidate#486 · コメント 11 件 ·
-
Feature
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
bufbuild/protovalidate#485 ·
bufbuild/protovalidate の issue をすべて見る
似ている issue
-
agent-review-finding chore
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
jordansmall/spindrift#5748 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
Resource links written as host:port without a scheme are broken対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
Proxy ignores l5d-retry-http and l5d-retry-grpc conditions that follow a comma and space対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 3 日以内に返信
-
needs_triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信