gaborgsomogyi commented on a change in pull request #24627: [SPARK-27748][SS] Kafka consumer/producer password/token redaction. URL: https://github.com/apache/spark/pull/24627#discussion_r289299222
########## File path: external/kafka-0-10-token-provider/src/main/scala/org/apache/spark/kafka010/KafkaRedactionUtil.scala ########## @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.kafka010 + +import org.apache.kafka.common.config.SaslConfigs + +import org.apache.spark.SparkEnv +import org.apache.spark.internal.Logging +import org.apache.spark.internal.config.SECRET_REDACTION_PATTERN +import org.apache.spark.util.Utils.{redact, REDACTION_REPLACEMENT_TEXT} + +private[spark] object KafkaRedactionUtil extends Logging { + private[spark] def redactParams(params: Seq[(String, Object)]): Seq[(String, Object)] = { + val redactionPattern = Some(SparkEnv.get.conf.get(SECRET_REDACTION_PATTERN)) + params.map { case (key, value) => + if (key.equalsIgnoreCase(SaslConfigs.SASL_JAAS_CONFIG)) { + (key, redactJaasParam(value.asInstanceOf[String])) + } else { + value match { + case s: String => + val (_, newValue) = redact(redactionPattern, Seq((key, s))).head + (key, newValue) + + case _ => + (key, value) Review comment: Considering your argument you're right, redacting all other types would be the flawless way. Redacting other data types, for example `int` I see mainly 2 ways: * Change the data type to `String` and set the known value `*********(redacted)`. I think it's kind of weird that all of a sudden the parameter type changes. Yeah, in this case would work but still weird. * Implement the default redacted value for each type. This would increase the complexity and the value is questionable because in case of `int` the user can't really tell 0 is the normal or redacted value. This solution could trick sysadmin/devs by showing invalid values. Considering the mentioned possibilities + the fact that until now I haven't seen the need for this feature I'm not fully convinced that this has to be added. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
