use of com.alibaba.druid.wall.WallConfig in project druid by alibaba.
the class MySqlWallTest_hint method test_true_11.
public void test_true_11() throws Exception {
WallConfig config = new WallConfig();
config.setHintAllow(true);
config.setMultiStatementAllow(true);
config.setNoneBaseStatementAllow(true);
String sql = "EXPLAIN /*!40100 EXTENDED */ SELECT * FROM trade_order_header WHERE id = ?";
//
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
use of com.alibaba.druid.wall.WallConfig in project druid by alibaba.
the class MySqlWallTest_union method testUnion.
public void testUnion() throws Exception {
WallConfig config = new WallConfig();
config.setSelectUnionCheck(true);
// not end of comment
Assert.assertTrue(WallUtils.isValidateMySql("select f1, f2 from t where id=1 union select 1, 2", config));
Assert.assertFalse(WallUtils.isValidateMySql("select f1, f2 from t where id=1 union select 1, 2 --", config));
// no where
Assert.assertTrue(WallUtils.isValidateMySql("select f1, f2 from t union select 1, 2", config));
Assert.assertFalse(WallUtils.isValidateMySql("select f1, f2 from t where id=1 union select null, '1', 2 --", config));
//union select item is not const
Assert.assertTrue(WallUtils.isValidateMySql("select f1, f2 from t where id=1 union select c1, c2", config));
Assert.assertTrue(WallUtils.isValidateMySql("SELECT typeid, typename FROM (SELECT typeid, typename FROM materialtype UNION ALL SELECT ? AS typeid, ? AS typename) a ORDER BY typeid", // union select item has alias
config));
// from is subQuery
Assert.assertFalse(WallUtils.isValidateMySql("select f1, f2 from (select 1 as f1, 2 as f2) t union select 'u1', 'u2' --", config));
// union select item has alias
Assert.assertTrue(WallUtils.isValidateMySql("select f1, f2 from t where id=1 union select 'u1' as u1, 'u2' as u2", config));
}
use of com.alibaba.druid.wall.WallConfig in project druid by alibaba.
the class MysqlWallTest_rename_table method test_true.
public void test_true() throws Exception {
WallConfig config = new WallConfig();
config.setRenameTableAllow(true);
Assert.assertTrue(WallUtils.isValidateMySql("RENAME TABLE t1 TO t2", config));
}
use of com.alibaba.druid.wall.WallConfig in project druid by alibaba.
the class OracleWallPermitFunctionTest method test_permitTable_allow.
public void test_permitTable_allow() throws Exception {
WallConfig config = new WallConfig();
config.setFunctionCheck(false);
Assert.assertTrue(WallUtils.isValidateOracle("select SYS_CONTEXT ('USERENV', 'CURRENT_USER') from X", config));
}
use of com.alibaba.druid.wall.WallConfig in project druid by alibaba.
the class MySqlWallTest_hint method test_true_3.
public void test_true_3() throws Exception {
WallConfig config = new WallConfig();
config.setHintAllow(true);
config.setMultiStatementAllow(true);
String sql = " /*!50003 CREATE*/ /*!50020 /*!50003 PROCEDURE `top_calculate_customer_update`(in update_time DATETIME)" + " DETERMINISTIC" + " BEGIN" + " DECLARE done INT DEFAULT FALSE;" + " DECLARE c_receiver_city,c_receiver_district,c_receiver_address VARCHAR(200);" + " DECLARE c_last_updated DATETIME;" + " DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;" + " insert into top_calculate_customer_log (execute_time,info) values (now(),'update table top_taobao_order_customer_mid begin');" + " update top_tmp_order_middle_last_sync set status = 'wait', last_sync = update_time where plat_form = 'taobao' and status = 'blocking';" + " END */";
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
Aggregations