github-actions[bot] commented on code in PR #69462: URL: https://github.com/apache/doris/pull/69462#discussion_r4356179972
########## fe/fe-core/src/main/java/org/apache/doris/load/routineload/kafka/KafkaPropertiesUtil.java: ########## @@ -0,0 +1,70 @@ +// 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.doris.load.routineload.kafka; + +import org.apache.doris.common.util.DatasourcePrintableMap; + +import org.apache.commons.collections4.MapUtils; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** Shared masking for Kafka configuration displays, modification logs and audit SQL. */ +public final class KafkaPropertiesUtil { + public static final String SENSITIVE_PROPERTY_MASK = "******"; + + private KafkaPropertiesUtil() { + } + + public static Map<String, String> maskProperties(Map<String, String> properties) { + Map<String, String> maskedProperties = new HashMap<>(); + MapUtils.emptyIfNull(properties).forEach((key, value) -> maskedProperties.put(key, + isSensitiveKey(key) ? SENSITIVE_PROPERTY_MASK : value)); + return maskedProperties; + } + + public static boolean isSensitiveKey(String key) { + String lowerKey = key.toLowerCase(Locale.ROOT); Review Comment: [P2] Classify Kafka credential keys at their native NUL boundary In default SQL mode, `ALTER ROUTINE LOAD FOR db.job FROM KAFKA ('property.sasl.password\0ignored'='synthetic-secret')` decodes the key to an interior NUL and passes the prefix-only Kafka property validation. This classifier sees `sasl.password<NUL>ignored`, matches no sensitive rule, and leaves the credential visible in both the new audit SQL and modification/replay INFO log. The unmodified key reaches BE `KafkaDataConsumer::init`; the pinned [librdkafka v2.16.0 setter](https://github.com/confluentinc/librdkafka/blob/v2.16.0/src-cpp/ConfImpl.cpp#L34-L44) passes `name.c_str()` to its C API, so the effective property is `sasl.password`, not an unsupported key. Classify that effective name, or conservatively mask NUL-containing keys, and cover this alias in audit and INFO-log tests. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
