Search in sources :

Example 26 with WallConfig

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

the class WallUpdateTest2 method testMySql_true.

public void testMySql_true() throws Exception {
    WallConfig config = new WallConfig();
    Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 27 with WallConfig

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

the class WallUpdateTest2 method testORACLE_true.

public void testORACLE_true() throws Exception {
    WallConfig config = new WallConfig();
    Assert.assertTrue(WallUtils.isValidateOracle(sql, config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 28 with WallConfig

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

the class MySqlWallDescribteTest method test_not_allow.

public void test_not_allow() throws Exception {
    WallConfig config = new WallConfig();
    config.setDescribeAllow(false);
    Assert.assertFalse(WallUtils.isValidateMySql("describe t", config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 29 with WallConfig

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

the class MySqlWallTest_hint method test_false.

public void test_false() throws Exception {
    WallConfig config = new WallConfig();
    config.setHintAllow(false);
    String sql = "select * from person where id = '3'/**/union select 0,1,v from (select 1,2,user/*!() as v*/) a where '1'<>''";
    //
    Assert.assertFalse(WallUtils.isValidateMySql(sql, config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 30 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)

Aggregations

WallConfig (com.alibaba.druid.wall.WallConfig)82 Properties (java.util.Properties)8 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)4 WallFilter (com.alibaba.druid.wall.WallFilter)4 WallCheckResult (com.alibaba.druid.wall.WallCheckResult)3 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 Filter (com.alibaba.druid.filter.Filter)1 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