-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support custom black list. #29
Merged
Merged
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,12 @@ | |
|
||
import com.alipay.hessian.NameBlackListFilter; | ||
|
||
import java.util.Arrays; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Scanner; | ||
|
||
/** | ||
* 内置黑名单列表过滤器 | ||
|
@@ -28,74 +32,12 @@ | |
*/ | ||
public class InternalNameBlackListFilter extends NameBlackListFilter { | ||
|
||
static final List<String> INTERNAL_BLACK_LIST = Arrays | ||
.asList( | ||
"org.codehaus.groovy.runtime.MethodClosure", | ||
"clojure.core$constantly", | ||
"clojure.main$eval_opt", | ||
"com.alibaba.citrus.springext.support.parser.AbstractNamedProxyBeanDefinitionParser$ProxyTargetFactory", | ||
"com.alibaba.citrus.springext.support.parser.AbstractNamedProxyBeanDefinitionParser$ProxyTargetFactoryImpl", | ||
"com.alibaba.citrus.springext.util.SpringExtUtil.AbstractProxy", | ||
"com.alipay.custrelation.service.model.redress.Pair", | ||
"com.caucho.hessian.test.TestCons", | ||
"com.mchange.v2.c3p0.JndiRefForwardingDataSource", | ||
"com.mchange.v2.c3p0.WrapperConnectionPoolDataSource", | ||
"com.rometools.rome.feed.impl.EqualsBean", | ||
"com.rometools.rome.feed.impl.ToStringBean", | ||
"com.sun.jndi.rmi.registry.BindingEnumeration", | ||
"com.sun.jndi.toolkit.dir.LazySearchEnumerationImpl", | ||
"com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl", | ||
"com.sun.rowset.JdbcRowSetImpl", | ||
"com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data", | ||
"java.rmi.server.UnicastRemoteObject", | ||
"java.security.SignedObject", | ||
"java.util.ServiceLoader$LazyIterator", | ||
"javax.imageio.ImageIO$ContainsFilter", | ||
"javax.imageio.spi.ServiceRegistry", | ||
"javax.management.BadAttributeValueExpException", | ||
"javax.naming.InitialContext", | ||
"javax.naming.spi.ObjectFactory", | ||
"javax.script.ScriptEngineManager", | ||
"javax.sound.sampled.AudioFormat$Encoding", | ||
"org.apache.carbondata.core.scan.expression.ExpressionResult", | ||
"org.apache.commons.dbcp.datasources.SharedPoolDataSource", | ||
"org.apache.ibatis.executor.loader.AbstractSerialStateHolder", | ||
"org.apache.ibatis.executor.loader.CglibSerialStateHolder", | ||
"org.apache.ibatis.executor.loader.JavassistSerialStateHolder", | ||
"org.apache.ibatis.executor.loader.cglib.CglibProxyFactory", | ||
"org.apache.ibatis.executor.loader.javassist.JavassistSerialStateHolder", | ||
"org.apache.tomcat.dbcp.dbcp.datasources.SharedPoolDataSource", | ||
"org.apache.wicket.util.upload.DiskFileItem", | ||
"org.apache.xalan.xsltc.trax.TemplatesImpl", | ||
"org.apache.xbean.naming.context.ContextUtil$ReadOnlyBinding", | ||
"org.apache.xpath.XPathContext", | ||
"org.eclipse.jetty.util.log.LoggerLog", | ||
"org.geotools.filter.ConstantExpression", | ||
"org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator$PartiallyComparableAdvisorHolder", | ||
"org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor", | ||
"org.springframework.beans.factory.BeanFactory", | ||
"org.springframework.beans.factory.config.PropertyPathFactoryBean", | ||
"org.springframework.beans.factory.support.DefaultListableBeanFactory", | ||
"org.springframework.jndi.support.SimpleJndiBeanFactory", | ||
"org.springframework.orm.jpa.AbstractEntityManagerFactoryBean", | ||
"org.springframework.transaction.jta.JtaTransactionManager", | ||
"org.yaml.snakeyaml.tokens.DirectiveToken", | ||
"sun.rmi.server.UnicastRef", | ||
"javax.management.ImmutableDescriptor", | ||
"org.springframework.jndi.JndiObjectTargetSource", | ||
"ch.qos.logback.core.db.JNDIConnectionSource", | ||
"java.beans.Expression", | ||
"javassist.bytecode", | ||
"org.apache.ibatis.javassist.bytecode", | ||
"org.springframework.beans.factory.config.MethodInvokingFactoryBean", | ||
"com.alibaba.druid.pool.DruidDataSource", | ||
"com.sun.org.apache.bcel.internal.util.ClassLoader", | ||
"com.alibaba.druid.stat.JdbcDataSourceStat", | ||
"org.apache.tomcat.dbcp.dbcp.BasicDataSource", | ||
"com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput", | ||
"javassist.tools.web.Viewer", | ||
"net.bytebuddy.dynamic.loading.ByteArrayClassLoader", | ||
"org.apache.commons.beanutils.BeanMap"); | ||
private static final String DEFAULT_BLACK_LIST = "security/serialize.blacklist"; | ||
|
||
private static final String blackListFile = System | ||
.getProperty("serialize.blacklist.file", DEFAULT_BLACK_LIST); | ||
|
||
static final List<String> INTERNAL_BLACK_LIST = readBlackList(blackListFile); | ||
|
||
/** | ||
* 构造函数 | ||
|
@@ -112,4 +54,32 @@ public InternalNameBlackListFilter() { | |
public InternalNameBlackListFilter(int maxCacheSize) { | ||
super(INTERNAL_BLACK_LIST, maxCacheSize); | ||
} | ||
|
||
private static List<String> readBlackList(String relativePath) { | ||
|
||
List<String> result = new ArrayList<String>(); | ||
//Get file from resources folder | ||
ClassLoader classLoader; | ||
|
||
if (blackListFile.equals(DEFAULT_BLACK_LIST)) { | ||
classLoader = InternalNameBlackListFilter.class.getClassLoader(); | ||
} else { | ||
classLoader = Thread.currentThread().getContextClassLoader(); | ||
} | ||
final URL resource = classLoader.getResource(relativePath); | ||
if (resource != null) { | ||
File file = new File(resource.getFile()); | ||
try { | ||
Scanner scanner = new Scanner(file); | ||
while (scanner.hasNextLine()) { | ||
String line = scanner.nextLine(); | ||
result.add(line); | ||
} | ||
scanner.close(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
} catch (IOException e) { | ||
//ignore | ||
} | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
org.codehaus.groovy.runtime.MethodClosure | ||
clojure.core$constantly | ||
clojure.main$eval_opt | ||
com.alibaba.citrus.springext.support.parser.AbstractNamedProxyBeanDefinitionParser$ProxyTargetFactory | ||
com.alibaba.citrus.springext.support.parser.AbstractNamedProxyBeanDefinitionParser$ProxyTargetFactoryImpl | ||
com.alibaba.citrus.springext.util.SpringExtUtil.AbstractProxy | ||
com.alipay.custrelation.service.model.redress.Pair | ||
com.caucho.hessian.test.TestCons | ||
com.mchange.v2.c3p0.JndiRefForwardingDataSource | ||
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource | ||
com.rometools.rome.feed.impl.EqualsBean | ||
com.rometools.rome.feed.impl.ToStringBean | ||
com.sun.jndi.rmi.registry.BindingEnumeration | ||
com.sun.jndi.toolkit.dir.LazySearchEnumerationImpl | ||
com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl | ||
com.sun.rowset.JdbcRowSetImpl | ||
com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data | ||
java.rmi.server.UnicastRemoteObject | ||
java.security.SignedObject | ||
java.util.ServiceLoader$LazyIterator | ||
javax.imageio.ImageIO$ContainsFilter | ||
javax.imageio.spi.ServiceRegistry | ||
javax.management.BadAttributeValueExpException | ||
javax.naming.InitialContext | ||
javax.naming.spi.ObjectFactory | ||
javax.script.ScriptEngineManager | ||
javax.sound.sampled.AudioFormat$Encoding | ||
org.apache.carbondata.core.scan.expression.ExpressionResult | ||
org.apache.commons.dbcp.datasources.SharedPoolDataSource | ||
org.apache.ibatis.executor.loader.AbstractSerialStateHolder | ||
org.apache.ibatis.executor.loader.CglibSerialStateHolder | ||
org.apache.ibatis.executor.loader.JavassistSerialStateHolder | ||
org.apache.ibatis.executor.loader.cglib.CglibProxyFactory | ||
org.apache.ibatis.executor.loader.javassist.JavassistSerialStateHolder | ||
org.apache.tomcat.dbcp.dbcp.datasources.SharedPoolDataSource | ||
org.apache.wicket.util.upload.DiskFileItem | ||
org.apache.xalan.xsltc.trax.TemplatesImpl | ||
org.apache.xbean.naming.context.ContextUtil$ReadOnlyBinding | ||
org.apache.xpath.XPathContext | ||
org.eclipse.jetty.util.log.LoggerLog | ||
org.geotools.filter.ConstantExpression | ||
org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator$PartiallyComparableAdvisorHolder | ||
org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor | ||
org.springframework.beans.factory.BeanFactory | ||
org.springframework.beans.factory.config.PropertyPathFactoryBean | ||
org.springframework.beans.factory.support.DefaultListableBeanFactory | ||
org.springframework.jndi.support.SimpleJndiBeanFactory | ||
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean | ||
org.springframework.transaction.jta.JtaTransactionManager | ||
org.yaml.snakeyaml.tokens.DirectiveToken | ||
sun.rmi.server.UnicastRef | ||
javax.management.ImmutableDescriptor | ||
org.springframework.jndi.JndiObjectTargetSource | ||
ch.qos.logback.core.db.JNDIConnectionSource | ||
java.beans.Expression | ||
javassist.bytecode | ||
org.apache.ibatis.javassist.bytecode | ||
org.springframework.beans.factory.config.MethodInvokingFactoryBean | ||
com.alibaba.druid.pool.DruidDataSource | ||
com.sun.org.apache.bcel.internal.util.ClassLoader | ||
com.alibaba.druid.stat.JdbcDataSourceStat | ||
org.apache.tomcat.dbcp.dbcp.BasicDataSource | ||
com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput | ||
javassist.tools.web.Viewer | ||
net.bytebuddy.dynamic.loading.ByteArrayClassLoader | ||
org.apache.commons.beanutils.BeanMap |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add to list if not blank.