use of com.alibaba.druid.wall.spi.MySqlWallProvider in project druid by alibaba.
the class MySqlWallTest59 method test_true.
public void test_true() throws Exception {
WallProvider provider = new MySqlWallProvider();
provider.getConfig().setSchemaCheck(true);
Assert.assertTrue(//
provider.checkValid(//
"SELECT * FROM mysql.proc " + //
"WHERE 1=1 AND db LIKE 'dsmessagedb001'" + " AND name LIKE 'Proc_getRemindinfoByRemindFlag'"));
Assert.assertEquals(1, provider.getTableStats().size());
}
use of com.alibaba.druid.wall.spi.MySqlWallProvider in project druid by alibaba.
the class MySqlWallTest60 method test_true.
public void test_true() throws Exception {
WallProvider provider = new MySqlWallProvider();
provider.getConfig().setSchemaCheck(true);
Assert.assertTrue(//
provider.checkValid("show create table `mysql`.`help_relation`"));
Assert.assertEquals(1, provider.getTableStats().size());
}
use of com.alibaba.druid.wall.spi.MySqlWallProvider in project druid by alibaba.
the class MySqlWallTest62 method test_true.
public void test_true() throws Exception {
WallProvider provider = new MySqlWallProvider();
provider.getConfig().setSchemaCheck(true);
Assert.assertTrue(//
provider.checkValid(//
"select temp.*, u.CanComment, u.CanBeShared, u.CanForward, COALESCE(b.UserID,0) as isBlocked" + //
" , COALESCE(f.UserID,0) as Followed, COALESCE(ff.UserID,0) as IsFollowed" + //
" , COALESCE(ul.UserID,0) as liked, COALESCE(fff.UserID,0) as RIsFollowed " + //
"from (select 294765 as UserID, 0 as RUserID, 7785977 as PicID " + //
" union all select 294765 as UserID, 0 as RUserID, 7780341 as PicID) temp " + //
"left join Users as u on u.UserID = temp.UserID " + //
"left join BlockUser as b on b.UserID = temp.UserID and b.BlockUserID = 294765 " + //
"left join Fans as f on f.FansID = temp.UserID and f.UserID = 294765 " + //
"left join Fans as ff ON ff.FansID = 294765 and ff.UserID = temp.UserID " + //
"left join Fans as fff ON fff.FansID = 294765 and fff.UserID = temp.RUserID " + "left join UserLikes as ul on ul.PicID = temp.PicID and ul.UserID = 294765"));
Assert.assertEquals(4, provider.getTableStats().size());
}
use of com.alibaba.druid.wall.spi.MySqlWallProvider in project druid by alibaba.
the class MySqlWallTest64 method test_false.
public void test_false() throws Exception {
WallProvider provider = new MySqlWallProvider();
provider.getConfig().setSchemaCheck(true);
Assert.assertFalse(//
provider.checkValid("SELECT email, passwd, login_id, full_name" + " FROM members" + " WHERE member_id = 3 AND 1=(SELECT COUNT(*) FROM tabname);'"));
Assert.assertEquals(2, provider.getTableStats().size());
}
use of com.alibaba.druid.wall.spi.MySqlWallProvider in project druid by alibaba.
the class WallFilter method init.
@Override
public synchronized void init(DataSourceProxy dataSource) {
if (null == dataSource) {
LOG.error("dataSource should not be null");
return;
}
if (this.dbType == null || this.dbType.trim().length() == 0) {
if (dataSource.getDbType() != null) {
this.dbType = dataSource.getDbType();
} else {
this.dbType = JdbcUtils.getDbType(dataSource.getRawJdbcUrl(), "");
}
}
if (dbType == null) {
dbType = JdbcUtils.getDbType(dataSource.getUrl(), null);
}
if (//
JdbcUtils.MYSQL.equals(dbType) || //
JdbcUtils.MARIADB.equals(dbType) || JdbcUtils.H2.equals(dbType)) {
if (config == null) {
config = new WallConfig(MySqlWallProvider.DEFAULT_CONFIG_DIR);
}
provider = new MySqlWallProvider(config);
} else if (JdbcUtils.ORACLE.equals(dbType) || JdbcUtils.ALI_ORACLE.equals(dbType)) {
if (config == null) {
config = new WallConfig(OracleWallProvider.DEFAULT_CONFIG_DIR);
}
provider = new OracleWallProvider(config);
} else if (JdbcUtils.SQL_SERVER.equals(dbType) || JdbcUtils.JTDS.equals(dbType)) {
if (config == null) {
config = new WallConfig(SQLServerWallProvider.DEFAULT_CONFIG_DIR);
}
provider = new SQLServerWallProvider(config);
} else if (JdbcUtils.POSTGRESQL.equals(dbType) || JdbcUtils.ENTERPRISEDB.equals(dbType)) {
if (config == null) {
config = new WallConfig(PGWallProvider.DEFAULT_CONFIG_DIR);
}
provider = new PGWallProvider(config);
} else if (JdbcUtils.DB2.equals(dbType)) {
if (config == null) {
config = new WallConfig(DB2WallProvider.DEFAULT_CONFIG_DIR);
}
provider = new DB2WallProvider(config);
} else {
throw new IllegalStateException("dbType not support : " + dbType + ", url " + dataSource.getUrl());
}
provider.setName(dataSource.getName());
this.inited = true;
}
Aggregations