Skip to content

Commit c921f09

Browse files
committed
Merge branch '2.7' into 2.8
2 parents 038b471 + 6799f8f commit c921f09

File tree

4 files changed

+41
-14
lines changed

4 files changed

+41
-14
lines changed

release-notes/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Project: jackson-databind
1010
(reported by Rob W)
1111
#1899: Another two gadgets to exploit default typing issue in jackson-databind
1212
(reported by OneSourceCat@github)
13+
#1931: Two more `c3p0` gadgets to exploit default typing issue
1314

1415
2.8.11 (24-Dec-2017)
1516

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
@@ -18,7 +18,10 @@
1818
*/
1919
public class SubTypeValidator
2020
{
21-
protected final static String PREFIX_STRING = "org.springframework.";
21+
protected final static String PREFIX_SPRING = "org.springframework.";
22+
23+
protected final static String PREFIX_C3P0 = "com.mchange.v2.c3p0.";
24+
2225
/**
2326
* Set of well-known "nasty classes", deserialization of which is considered dangerous
2427
* and should (and is) prevented by default.
@@ -45,8 +48,9 @@ public class SubTypeValidator
4548
// [databind#1737]; 3rd party
4649
//s.add("org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor"); // deprecated by [databind#1855]
4750
s.add("org.springframework.beans.factory.config.PropertyPathFactoryBean");
48-
s.add("com.mchange.v2.c3p0.JndiRefForwardingDataSource");
49-
s.add("com.mchange.v2.c3p0.WrapperConnectionPoolDataSource");
51+
52+
// s.add("com.mchange.v2.c3p0.JndiRefForwardingDataSource"); // deprecated by [databind#1931]
53+
// s.add("com.mchange.v2.c3p0.WrapperConnectionPoolDataSource"); // - "" -
5054
// [databind#1855]: more 3rd party
5155
s.add("org.apache.tomcat.dbcp.dbcp2.BasicDataSource");
5256
s.add("com.sun.org.apache.bcel.internal.util.ClassLoader");
@@ -84,8 +88,10 @@ public void validateSubType(DeserializationContext ctxt, JavaType type) throws J
8488
// 18-Dec-2017, tatu: As per [databind#1855], need bit more sophisticated handling
8589
// for some Spring framework types
8690
// 05-Jan-2017, tatu: ... also, only applies to classes, not interfaces
87-
if (!raw.isInterface() && full.startsWith(PREFIX_STRING)) {
88-
for (Class<?> cls = raw; (cls != null) && (cls != Object.class); cls = cls.getSuperclass()) {
91+
if (raw.isInterface()) {
92+
;
93+
} else if (full.startsWith(PREFIX_SPRING)) {
94+
for (Class<?> cls = raw; (cls != null) && (cls != Object.class); cls = cls.getSuperclass()){
8995
String name = cls.getSimpleName();
9096
// looking for "AbstractBeanFactoryPointcutAdvisor" but no point to allow any is there?
9197
if ("AbstractPointcutAdvisor".equals(name)
@@ -94,6 +100,16 @@ public void validateSubType(DeserializationContext ctxt, JavaType type) throws J
94100
break main_check;
95101
}
96102
}
103+
} else if (full.startsWith(PREFIX_C3P0)) {
104+
// [databind#1737]; more 3rd party
105+
// s.add("com.mchange.v2.c3p0.JndiRefForwardingDataSource");
106+
// s.add("com.mchange.v2.c3p0.WrapperConnectionPoolDataSource");
107+
// [databind#1931]; more 3rd party
108+
// com.mchange.v2.c3p0.ComboPooledDataSource
109+
// com.mchange.v2.c3p0.debug.AfterCloseLoggingComboPooledDataSource
110+
if (full.endsWith("DataSource")) {
111+
break main_check;
112+
}
97113
}
98114
return;
99115
} while (false);

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import com.fasterxml.jackson.annotation.JsonTypeInfo;
1010
import com.fasterxml.jackson.databind.*;
11+
import com.mchange.v2.c3p0.jacksontest.ComboPooledDataSource;
12+
13+
import java.util.ArrayList;
14+
import java.util.List;
1115

1216
/**
1317
* Test case(s) to guard against handling of types that are illegal to handle
@@ -37,7 +41,7 @@ static class Authentication1872 {
3741
*/
3842

3943
private final ObjectMapper MAPPER = objectMapper();
40-
44+
4145
// // // Tests for [databind#1599]
4246

4347
public void testXalanTypes1599() throws Exception
@@ -85,34 +89,34 @@ public void testJDKTypes1855() throws Exception
8589

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

9094
/*
9195
public void testSpringTypes1737() throws Exception
9296
{
9397
_testIllegalType("org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor");
9498
_testIllegalType("org.springframework.beans.factory.config.PropertyPathFactoryBean");
9599
}
96-
97-
public void testC3P0Types1737() throws Exception
98-
{
99-
_testTypes1737("com.mchange.v2.c3p0.JndiRefForwardingDataSource");
100-
_testTypes1737("com.mchange.v2.c3p0.WrapperConnectionPoolDataSource");
101-
}
102100
*/
103101

104102
// // // Tests for [databind#1872]
105103
public void testJDKTypes1872() throws Exception
106104
{
107105
ObjectMapper mapper = new ObjectMapper();
108106
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
109-
107+
110108
String json = aposToQuotes(String.format("{'@class':'%s','authorities':['java.util.ArrayList',[]]}",
111109
Authentication1872.class.getName()));
112110
Authentication1872 result = mapper.readValue(json, Authentication1872.class);
113111
assertNotNull(result);
114112
}
115113

114+
// [databind#1931]
115+
public void testC3P0Types() throws Exception
116+
{
117+
_testIllegalType(ComboPooledDataSource.class); // [databind#1931]
118+
}
119+
116120
private void _testIllegalType(Class<?> nasty) throws Exception {
117121
_testIllegalType(nasty.getName());
118122
}
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)