Skip to content

Commit 4a8abfd

Browse files
authored
hessian whitelist (#6388)
1 parent a9f0762 commit 4a8abfd

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

dependencies-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127

128128
<jaxb_version>2.2.7</jaxb_version>
129129
<activation_version>1.2.0</activation_version>
130-
<hessian_lite_version>3.2.5</hessian_lite_version>
130+
<hessian_lite_version>3.2.8</hessian_lite_version>
131131
<alibaba_spring_context_support_version>1.0.2</alibaba_spring_context_support_version>
132132
<yaml_version>1.17</yaml_version>
133133
</properties>

dubbo-serialization/dubbo-serialization-hessian2/src/main/java/com/alibaba/dubbo/common/serialize/hessian2/Hessian2SerializerFactory.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,36 @@
1717
package com.alibaba.dubbo.common.serialize.hessian2;
1818

1919
import com.alibaba.com.caucho.hessian.io.SerializerFactory;
20+
import com.alibaba.dubbo.common.utils.ConfigUtils;
21+
import com.alibaba.dubbo.common.utils.StringUtils;
2022

2123
public class Hessian2SerializerFactory extends SerializerFactory {
24+
private static final String WHITELIST = "dubbo.application.hessian2.whitelist";
25+
private static final String ALLOW = "dubbo.application.hessian2.allow";
26+
private static final String DENY = "dubbo.application.hessian2.deny";
2227

23-
public static final SerializerFactory SERIALIZER_FACTORY = new Hessian2SerializerFactory();
28+
public static final SerializerFactory SERIALIZER_FACTORY;
29+
30+
/**
31+
* see https://github.com/ebourg/hessian/commit/cf851f5131707891e723f7f6a9718c2461aed826
32+
*/
33+
static {
34+
SERIALIZER_FACTORY = new Hessian2SerializerFactory();
35+
String whiteList = ConfigUtils.getProperty(WHITELIST);
36+
if ("true".equals(whiteList)) {
37+
SERIALIZER_FACTORY.getClassFactory().setWhitelist(true);
38+
String allowPattern = ConfigUtils.getProperty(ALLOW);
39+
if (StringUtils.isNotEmpty(allowPattern)) {
40+
SERIALIZER_FACTORY.getClassFactory().allow(allowPattern);
41+
}
42+
} else {
43+
SERIALIZER_FACTORY.getClassFactory().setWhitelist(false);
44+
String denyPattern = ConfigUtils.getProperty(DENY);
45+
if (StringUtils.isNotEmpty(denyPattern)) {
46+
SERIALIZER_FACTORY.getClassFactory().deny(denyPattern);
47+
}
48+
}
49+
}
2450

2551
private Hessian2SerializerFactory() {
2652
}

0 commit comments

Comments
 (0)