mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fixed #5154,avoid spring RCE
This commit is contained in:
@@ -25,6 +25,9 @@ import org.springframework.util.PropertyPlaceholderHelper;
|
||||
public class YamlUtils {
|
||||
|
||||
public static <T> T resourceYmlToObj(String resource, String prefix, Class<T> clazz) {
|
||||
if (!StringUtils.startsWithIgnoreCase("classpath:", resource)) {
|
||||
resource = "classpath:" + resource;
|
||||
}
|
||||
ClassPathResource classPathResource = new ClassPathResource(resource);
|
||||
|
||||
String content;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.alibaba.otter.canal.instance.manager;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -69,6 +70,9 @@ public class PlainCanalInstanceGenerator implements CanalInstanceGenerator {
|
||||
// ================ setter / getter ================
|
||||
|
||||
private BeanFactory getBeanFactory(String springXml) {
|
||||
if (!StringUtils.startsWithIgnoreCase("classpath:", springXml)) {
|
||||
springXml = "classpath:" + springXml;
|
||||
}
|
||||
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(springXml);
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.alibaba.otter.canal.instance.spring;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -44,6 +45,9 @@ public class SpringCanalInstanceGenerator implements CanalInstanceGenerator {
|
||||
}
|
||||
|
||||
private BeanFactory getBeanFactory(String springXml) {
|
||||
if (!StringUtils.startsWithIgnoreCase("classpath:", springXml)) {
|
||||
springXml = "classpath:" + springXml;
|
||||
}
|
||||
ApplicationContext applicationContext = new ClassPathXmlApplicationContext(springXml);
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class DefaultSpringInstanceTest {
|
||||
@Before
|
||||
public void start() {
|
||||
System.setProperty("canal.instance.destination", "retl");
|
||||
context = new ClassPathXmlApplicationContext(new String[] { "spring/default-instance.xml" });
|
||||
context = new ClassPathXmlApplicationContext(new String[] { "classpath:spring/default-instance.xml" });
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GroupSpringInstanceTest {
|
||||
@Before
|
||||
public void start() {
|
||||
System.setProperty("canal.instance.destination", "retl");
|
||||
context = new ClassPathXmlApplicationContext(new String[] { "spring/group-instance.xml" });
|
||||
context = new ClassPathXmlApplicationContext(new String[] { "classpath:spring/group-instance.xml" });
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -24,7 +24,7 @@ public class MemorySpringInstanceTest {
|
||||
@Before
|
||||
public void start() {
|
||||
System.setProperty("canal.instance.destination", "retl");
|
||||
context = new ClassPathXmlApplicationContext(new String[] { "spring/memory-instance.xml" });
|
||||
context = new ClassPathXmlApplicationContext(new String[] { "classpath:spring/memory-instance.xml" });
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -30,6 +30,9 @@ public class TableMetaTSDBBuilder {
|
||||
if (applicationContext == null) {
|
||||
synchronized (contexts) {
|
||||
if (applicationContext == null) {
|
||||
if (!StringUtils.startsWithIgnoreCase("classpath:", springXml)) {
|
||||
springXml = "classpath:" + springXml;
|
||||
}
|
||||
applicationContext = new ClassPathXmlApplicationContext(springXml);
|
||||
contexts.put(destination, applicationContext);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user