add sql wall support

This commit is contained in:
温少
2012-03-15 17:13:20 +08:00
parent 8f8d6483cd
commit 8e8e297a9c
11 changed files with 284 additions and 56 deletions
@@ -0,0 +1,21 @@
package com.alibaba.druid.bvt.filter.wall;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.filter.wall.WallUtils;
public class MySqlWallTest extends TestCase {
public void testWall() throws Exception {
Assert.assertFalse(WallUtils.isValidateMySql("select 14,13,12,11,10,@@version_compile_os,8,7,6,5,4,3,2,1"));
Assert.assertTrue(WallUtils.isValidateMySql("select '@@version_compile_os'"));
Assert.assertFalse(WallUtils.isValidateMySql("select hex(load_file(0x633A2F77696E646F77732F7265706169722F73616D))"));
Assert.assertTrue(WallUtils.isValidateMySql("select 'hex(load_file(0x633A2F77696E646F77732F7265706169722F73616D))'"));
Assert.assertFalse(WallUtils.isValidateMySql("select 1 from information_schema.columns"));
Assert.assertTrue(WallUtils.isValidateMySql("select 'information_schema.columns'"));
}
}
@@ -34,5 +34,7 @@ public class WallVisitorUtilsTest extends TestCase {
Assert.assertEquals(Boolean.TRUE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("(select count(*) from t) >= 0")));
Assert.assertEquals(Boolean.FALSE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("(select count(*) from t) < 0")));
Assert.assertEquals(Boolean.TRUE, WallVisitorUtils.getValue(SQLUtils.toSQLExpr("NOT (select count(*) from t) < 0")));
//
}
}