From 08639ad830406ca01960d6a8fbddef478d6172f9 Mon Sep 17 00:00:00 2001 From: wenshao Date: Fri, 15 Mar 2013 17:50:13 +0800 Subject: [PATCH] bug fixed for WallFilter --- .../druid/wall/mysql/permit-function.txt | 2 +- .../druid/bvt/filter/wall/MySqlWallTest4.java | 37 +++++++++++++++++++ .../druid/bvt/filter/wall/MySqlWallTest5.java | 37 +++++++++++++++++++ .../druid/bvt/filter/wall/MySqlWallTest6.java | 37 +++++++++++++++++++ 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest4.java create mode 100644 src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest5.java create mode 100644 src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest6.java diff --git a/src/main/resources/META-INF/druid/wall/mysql/permit-function.txt b/src/main/resources/META-INF/druid/wall/mysql/permit-function.txt index 94141d2884..a3752fb9f2 100644 --- a/src/main/resources/META-INF/druid/wall/mysql/permit-function.txt +++ b/src/main/resources/META-INF/druid/wall/mysql/permit-function.txt @@ -1,6 +1,6 @@ version load_file -databse +database schema user system_user diff --git a/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest4.java b/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest4.java new file mode 100644 index 0000000000..2b0b59efb4 --- /dev/null +++ b/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest4.java @@ -0,0 +1,37 @@ +/* + * Copyright 1999-2011 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.druid.bvt.filter.wall; + +import junit.framework.TestCase; + +import org.junit.Assert; + +import com.alibaba.druid.wall.WallUtils; + +/** + * SQLServerWallTest + * + * @author RaymondXiu + * @version 1.0, 2012-3-18 + * @see + */ +public class MySqlWallTest4 extends TestCase { + + public void test_stuff() throws Exception { + Assert.assertFalse(WallUtils.isValidateMySql(// + "SSELECT a.*,b.name FROM vote_info a left join vote_item b on a.item_id=b.id where a.id<10 or 1=1 limit 1,10")); + } +} diff --git a/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest5.java b/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest5.java new file mode 100644 index 0000000000..2bcd99eb09 --- /dev/null +++ b/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest5.java @@ -0,0 +1,37 @@ +/* + * Copyright 1999-2011 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.druid.bvt.filter.wall; + +import junit.framework.TestCase; + +import org.junit.Assert; + +import com.alibaba.druid.wall.WallUtils; + +/** + * SQLServerWallTest + * + * @author RaymondXiu + * @version 1.0, 2012-3-18 + * @see + */ +public class MySqlWallTest5 extends TestCase { + + public void test_stuff() throws Exception { + Assert.assertFalse(WallUtils.isValidateMySql(// + "select * from tbl_product WHERE delFlag=0 AND cateId = 40 OR EXTRACTVALUE(1,CONCAT(0x7c,database(),0x7c)) order by sort desc, productId desc limit 20,20")); + } +} diff --git a/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest6.java b/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest6.java new file mode 100644 index 0000000000..975bee6f55 --- /dev/null +++ b/src/test/java/com/alibaba/druid/bvt/filter/wall/MySqlWallTest6.java @@ -0,0 +1,37 @@ +/* + * Copyright 1999-2011 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.druid.bvt.filter.wall; + +import junit.framework.TestCase; + +import org.junit.Assert; + +import com.alibaba.druid.wall.WallUtils; + +/** + * SQLServerWallTest + * + * @author RaymondXiu + * @version 1.0, 2012-3-18 + * @see + */ +public class MySqlWallTest6 extends TestCase { + + public void test_stuff() throws Exception { + Assert.assertFalse(WallUtils.isValidateMySql(// + "SELECT a.* FROM vote_info a where a.id<10 or (id <5 or 1=1) limit 1,10")); + } +}