protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Prototype of customizable recursion and size limits for message parsing

Open jskeet opened this issue 1 year ago • 4 comments

cc @JamesNK @EronWright

Obviously this has no tests, but it's an alternative to #17881.

I don't know how the gRPC generator would be configured to change the parser settings, but the result could be a change from:

[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
static readonly grpc::Marshaller<global::Google.Cloud.Functions.V2.GetFunctionRequest> 
    __Marshaller_google_cloud_functions_v2_GetFunctionRequest =
    grpc::Marshallers.Create(__Helper_SerializeMessage, context =>
        __Helper_DeserializeMessage(context, global::Google.Cloud.Functions.V2.GetFunctionRequest.Parser));

to

[global::System.CodeDom.Compiler.GeneratedCode("grpc_csharp_plugin", null)]
static readonly grpc::Marshaller<global::Google.Cloud.Functions.V2.GetFunctionRequest> 
    __Marshaller_google_cloud_functions_v2_GetFunctionRequest =
    grpc::Marshallers.Create(__Helper_SerializeMessage, context =>
        __Helper_DeserializeMessage(context, global::Google.Cloud.Functions.V2.GetFunctionRequest.Parser
            .WithRecursionLimit(500)));

Causes for concern (beyond the current lack of tests):

  • Additional complexity in MessageExtensions and CodedInputStream
  • Potential performance regression due to dereferencing Settings frequently
  • Having an "immutable" Settings type referring to a mutable ExtensionRegistry is a code smell, but that's an existing issue.

jskeet avatar Aug 22 '24 11:08 jskeet

Any update on this, @jskeet ?

JasonLunn avatar Oct 07 '24 16:10 JasonLunn

@JasonLunn: I haven't had any feedback, and don't have the time to chase at the moment I'm afraid.

jskeet avatar Oct 07 '24 16:10 jskeet

This looks reasonable to me, although tests would be nice

mkruskal-google avatar Oct 07 '24 16:10 mkruskal-google

@mkruskal-google: I'll definitely add tests before we merge :) I'd like feedback on the API surface from potential consumers such as @JamesNK before writing those tests though.

jskeet avatar Oct 07 '24 16:10 jskeet

We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment.

This PR is labeled inactive because the last activity was over 90 days ago. This PR will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Jan 10 '25 10:01 github-actions[bot]

We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active or becomes active again, please reopen it.

This PR was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

github-actions[bot] avatar Jan 25 '25 10:01 github-actions[bot]