Skip to content

Commit f31af7e

Browse files
Vipinofficial11sgarg-CS
authored andcommitted
Prevent auto security injection on TCPS URLs
1 parent 775cf19 commit f31af7e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConstants.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ private OracleConstants() {
2929
public static final String PLUGIN_NAME = "Oracle";
3030
public static final String ORACLE_CONNECTION_STRING_SID_FORMAT = "jdbc:oracle:thin:@%s:%s:%s";
3131
public static final String ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT = "jdbc:oracle:thin:@//%s:%s/%s";
32-
// Connection formats to accept protocol (e.g., jdbc:oracle:thin:@<protocol>://<host>:<port>/<SID>)
33-
public static final String ORACLE_CONNECTION_STRING_SID_FORMAT_WITH_PROTOCOL = "jdbc:oracle:thin:@%s:%s:%s/%s";
34-
public static final String ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT_WITH_PROTOCOL =
35-
"jdbc:oracle:thin:@%s://%s:%s/%s";
32+
// Connection formats using TNS DESCRIPTOR to accept protocol
33+
public static final String ORACLE_SERVICE_NAME_FORMAT_TNS_DESCRIPTOR_WITH_PROTOCOL =
34+
"jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=%s)(HOST=%s)(PORT=%s))(CONNECT_DATA=(SERVICE_NAME=%s)))";
35+
public static final String ORACLE_SID_FORMAT_TNS_DESCRIPTOR_WITH_PROTOCOL =
36+
"jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=%s)(HOST=%s)(PORT=%s))(CONNECT_DATA=(SID=%s)))";
3637
public static final String ORACLE_CONNECTION_STRING_TNS_FORMAT = "jdbc:oracle:thin:@%s";
3738
public static final String DEFAULT_BATCH_VALUE = "defaultBatchValue";
3839
public static final String DEFAULT_ROW_PREFETCH = "defaultRowPrefetch";
@@ -102,7 +103,8 @@ private static String getConnectionStringWithService(@Nullable String host,
102103
boolean isSSLEnabled) {
103104
// Choose the appropriate format based on whether SSL is enabled.
104105
if (isSSLEnabled) {
105-
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT_WITH_PROTOCOL,
106+
// Use the TNS descriptor format for TCPS to prevent automatic security injection.
107+
return String.format(ORACLE_SERVICE_NAME_FORMAT_TNS_DESCRIPTOR_WITH_PROTOCOL,
106108
connectionProtocol, host, port, database);
107109
}
108110
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SERVICE_NAME_FORMAT,
@@ -126,7 +128,8 @@ private static String getConnectionStringWithSID(@Nullable String host,
126128
boolean isSSLEnabled) {
127129
// Choose the appropriate format based on whether SSL is enabled.
128130
if (isSSLEnabled) {
129-
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT_WITH_PROTOCOL,
131+
// Use the TNS descriptor format for TCPS to prevent automatic security injection.
132+
return String.format(ORACLE_SID_FORMAT_TNS_DESCRIPTOR_WITH_PROTOCOL,
130133
connectionProtocol, host, port, database);
131134
}
132135
return String.format(OracleConstants.ORACLE_CONNECTION_STRING_SID_FORMAT,

0 commit comments

Comments
 (0)