Skip to content

Commit fe52024

Browse files
committed
Server:解决 @combine:"userId,..." 或 @combine:"userId{},..." 绕过权限校验,优化报错信息
1 parent 6be4970 commit fe52024

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/AbstractSQLConfig.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,14 +1379,16 @@ public static AbstractSQLConfig newSQLConfig(RequestMethod method, String table,
13791379
}
13801380
else if (w.startsWith("|")) {
13811381
if (method == PUT) {
1382-
throw new IllegalArgumentException("字符 " + w + " 不合法!PUT请求的 @combine:\"key0,key1,...\" 不允许传 |key 或 !key !");
1382+
throw new IllegalArgumentException(table + ":{} 里的 @combine:value 中的value里条件 " + ws[i] + " 不合法!"
1383+
+ "PUT请求的 @combine:\"key0,key1,...\" 不允许传 |key 或 !key !");
13831384
}
13841385
w = w.substring(1);
13851386
orList.add(w);
13861387
}
13871388
else if (w.startsWith("!")) {
13881389
if (method == PUT) {
1389-
throw new IllegalArgumentException("字符 " + w + " 不合法!PUT请求的 @combine:\"key0,key1,...\" 不允许传 |key 或 !key !");
1390+
throw new IllegalArgumentException(table + ":{} 里的 @combine:value 中的value里条件 " + ws[i] + " 不合法!"
1391+
+ "PUT请求的 @combine:\"key0,key1,...\" 不允许传 |key 或 !key !");
13901392
}
13911393
w = w.substring(1);
13921394
notList.add(w);
@@ -1395,11 +1397,20 @@ else if (w.startsWith("!")) {
13951397
orList.add(w);
13961398
}
13971399

1400+
if (w.isEmpty()) {
1401+
throw new IllegalArgumentException(table + ":{} 里的 @combine:value 中的value里条件 " + ws[i] + " 不合法!不允许为空值!");
1402+
}
1403+
else {
1404+
if (KEY_ID.equals(w) || KEY_ID_IN.equals(w) || KEY_USER_ID.equals(w) || KEY_USER_ID_IN.equals(w)) {
1405+
throw new UnsupportedOperationException(table + ":{} 里的 @combine:value 中的value里 " + ws[i] + " 不合法!"
1406+
+ "不允许传 [" + KEY_ID + ", " + KEY_ID_IN + ", " + KEY_USER_ID + ", " + KEY_USER_ID_IN + "] 其中任何一个!");
1407+
}
1408+
}
1409+
13981410
whereList.add(w);
13991411
}
14001412
if (request.containsKey(w) == false) {
1401-
throw new IllegalArgumentException("条件 " + w + " 不在同一表对象 TableKey:{} 里面!"
1402-
+ "或者是 id 或 id{} ,这两个key不允许在 @combine:value 的value里设置!");
1413+
throw new IllegalArgumentException(table + ":{} 里的 @combine:value 中的value里 " + ws[i] + " 对应的 " + w + " 不在它里面!");
14031414
}
14041415
}
14051416

0 commit comments

Comments
 (0)