Search in sources :

Example 61 with WallConfig

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

the class MySqlWallTest_hint method test_true_4.

public void test_true_4() throws Exception {
    WallConfig config = new WallConfig();
    config.setHintAllow(true);
    config.setMultiStatementAllow(true);
    String sql = "LOCK TABLES `m_rpt_adgroupeffect` READ /*!32311 LOCAL */";
    //
    Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 62 with WallConfig

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

the class MySqlWallTest_hint method test_true_9.

public void test_true_9() throws Exception {
    WallConfig config = new WallConfig();
    config.setHintAllow(true);
    config.setMultiStatementAllow(true);
    String sql = //
    "CREATE TABLE `session` (" + //
    " `sess_id` varchar(128) NOT NULL," + //
    " `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00'," + //
    " `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00'," + //
    " `ip` varchar(40) NOT NULL," + //
    " `vars` mediumtext NOT NULL," + //
    " PRIMARY KEY(`sess_id`)," + //
    " INDEX `changed_index` (`changed`)" + ") /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */ ";
    //
    Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 63 with WallConfig

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

the class MySqlWallTest_hint method test_true_5.

public void test_true_5() throws Exception {
    WallConfig config = new WallConfig();
    config.setHintAllow(true);
    config.setMultiStatementAllow(true);
    String sql = //
    "DROP TABLE IF EXISTS `item_similarity`;" + //
    "\n/*!40101 SET @saved_cs_client     = @@character_set_client */;" + //
    "\n/*!40101 SET character_set_client = utf8 */;" + //
    "\nCREATE TABLE `item_similarity` (" + //
    " `id` bigint(20) unsigned NOT NULL, " + //
    " `sellerId` bigint(20) DEFAULT NULL," + //
    " PRIMARY KEY (`id`)" + //
    " ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" + " \n/*!40101 SET character_set_client = @saved_cs_client */;";
    //
    Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 64 with WallConfig

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

the class OracleWallPermitObjectTest method test_permitTable_allow.

public void test_permitTable_allow() throws Exception {
    WallConfig config = new WallConfig();
    config.setObjectCheck(false);
    Assert.assertTrue(WallUtils.isValidateOracle("select  sys.LinxReadFile('c:/boot.ini') from dual", config));
    Assert.assertTrue(WallUtils.isValidateOracle("select  sys.LinxRunCMD('cmd /c net user linx /add') from dual", config));
    Assert.assertTrue(WallUtils.isValidateOracle("select utl_inaddr.get_host_address from DUAL", config));
    Assert.assertTrue(WallUtils.isValidateOracle("select TO_CHAR(utl_inaddr.get_host_address) from DUAL", config));
    Assert.assertTrue(WallUtils.isValidateOracle("SELECT SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES('FOO','BAR','DBMS_OUTPUT'.PUT(:P1));", config));
    Assert.assertTrue(WallUtils.isValidateOracle("select SYS.DBMS_EXPORT_EXTENSION.GET_DOMAIN_INDEX_TABLES()", config));
}
Also used : WallConfig(com.alibaba.druid.wall.WallConfig)

Example 65 with WallConfig

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

the class OracleWallPermitVariantTest method test_permitTable.

public void test_permitTable() throws Exception {
    WallConfig config = new WallConfig();
    config.setVariantCheck(false);
    Assert.assertTrue(WallUtils.isValidateOracle("select UID from dual", config));
    Assert.assertTrue(WallUtils.isValidateOracle("select USER from dual", config));
    Assert.assertTrue(WallUtils.isValidateOracle("select user from dual", 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