Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](fe) Mask Kafka routine load sensitive properties#64786
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
2fb017fac1f26b42ff2631ead4ed4bd30cbecf8e30043faf927a837fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -33,6 +33,7 @@ | ||
| import org.apache.doris.common.LoadException; | ||
| import org.apache.doris.common.Pair; | ||
| import org.apache.doris.common.UserException; | ||
| import org.apache.doris.common.util.DatasourcePrintableMap; | ||
| import org.apache.doris.common.util.DebugPointUtil; | ||
| import org.apache.doris.common.util.DebugUtil; | ||
| import org.apache.doris.common.util.LogBuilder; | ||
| @@ -82,6 +83,7 @@ | ||
| import java.util.HashMap; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
| import java.util.TimeZone; | ||
| import java.util.UUID; | ||
| @@ -102,6 +104,7 @@ public class KafkaRoutineLoadJob extends RoutineLoadJob { | ||
| private static final String READ_COMMITTED_ZERO_ROWS_WITH_LAG_MESSAGE = "Kafka routine load consumed 0 rows " | ||
| + "while lag is still positive under isolation.level=read_committed. If the upstream producer uses " | ||
| + "Kafka transactions, some records may be in uncommitted transactions and are not visible yet."; | ||
| private static final String SENSITIVE_PROPERTY_MASK = "******"; | ||
| @SerializedName("bl") | ||
| private String brokerList; | ||
| @@ -723,7 +726,31 @@ public String dataSourcePropertiesJsonToString() { | ||
| @Override | ||
| public String customPropertiesJsonToString() { | ||
| Gson gson = new GsonBuilder().disableHtmlEscaping().create(); | ||
| return gson.toJson(customProperties); | ||
| return gson.toJson(getMaskedCustomProperties("")); | ||
| } | ||
| private Map<String, String> getMaskedCustomProperties(String keyPrefix) { | ||
| Map<String, String> maskedProperties = new HashMap<>(); | ||
| customProperties.forEach((key, value) -> { | ||
sollhui marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| String lowerKey = key.toLowerCase(Locale.ROOT); | ||
| boolean sensitive = KafkaConfiguration.SASL_JAAS_CONFIG.equalsIgnoreCase(key) | ||
0AyanamiRei marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| || KafkaConfiguration.AWS_ACCESS_KEY.equalsIgnoreCase(key) | ||
| || DatasourcePrintableMap.SENSITIVE_KEY.contains(key) | ||
0AyanamiRei marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| || lowerKey.endsWith(".password") | ||
| || lowerKey.endsWith(".secret") | ||
| || lowerKey.endsWith(".secret_key") | ||
| || lowerKey.endsWith(".secret.key") | ||
| || lowerKey.endsWith(".session_key") | ||
| || lowerKey.endsWith(".session.token") | ||
| || lowerKey.contains(".private.key.") | ||
| || lowerKey.endsWith(".private.key") | ||
| || lowerKey.endsWith(".private_key") | ||
| || lowerKey.endsWith(".passphrase") | ||
| || "ssl.keystore.key".equals(lowerKey) | ||
| || "ssl.key.pem".equals(lowerKey); | ||
| maskedProperties.put(keyPrefix + key, sensitive ? SENSITIVE_PROPERTY_MASK : value); | ||
| }); | ||
| return maskedProperties; | ||
| } | ||
| @Override | ||
| @@ -736,9 +763,7 @@ public Map<String, String> getDataSourceProperties() { | ||
| @Override | ||
| public Map<String, String> getCustomProperties() { | ||
| Map<String, String> ret = new HashMap<>(); | ||
| customProperties.forEach((k, v) -> ret.put("property." + k, v)); | ||
| return ret; | ||
| return getMaskedCustomProperties("property."); | ||
| } | ||
| @Override | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.