提交 2e051b4e 编写于 作者: Q qiao tian

增加单元测试

上级 20790aca
...@@ -16,7 +16,11 @@ public class InvokeSecurityRiskMethodsTest { ...@@ -16,7 +16,11 @@ public class InvokeSecurityRiskMethodsTest {
@Before @Before
public void before() public void before()
{ {
//系统默认阻止的方法黑名单:System.exit(1);Runtime.getRuntime().exec()两个函数
QLExpressRunStrategy.setForbiddenInvokeSecurityRiskMethods(true); QLExpressRunStrategy.setForbiddenInvokeSecurityRiskMethods(true);
//用户还可以增加一些类的方法黑名单
QLExpressRunStrategy.addSecurityRiskMethod(InvokeSecurityRiskMethodsTest.class,"echo");
} }
@After @After
public void after() public void after()
...@@ -25,9 +29,15 @@ public class InvokeSecurityRiskMethodsTest { ...@@ -25,9 +29,15 @@ public class InvokeSecurityRiskMethodsTest {
} }
private static String[] expressList = new String[]{ private static String[] expressList = new String[]{
"System.exit(1);", "System.exit(1);",
"for(i=1;i<10;i++){\nRuntime.getRuntime().exec('echo 1+1');}" "for(i=1;i<10;i++){\nRuntime.getRuntime().exec('echo 1+1');}",
"a = new com.ql.util.express.bugfix.InvokeSecurityRiskMethodsTest();a.echo('hello')"
}; };
public String echo(String a)
{
return a;
}
@Test @Test
public void test() throws Exception { public void test() throws Exception {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册