From 946e43db537f0e5396c22c0dff1ed9870ab733c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A9=E5=B0=91?= Date: Sat, 17 Mar 2012 15:20:46 +0800 Subject: [PATCH] refactor --- .../java/com/alibaba/druid/filter/wall/WallConfig.java | 9 +++++++++ .../alibaba/druid/filter/wall/spi/MySqlWallVisitor.java | 7 +++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/alibaba/druid/filter/wall/WallConfig.java b/src/main/java/com/alibaba/druid/filter/wall/WallConfig.java index 5af380b16e..9d41e09719 100644 --- a/src/main/java/com/alibaba/druid/filter/wall/WallConfig.java +++ b/src/main/java/com/alibaba/druid/filter/wall/WallConfig.java @@ -11,6 +11,7 @@ public class WallConfig { private boolean selelctAllow = true; private boolean selectIntoAllow = true; + private boolean selectIntoOutfileAllow = false; private boolean selectWhereAlwayTrueCheck = true; private boolean selectHavingAlwayTrueCheck = true; @@ -90,6 +91,14 @@ public class WallConfig { this.selectIntoAllow = selectIntoAllow; } + public boolean isSelectIntoOutfileAllow() { + return selectIntoOutfileAllow; + } + + public void setSelectIntoOutfileAllow(boolean selectIntoOutfileAllow) { + this.selectIntoOutfileAllow = selectIntoOutfileAllow; + } + public boolean isSelectWhereAlwayTrueCheck() { return selectWhereAlwayTrueCheck; } diff --git a/src/main/java/com/alibaba/druid/filter/wall/spi/MySqlWallVisitor.java b/src/main/java/com/alibaba/druid/filter/wall/spi/MySqlWallVisitor.java index 1ad6fe5b7a..e3703a2f73 100644 --- a/src/main/java/com/alibaba/druid/filter/wall/spi/MySqlWallVisitor.java +++ b/src/main/java/com/alibaba/druid/filter/wall/spi/MySqlWallVisitor.java @@ -167,8 +167,11 @@ public class MySqlWallVisitor extends MySqlASTVisitorAdapter implements WallVisi @Override public boolean visit(MySqlOutFileExpr x) { - violations.add(new IllegalSQLObjectViolation(SQLUtils.toMySqlString(x))); - return false; + if (!config.isSelectIntoOutfileAllow()) { + violations.add(new IllegalSQLObjectViolation(SQLUtils.toMySqlString(x))); + } + + return true; } @Override