mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge pull request #359 from cutedemons/master
modify deny variant, function, schema ,table
This commit is contained in:
@@ -41,8 +41,8 @@ public class SQLBinaryOpExpr extends SQLExprImpl implements Serializable {
|
||||
|
||||
public SQLBinaryOpExpr(SQLExpr left, SQLExpr right, SQLBinaryOperator operator){
|
||||
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
setLeft(left);
|
||||
setRight(right);
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,9 @@ public class SQLCaseExpr extends SQLExprImpl implements Serializable {
|
||||
}
|
||||
|
||||
public void setValueExpr(SQLExpr valueExpr) {
|
||||
if (valueExpr != null) {
|
||||
valueExpr.setParent(this);
|
||||
}
|
||||
this.valueExpr = valueExpr;
|
||||
}
|
||||
|
||||
@@ -71,6 +74,9 @@ public class SQLCaseExpr extends SQLExprImpl implements Serializable {
|
||||
}
|
||||
|
||||
public void setElseExpr(SQLExpr elseExpr) {
|
||||
if (elseExpr != null) {
|
||||
elseExpr.setParent(this);
|
||||
}
|
||||
this.elseExpr = elseExpr;
|
||||
}
|
||||
|
||||
@@ -78,6 +84,13 @@ public class SQLCaseExpr extends SQLExprImpl implements Serializable {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public void addItem(Item item) {
|
||||
if (item != null) {
|
||||
item.setParent(this);
|
||||
this.items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, this.valueExpr);
|
||||
@@ -99,8 +112,8 @@ public class SQLCaseExpr extends SQLExprImpl implements Serializable {
|
||||
|
||||
public Item(SQLExpr conditionExpr, SQLExpr valueExpr){
|
||||
|
||||
this.conditionExpr = conditionExpr;
|
||||
this.valueExpr = valueExpr;
|
||||
setConditionExpr(conditionExpr);
|
||||
setValueExpr(valueExpr);
|
||||
}
|
||||
|
||||
public SQLExpr getConditionExpr() {
|
||||
@@ -108,6 +121,9 @@ public class SQLCaseExpr extends SQLExprImpl implements Serializable {
|
||||
}
|
||||
|
||||
public void setConditionExpr(SQLExpr conditionExpr) {
|
||||
if (conditionExpr != null) {
|
||||
conditionExpr.setParent(this);
|
||||
}
|
||||
this.conditionExpr = conditionExpr;
|
||||
}
|
||||
|
||||
@@ -116,6 +132,9 @@ public class SQLCaseExpr extends SQLExprImpl implements Serializable {
|
||||
}
|
||||
|
||||
public void setValueExpr(SQLExpr valueExpr) {
|
||||
if (valueExpr != null) {
|
||||
valueExpr.setParent(this);
|
||||
}
|
||||
this.valueExpr = valueExpr;
|
||||
}
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ public class SQLExprParser extends SQLParser {
|
||||
accept(Token.THEN);
|
||||
SQLExpr valueExpr = expr();
|
||||
SQLCaseExpr.Item caseItem = new SQLCaseExpr.Item(testExpr, valueExpr);
|
||||
caseExpr.getItems().add(caseItem);
|
||||
caseExpr.addItem(caseItem);
|
||||
|
||||
while (lexer.token() == Token.WHEN) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -1223,7 +1223,7 @@ public class SQLEvalVisitorUtils {
|
||||
}
|
||||
|
||||
if (a instanceof String || b instanceof String) {
|
||||
return ((String) a).compareTo((String) b) > 0;
|
||||
return castToString(a).compareTo(castToString(b)) > 0;
|
||||
}
|
||||
|
||||
if (a instanceof BigDecimal || b instanceof BigDecimal) {
|
||||
|
||||
@@ -38,8 +38,10 @@ public class Isnull implements Function {
|
||||
SQLExpr condition = parameters.get(0);
|
||||
condition.accept(visitor);
|
||||
Object itemValue = condition.getAttributes().get(EVAL_VALUE);
|
||||
if (itemValue == null || itemValue == EVAL_VALUE_NULL) {
|
||||
if (itemValue == EVAL_VALUE_NULL) {
|
||||
return Boolean.TRUE;
|
||||
} else if (itemValue == null) {
|
||||
return null;
|
||||
} else {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr;
|
||||
import com.alibaba.druid.sql.visitor.SQLEvalVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLEvalVisitorUtils;
|
||||
|
||||
|
||||
public class Right implements Function {
|
||||
|
||||
public final static Right instance = new Right();
|
||||
|
||||
|
||||
public Object eval(SQLEvalVisitor visitor, SQLMethodInvokeExpr x) {
|
||||
if (x.getParameters().size() != 2) {
|
||||
return SQLEvalVisitor.EVAL_ERROR;
|
||||
@@ -45,7 +45,11 @@ public class Right implements Function {
|
||||
String strValue = param0Value.toString();
|
||||
int intValue = SQLEvalVisitorUtils.castToInteger(param1Value);
|
||||
|
||||
String result = strValue.substring(strValue.length() - intValue, strValue.length());
|
||||
int start = strValue.length() - intValue;
|
||||
if (start < 0) {
|
||||
start = 0;
|
||||
}
|
||||
String result = strValue.substring(start, strValue.length());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
basedir
|
||||
version_compile_os
|
||||
version
|
||||
version
|
||||
datadir
|
||||
@@ -1,5 +1,12 @@
|
||||
sp_executesql
|
||||
db_name
|
||||
col_name
|
||||
user_name
|
||||
host_name
|
||||
object_id
|
||||
is_srvrolemember
|
||||
DB_NAME
|
||||
HOST_NAME
|
||||
is_member
|
||||
opendatasource
|
||||
openrowset
|
||||
openquery
|
||||
has_dbaccess
|
||||
sp_executesql
|
||||
@@ -1,2 +1,5 @@
|
||||
master
|
||||
sys
|
||||
sys
|
||||
sysobjects
|
||||
sysdatabases
|
||||
information_schema
|
||||
@@ -1,100 +1,100 @@
|
||||
sysaltfiles
|
||||
syslockinfo
|
||||
syscacheobjects
|
||||
syslogins
|
||||
syscharsets
|
||||
sysmessages
|
||||
sysconfigures
|
||||
sysoledbusers
|
||||
syscurconfigs
|
||||
sysperfinfo
|
||||
sysdatabases
|
||||
sysprocesses
|
||||
sysdevices
|
||||
sysremotelogins
|
||||
syslanguages
|
||||
sysservers
|
||||
syscolumns
|
||||
sysindexkeys
|
||||
syscomments
|
||||
sysmembers
|
||||
sysconstraints
|
||||
sysobjects
|
||||
sysdepends
|
||||
syspermissions
|
||||
sysfilegroups
|
||||
sysprotects
|
||||
sysfiles
|
||||
sysreferences
|
||||
sysforeignkeys
|
||||
systypes
|
||||
sysfulltextcatalogs
|
||||
sysusers
|
||||
sysindexes
|
||||
sysalerts
|
||||
sysjobsteps
|
||||
syscategories
|
||||
sysnotifications
|
||||
sysdownloadlist
|
||||
sysoperators
|
||||
sysjobhistory
|
||||
systargetservergroupmembers
|
||||
sysjobs
|
||||
systargetservergroups
|
||||
sysjobschedules
|
||||
systargetservers
|
||||
sysjobservers
|
||||
systaskids
|
||||
backupfile
|
||||
restorefile
|
||||
backupmediafamily
|
||||
restorefilegroup
|
||||
backupmediaset
|
||||
restorehistory
|
||||
backupset
|
||||
sysdatabases
|
||||
sysservers
|
||||
sysreplicationalerts
|
||||
msagent_parameters
|
||||
mspublisher_databases
|
||||
msagent_profiles
|
||||
msreplication_objects
|
||||
msarticles
|
||||
msreplication_subscriptions
|
||||
msdistpublishers
|
||||
msrepl_commands
|
||||
msdistributiondbs
|
||||
msrepl_errors
|
||||
msdistribution_agents
|
||||
msrepl_originators
|
||||
msdistribution_history
|
||||
msrepl_transactions
|
||||
msdistributor
|
||||
msrepl_version
|
||||
mslogreader_agents
|
||||
mssnapshot_agents
|
||||
mslogreader_history
|
||||
mssnapshot_history
|
||||
msmerge_agents
|
||||
mssubscriber_info
|
||||
msmerge_history
|
||||
mssubscriber_schedule
|
||||
msmerge_subscriptions
|
||||
mssubscriptions
|
||||
mspublication_access
|
||||
mssubscription_properties
|
||||
mspublications
|
||||
msmerge_contents
|
||||
sysmergearticles
|
||||
msmerge_delete_conflicts
|
||||
sysmergepublications
|
||||
msmerge_genhistory
|
||||
sysmergeschemachange
|
||||
msmerge_replinfo
|
||||
sysmergesubscriptions
|
||||
msmerge_tombstone
|
||||
sysmergesubsetfilters
|
||||
sysarticles
|
||||
syspublications
|
||||
sysarticleupdates
|
||||
sysaltfiles
|
||||
syslockinfo
|
||||
syscacheobjects
|
||||
syslogins
|
||||
syscharsets
|
||||
sysmessages
|
||||
sysconfigures
|
||||
sysoledbusers
|
||||
syscurconfigs
|
||||
sysperfinfo
|
||||
sysdatabases
|
||||
sysprocesses
|
||||
sysdevices
|
||||
sysremotelogins
|
||||
syslanguages
|
||||
sysservers
|
||||
syscolumns
|
||||
sysindexkeys
|
||||
syscomments
|
||||
sysmembers
|
||||
sysconstraints
|
||||
sysobjects
|
||||
sysdepends
|
||||
syspermissions
|
||||
sysfilegroups
|
||||
sysprotects
|
||||
sysfiles
|
||||
sysreferences
|
||||
sysforeignkeys
|
||||
systypes
|
||||
sysfulltextcatalogs
|
||||
sysusers
|
||||
sysindexes
|
||||
sysalerts
|
||||
sysjobsteps
|
||||
syscategories
|
||||
sysnotifications
|
||||
sysdownloadlist
|
||||
sysoperators
|
||||
sysjobhistory
|
||||
systargetservergroupmembers
|
||||
sysjobs
|
||||
systargetservergroups
|
||||
sysjobschedules
|
||||
systargetservers
|
||||
sysjobservers
|
||||
systaskids
|
||||
backupfile
|
||||
restorefile
|
||||
backupmediafamily
|
||||
restorefilegroup
|
||||
backupmediaset
|
||||
restorehistory
|
||||
backupset
|
||||
sysdatabases
|
||||
sysservers
|
||||
sysreplicationalerts
|
||||
msagent_parameters
|
||||
mspublisher_databases
|
||||
msagent_profiles
|
||||
msreplication_objects
|
||||
msarticles
|
||||
msreplication_subscriptions
|
||||
msdistpublishers
|
||||
msrepl_commands
|
||||
msdistributiondbs
|
||||
msrepl_errors
|
||||
msdistribution_agents
|
||||
msrepl_originators
|
||||
msdistribution_history
|
||||
msrepl_transactions
|
||||
msdistributor
|
||||
msrepl_version
|
||||
mslogreader_agents
|
||||
mssnapshot_agents
|
||||
mslogreader_history
|
||||
mssnapshot_history
|
||||
msmerge_agents
|
||||
mssubscriber_info
|
||||
msmerge_history
|
||||
mssubscriber_schedule
|
||||
msmerge_subscriptions
|
||||
mssubscriptions
|
||||
mspublication_access
|
||||
mssubscription_properties
|
||||
mspublications
|
||||
msmerge_contents
|
||||
sysmergearticles
|
||||
msmerge_delete_conflicts
|
||||
sysmergepublications
|
||||
msmerge_genhistory
|
||||
sysmergeschemachange
|
||||
msmerge_replinfo
|
||||
sysmergesubscriptions
|
||||
msmerge_tombstone
|
||||
sysmergesubsetfilters
|
||||
sysarticles
|
||||
syspublications
|
||||
sysarticleupdates
|
||||
syssubscriptions
|
||||
@@ -1,2 +1,4 @@
|
||||
servername
|
||||
version
|
||||
user
|
||||
system_user
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class SQLServerWallPermitFunctionTest extends TestCase {
|
||||
}
|
||||
|
||||
public void test01() throws Exception {
|
||||
Assert.assertTrue(WallUtils.isValidateSqlServer("SELECT user_name() FROM X;"));
|
||||
Assert.assertFalse(WallUtils.isValidateSqlServer("SELECT user_name() FROM X;"));
|
||||
}
|
||||
|
||||
public final void test_sp_addsrvrolemenber() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user