[CALCITE-7773] Kafka adapter should validate class-naming keys in the "consumer.params" operand - #5256
Open
rubenada wants to merge 1 commit into
Open
[CALCITE-7773] Kafka adapter should validate class-naming keys in the "consumer.params" operand#5256rubenada wants to merge 1 commit into
rubenada wants to merge 1 commit into
Conversation
… "consumer.params" operand
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Jira Link
CALCITE-7773
Changes Proposed
The Kafka adapter's
consumer.paramsmodel operand is forwarded verbatim toKafkaConsumerinKafkaTableFactory.create(...)(currently viaKafkaTableOptions.setConsumerParams(...), thenProperties.putAll(...)inKafkaStreamTable). Several Kafka consumer configuration keys cause the client to load and instantiate classes named in the operand as part ofnew KafkaConsumer<>(config): keys inside it are forwarded without any check, which means a model with, for example,consumer.params.value.deserializer=some.unrelated.Classruns the static initializer ofsome.unrelated.Classinside the Kafka client before any validation.Proposal:
Add validation in
KafkaTableFactory.create(...)(fail-fast at table creation):key.deserializer/value.deserializerare accepted only afterClass.forName(name, false, loader)andDeserializer.class.isAssignableFrom(klass)(the class is not initialized during the check).SecurityExceptionnaming the offending key and pointing at the system property that can be used to revert to the legacy behavior (see below).group.id,max.poll.records,fetch.min.bytes, timeouts,security.protocol=PLAINTEXT, etc.) are forwarded unchanged.Add a new system property
calcite.kafka.consumer.params.trusted, registered asCalciteSystemProperty.KAFKA_CONSUMER_PARAMS_TRUSTED, defaultfalse. Setting it totruerestores the previous forwarding behavior for deployments where the model is entirely operator-supplied (i.e. trusted).