WallFilter support DropProcedure Statement

This commit is contained in:
wenshao
2016-08-04 14:16:11 +08:00
parent e75a304fe9
commit cfa4b9fca2
3 changed files with 51 additions and 0 deletions
@@ -39,6 +39,7 @@ import com.alibaba.druid.sql.ast.statement.SQLAlterTableStatement;
import com.alibaba.druid.sql.ast.statement.SQLBlockStatement;
import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition;
import com.alibaba.druid.sql.ast.statement.SQLCreateProcedureStatement;
import com.alibaba.druid.sql.ast.statement.SQLDropProcedureStatement;
import com.alibaba.druid.sql.ast.statement.SQLDropSequenceStatement;
import com.alibaba.druid.sql.ast.statement.SQLDropTableStatement;
import com.alibaba.druid.sql.ast.statement.SQLDropTriggerStatement;
@@ -459,6 +460,12 @@ public class OracleStatementParser extends SQLStatementParser {
statementList.add(stmt);
continue;
}
if (lexer.token() == Token.PROCEDURE) {
SQLDropProcedureStatement stmt = parseDropProcedure(false);
statementList.add(stmt);
continue;
}
throw new ParserException("TODO : " + lexer.token() + " " + lexer.stringVal());
}
@@ -69,6 +69,7 @@ import com.alibaba.druid.sql.ast.statement.SQLCreateTriggerStatement;
import com.alibaba.druid.sql.ast.statement.SQLCreateViewStatement;
import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement;
import com.alibaba.druid.sql.ast.statement.SQLDropIndexStatement;
import com.alibaba.druid.sql.ast.statement.SQLDropProcedureStatement;
import com.alibaba.druid.sql.ast.statement.SQLDropSequenceStatement;
import com.alibaba.druid.sql.ast.statement.SQLDropTableStatement;
import com.alibaba.druid.sql.ast.statement.SQLDropTriggerStatement;
@@ -2434,6 +2435,7 @@ public class WallVisitorUtils {
|| x instanceof SQLDropViewStatement //
|| x instanceof SQLDropTriggerStatement //
|| x instanceof SQLDropSequenceStatement //
|| x instanceof SQLDropProcedureStatement //
) {
allow = config.isDropTableAllow();
denyMessage = "drop table not allow";
@@ -0,0 +1,42 @@
/*
* Copyright 1999-2101 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.bvt.filter.wall;
import junit.framework.TestCase;
import org.junit.Assert;
import com.alibaba.druid.wall.WallConfig;
import com.alibaba.druid.wall.WallUtils;
public class WallDropTest2 extends TestCase {
private String sql = "DROP PROCEDURE IF EXISTS CP_PayCalc1";
private WallConfig config = new WallConfig();
protected void setUp() throws Exception {
config.setDropTableAllow(true);
}
public void testMySql() throws Exception {
Assert.assertTrue(WallUtils.isValidateMySql(sql, config));
}
public void testORACLE() throws Exception {
Assert.assertTrue(WallUtils.isValidateOracle(sql, config));
}
}