Skip to content

Commit e66c0a9

Browse files
committed
Merge branch '2.8' into 2.9
2 parents 4a2d8f4 + c921f09 commit e66c0a9

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Project: jackson-databind
1212
#1912: `BeanDeserializerModifier.updateBuilder()` not work to set custom
1313
deserializer on a property (since 2.9.0)
1414
(contributed by Deblock T)
15+
#1931: Two more `c3p0` gadgets to exploit default typing issue
1516

1617
2.9.4 (24-Jan-2018)
1718

@@ -213,6 +214,7 @@ Project: jackson-databind
213214
(reported by Rob W)
214215
#1899: Another two gadgets to exploit default typing issue in jackson-databind
215216
(reported by OneSourceCat@github)
217+
#1931: Two more `c3p0` gadgets to exploit default typing issue
216218

217219
2.8.11 (24-Dec-2017)
218220

src/main/java/com/fasterxml/jackson/databind/jsontype/impl/SubTypeValidator.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
*/
2020
public class SubTypeValidator
2121
{
22-
protected final static String PREFIX_STRING = "org.springframework.";
22+
protected final static String PREFIX_SPRING = "org.springframework.";
23+
24+
protected final static String PREFIX_C3P0 = "com.mchange.v2.c3p0.";
25+
2326
/**
2427
* Set of well-known "nasty classes", deserialization of which is considered dangerous
2528
* and should (and is) prevented by default.
@@ -46,8 +49,9 @@ public class SubTypeValidator
4649
// [databind#1737]; 3rd party
4750
//s.add("org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor"); // deprecated by [databind#1855]
4851
s.add("org.springframework.beans.factory.config.PropertyPathFactoryBean");
49-
s.add("com.mchange.v2.c3p0.JndiRefForwardingDataSource");
50-
s.add("com.mchange.v2.c3p0.WrapperConnectionPoolDataSource");
52+
53+
// s.add("com.mchange.v2.c3p0.JndiRefForwardingDataSource"); // deprecated by [databind#1931]
54+
// s.add("com.mchange.v2.c3p0.WrapperConnectionPoolDataSource"); // - "" -
5155
// [databind#1855]: more 3rd party
5256
s.add("org.apache.tomcat.dbcp.dbcp2.BasicDataSource");
5357
s.add("com.sun.org.apache.bcel.internal.util.ClassLoader");
@@ -86,8 +90,10 @@ public void validateSubType(DeserializationContext ctxt, JavaType type,
8690
// 18-Dec-2017, tatu: As per [databind#1855], need bit more sophisticated handling
8791
// for some Spring framework types
8892
// 05-Jan-2017, tatu: ... also, only applies to classes, not interfaces
89-
if (!raw.isInterface() && full.startsWith(PREFIX_STRING)) {
90-
for (Class<?> cls = raw; (cls != null) && (cls != Object.class); cls = cls.getSuperclass()) {
93+
if (raw.isInterface()) {
94+
;
95+
} else if (full.startsWith(PREFIX_SPRING)) {
96+
for (Class<?> cls = raw; (cls != null) && (cls != Object.class); cls = cls.getSuperclass()){
9197
String name = cls.getSimpleName();
9298
// looking for "AbstractBeanFactoryPointcutAdvisor" but no point to allow any is there?
9399
if ("AbstractPointcutAdvisor".equals(name)
@@ -96,6 +102,16 @@ public void validateSubType(DeserializationContext ctxt, JavaType type,
96102
break main_check;
97103
}
98104
}
105+
} else if (full.startsWith(PREFIX_C3P0)) {
106+
// [databind#1737]; more 3rd party
107+
// s.add("com.mchange.v2.c3p0.JndiRefForwardingDataSource");
108+
// s.add("com.mchange.v2.c3p0.WrapperConnectionPoolDataSource");
109+
// [databind#1931]; more 3rd party
110+
// com.mchange.v2.c3p0.ComboPooledDataSource
111+
// com.mchange.v2.c3p0.debug.AfterCloseLoggingComboPooledDataSource
112+
if (full.endsWith("DataSource")) {
113+
break main_check;
114+
}
99115
}
100116
return;
101117
} while (false);

src/test/java/com/fasterxml/jackson/databind/interop/IllegalTypesCheckTest.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import com.fasterxml.jackson.databind.*;
1111
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
1212

13+
import com.mchange.v2.c3p0.jacksontest.ComboPooledDataSource;
14+
1315
/**
1416
* Test case(s) to guard against handling of types that are illegal to handle
1517
* due to security constraints.
@@ -38,7 +40,7 @@ static class Authentication1872 {
3840
*/
3941

4042
private final ObjectMapper MAPPER = objectMapper();
41-
43+
4244
// // // Tests for [databind#1599]
4345

4446
public void testXalanTypes1599() throws Exception
@@ -86,34 +88,34 @@ public void testJDKTypes1855() throws Exception
8688

8789
// 17-Aug-2017, tatu: Ideally would test handling of 3rd party types, too,
8890
// but would require adding dependencies. This may be practical when
89-
// checking done by module, but for now let's not do that for databind.
91+
// checking done by separate module, but for now let's not do that for databind.
9092

9193
/*
9294
public void testSpringTypes1737() throws Exception
9395
{
9496
_testIllegalType("org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor");
9597
_testIllegalType("org.springframework.beans.factory.config.PropertyPathFactoryBean");
9698
}
97-
98-
public void testC3P0Types1737() throws Exception
99-
{
100-
_testTypes1737("com.mchange.v2.c3p0.JndiRefForwardingDataSource");
101-
_testTypes1737("com.mchange.v2.c3p0.WrapperConnectionPoolDataSource");
102-
}
10399
*/
104100

105101
// // // Tests for [databind#1872]
106102
public void testJDKTypes1872() throws Exception
107103
{
108104
ObjectMapper mapper = new ObjectMapper();
109105
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
110-
106+
111107
String json = aposToQuotes(String.format("{'@class':'%s','authorities':['java.util.ArrayList',[]]}",
112108
Authentication1872.class.getName()));
113109
Authentication1872 result = mapper.readValue(json, Authentication1872.class);
114110
assertNotNull(result);
115111
}
116112

113+
// [databind#1931]
114+
public void testC3P0Types() throws Exception
115+
{
116+
_testIllegalType(ComboPooledDataSource.class); // [databind#1931]
117+
}
118+
117119
private void _testIllegalType(Class<?> nasty) throws Exception {
118120
_testIllegalType(nasty.getName());
119121
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.mchange.v2.c3p0.jacksontest;
2+
3+
// test class for [databind#1931]
4+
public class ComboPooledDataSource {
5+
6+
}

0 commit comments

Comments
 (0)