Skip to content

Commit 9d49d73

Browse files
author
Bruno Paiva Lima da Silva
committed
fix: using masked properties for logging
1 parent e64bdb9 commit 9d49d73

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

wrapper/src/main/java/software/amazon/jdbc/DriverConnectionProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public Connection connect(
119119
final ConnectInfo connectInfo = this.targetDriverDialect.prepareConnectInfo(protocol, hostSpec, copy);
120120

121121
LOGGER.finest(() -> "Connecting to " + connectInfo.url
122-
+ PropertyUtils.logProperties(connectInfo.props, "\nwith properties: \n"));
122+
+ PropertyUtils.logProperties(PropertyUtils.maskProperties(connectInfo.props), "\nwith properties: \n"));
123123

124124
Connection conn = this.driver.connect(connectInfo.url, connectInfo.props);
125125

wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/GenericTargetDriverDialect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public void prepareDataSource(
7878
props.setProperty("url", finalUrl);
7979

8080
PropertyDefinition.removeAllExceptCredentials(props);
81-
82-
LOGGER.finest(() -> PropertyUtils.logProperties(props, "Connecting with properties: \n"));
81+
LOGGER.finest(() -> PropertyUtils.logProperties(PropertyUtils.maskProperties(props),
82+
"Connecting with properties: \n"));
8383

8484
if (!props.isEmpty()) {
8585
PropertyUtils.applyProperties(dataSource, props);

wrapper/src/main/java/software/amazon/jdbc/util/PropertyUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public static void setPropertyOnTarget(
9696
} else {
9797
writeMethod.invoke(target, propValue);
9898
}
99-
LOGGER.finest(() -> String.format("Set property '%s' with value: %s", propName, propValue));
99+
Object loggedProperty = propValue.equals(PropertyDefinition.PASSWORD.name) ? "***" : propValue;
100+
LOGGER.finest(() -> String.format("Set property '%s' with value: %s", propName, loggedProperty));
100101

101102
} catch (final InvocationTargetException ex) {
102103
LOGGER.warning(

0 commit comments

Comments
 (0)