-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: validate proto messages before converting them to anypb.Any #4499
Conversation
5403023
to
87ab699
Compare
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
87ab699
to
942de59
Compare
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
9e01d42
to
9156ad7
Compare
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
@@ -13,7 +13,8 @@ accesslog: | |||
protocol: "%PROTOCOL%" | |||
response_code: "%RESPONSE_CODE%" | |||
als: | |||
- destination: | |||
- name: als |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--- FAIL: TestTranslateXds (0.00s)
--- FAIL: TestTranslateXds/accesslog (0.00s)
translator_test.go:142: accesslog
translator_test.go:143:
Error Trace: /home/ubuntu/gateway/internal/xds/translator/translator_test.go:143
Error: Received unexpected error:
invalid HttpGrpcAccessLogConfig.CommonConfig: embedded message failed validation | caused by: invalid CommonGrpcAccessLogConfig.LogName: value length must be at least 1 runes
Test: TestTranslateXds/accesslog
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
@@ -11,7 +11,8 @@ accesslog: | |||
protocol: "%PROTOCOL%" | |||
response_code: "%RESPONSE_CODE%" | |||
als: | |||
- destination: | |||
- name: als |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go test -timeout 30s github.com/envoyproxy/gateway/internal/xds/translator --override-testdata=true
--- FAIL: TestTranslateXds (0.42s)
--- FAIL: TestTranslateXds/accesslog-without-format (0.00s)
translator_test.go:142: accesslog-without-format
translator_test.go:143:
Error Trace: /home/ubuntu/gateway/internal/xds/translator/translator_test.go:143
Error: Received unexpected error:
invalid HttpGrpcAccessLogConfig.CommonConfig: embedded message failed validation | caused by: invalid CommonGrpcAccessLogConfig.LogName: value length must be at least 1 runes
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
@@ -44,7 +44,7 @@ http: | |||
isIPv6: false | |||
maskLen: 24 | |||
jwt: | |||
issuer: https://one.example.com | |||
provider: https://one.example.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--- FAIL: TestTranslateXds (0.00s)
--- FAIL: TestTranslateXds/authorization-multiple-principals (0.00s)
translator_test.go:142: authorization-multiple-principals
translator_test.go:143:
Error Trace: /home/ubuntu/gateway/internal/xds/translator/translator_test.go:143
Error: Received unexpected error:
invalid DynamicMetadataInput.Path[0]: embedded message failed validation | caused by: invalid DynamicMetadataInput_PathSegment.Key: value length must be at least 1 runes
Test: TestTranslateXds/authorization-multiple-principals
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4499 +/- ##
==========================================
- Coverage 65.60% 65.54% -0.07%
==========================================
Files 210 210
Lines 31612 31649 +37
==========================================
+ Hits 20739 20744 +5
- Misses 9670 9690 +20
- Partials 1203 1215 +12 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
func ToAny(msg proto.Message) *anypb.Any { | ||
res, err := ToAnyWithValidation(msg) | ||
if err != nil { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation error should not be ignored.
Leave the ToAny
function for now as the impact are a bit large and we're approaching the rc1. I will raise a follow-up PR to clean up all the refrences to it after v1.2.0 release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For cases like the following, 'ToAny' still makes sense, but you really should use ToAnyWithValidation in most cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we change the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer removing this function at all, but let's discuss and decide in a follow-up PR. Tracked in #4554
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
hey @zhaohuabing can you rebase ? |
0e272b1
to
51a5502
Compare
this's worth to backport if possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for fixing it across the board
…oyproxy#4499) * validate proto message before converting to any Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> (cherry picked from commit 05817fc) Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
…oyproxy#4499) * validate proto message before converting to any Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> (cherry picked from commit 05817fc) Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
…oyproxy#4499) * validate proto message before converting to any Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> (cherry picked from commit 05817fc) Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
The
validate
andvalidateAll
method of a proto message don't validate a member field ofanypb.Any
type as it doesn't have avalidate
method itself. Therefore, all proto messages must be validated before been converting toanypb.Any
.Fix #4504
Release note: No