-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Allow for kafka emitter producer secrets to be masked in logs #15485
Allow for kafka emitter producer secrets to be masked in logs #15485
Conversation
… of being visible This change will allow for kafka producer config values that should be secrets to not show up in the logs. This will enhance the security of the people who use the kafka emitter to use this if they want to. This is opt in and will not affect prior configs for this emitter
@@ -83,7 +87,8 @@ public KafkaEmitterConfig( | |||
@Nullable @JsonProperty("request.topic") String requestTopic, | |||
@Nullable @JsonProperty("segmentMetadata.topic") String segmentMetadataTopic, | |||
@JsonProperty("clusterName") String clusterName, | |||
@JsonProperty("producer.config") @Nullable Map<String, String> kafkaProducerConfig | |||
@JsonProperty("producer.config") @Nullable Map<String, String> kafkaProducerConfig, | |||
@JsonProperty("producer.secrets.config") @Nullable DynamicConfigProvider<String> kafkaProducerSecrets |
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.
property name could use some work imo
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.
Related configs that currently exist are druid.startup.logging.maskProperties
and druid.server.hiddenProperties
. Maybe something like producer.hiddenProperties
?
Thanks, @TSFenwick! Masking sensitive values makes sense to me. I think we can mask the sensitive keys/values directly in
This would more generally help mask any sensitive properties in the config. What do you think? |
I like this idea, but i think it becomes more complicated when needing to consider generic things, like how far down a map should we go. Also the less handwritten parsing code i write the better for everyone :) The other question is defining the values to be masked in core druid code isn't probably the best. Using the dynamic config provider means it can mask any and all values stored in the configProvider's map. I think the solution i have implemented in this PR suffices enough and moves the needle forward in protecting secrets. Also this change follows the practices Druid uses elsewhere to secure maps of values like in the Kafka consumer https://github.com/apache/druid/blob/master/extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/KafkaRecordSupplier.java#L263 That being said it would be an improvement to mask the only the values of the map instead of the entire map so its easier to debug if you missed an entire thing |
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.
This approach is reasonable. I left a couple of tangential ideas as suggestions to plumb in credentials that we can explore separately. In the mean time, let's keep the added property undocumented. Thanks, @TSFenwick!
This change will allow for kafka producer config values that should be secrets to not show up in the logs. This will enhance the security of the people who use the kafka emitter to use this if they want to. This is opt in and will not affect prior configs for this emitter
Fixes an issue where kafka producer configs that would be used for securing the producer to the kafka topic would be logged in plaintext.
Description
add a new config option to the kafka emitter config that will leverage DynamicConfigProvider.java to mask a map of configs for the kafka producer.
If there are duplicate keys in the secrets config and the not masked config the secrets config value will be the one used.
for example the
runtime.properties
for the the config can look like this when leveraging the MapStringDynamicConfigProvider.javaalso made minor change to DynamicConfigProviderUtils to use putAll instead of iterating and putting in that class.
how the properties now look in the logs
3 test cases:
Tested this with valid config and secret value so it's masked. Worked fine
Tested this with the secrets left in the normal producer config and no line for the secrets config. Worked fine
Tested this with the secrets left in the normal producer config and the mapString was empty. Worked fine.
Release note
Key changed/added classes in this PR
KafkaEmitterConfig
KafkaEmitter
This PR has: