Search in sources :

Example 31 with WallConfig

use of com.alibaba.druid.wall.WallConfig in project druid by alibaba.

the class MySqlWallTest_hint method test_true_10.

public void test_true_10() throws Exception {
    WallConfig config = new WallConfig();
    config.setHintAllow(true);
    config.setMultiStatementAllow(true);
    config.setNoneBaseStatementAllow(true);
    String sql = "CREATE DATABASE `newsfocus` /*!40100 COLLATE 'big5_chinese_ci' */ ";
    //
    Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 32 with WallConfig

use of com.alibaba.druid.wall.WallConfig in project druid by alibaba.

the class MysqlWallTest_rename_table method test_false.

public void test_false() throws Exception {
    WallConfig config = new WallConfig();
    config.setRenameTableAllow(false);
    Assert.assertFalse(WallUtils.isValidateMySql("RENAME TABLE t1 TO t2", config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 33 with WallConfig

use of com.alibaba.druid.wall.WallConfig in project druid by alibaba.

the class TestOracleWall2 method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    WallFilter wall = new WallFilter();
    wall.setConfig(new WallConfig());
    wall.getConfig().setWrapAllow(false);
    dataSource.setOracle(true);
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setDriver(new OracleMockDriver());
    dataSource.setPoolPreparedStatements(true);
    dataSource.setConnectionProperties("defaultRowPrefetch=50");
    dataSource.setFilters("stat");
    dataSource.getProxyFilters().add(wall);
    dataSource.setDbType("oracle");
// dataSource.setFilters("log4j");
}
Also used : WallFilter(com.alibaba.druid.wall.WallFilter) WallConfig(com.alibaba.druid.wall.WallConfig) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) OracleMockDriver(com.alibaba.druid.test.util.OracleMockDriver)

Example 34 with WallConfig

use of com.alibaba.druid.wall.WallConfig in project druid by alibaba.

the class WallFilterTest3 method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:h2:mem:wall_test;");
    // dataSource.setFilters("wall");
    dataSource.setDbType(JdbcConstants.MARIADB);
    WallConfig config = new WallConfig();
    config.setTenantCallBack(new TenantTestCallBack());
    wallFilter = new WallFilter();
    wallFilter.setConfig(config);
    wallFilter.setDbType(JdbcConstants.MARIADB);
    List<Filter> filters = new LinkedList<Filter>();
    filters.add(wallFilter);
    dataSource.setProxyFilters(filters);
    dataSource.init();
}
Also used : WallFilter(com.alibaba.druid.wall.WallFilter) WallFilter(com.alibaba.druid.wall.WallFilter) Filter(com.alibaba.druid.filter.Filter) WallConfig(com.alibaba.druid.wall.WallConfig) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) LinkedList(java.util.LinkedList)

Example 35 with WallConfig

use of com.alibaba.druid.wall.WallConfig in project druid by alibaba.

the class WallHavingTest6 method test_check_true.

public void test_check_true() throws Exception {
    WallConfig config = new WallConfig();
    config.setSelectHavingAlwayTrueCheck(true);
    config.setConditionAndAlwayTrueAllow(true);
    config.setCommentAllow(true);
    Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
    Assert.assertFalse(WallUtils.isValidateMySql(sql1, config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Aggregations

WallConfig (com.alibaba.druid.wall.WallConfig)83 Properties (java.util.Properties)8 WallFilter (com.alibaba.druid.wall.WallFilter)5 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)4 WallCheckResult (com.alibaba.druid.wall.WallCheckResult)3 Filter (com.alibaba.druid.filter.Filter)2 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)2 OracleMockDriver (com.alibaba.druid.test.util.OracleMockDriver)2 WallContext (com.alibaba.druid.wall.WallContext)2 MySqlWallProvider (com.alibaba.druid.wall.spi.MySqlWallProvider)2 SQLCommentHint (com.alibaba.druid.sql.ast.SQLCommentHint)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 SQLStartTransactionStatement (com.alibaba.druid.sql.ast.statement.SQLStartTransactionStatement)1 MySqlCommitStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlCommitStatement)1 MySqlDeleteStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement)1 MySqlDescribeStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDescribeStatement)1 MySqlHintStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlHintStatement)1 MySqlLockTableStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLockTableStatement)1 MySqlRenameTableStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlRenameTableStatement)1 MySqlReplaceStatement (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlReplaceStatement)1