sql注入修改
This commit is contained in:
+2
-1
@@ -187,7 +187,8 @@ public class SysAnnouncementSendController {
|
||||
LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
|
||||
updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
|
||||
updateWrapper.last("where annt_id ='"+anntId+"' and user_id ='"+userId+"'");
|
||||
updateWrapper.eq(SysAnnouncementSend::getAnntId,anntId);
|
||||
updateWrapper.eq(SysAnnouncementSend::getUserId,userId);
|
||||
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
|
||||
sysAnnouncementSendService.update(announcementSend, updateWrapper);
|
||||
result.setSuccess(true);
|
||||
|
||||
+22
@@ -1764,6 +1764,8 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
}
|
||||
|
||||
private String getSelectCondition(Map<String, Object> parameter, List<LawsTag> fieldListCondition) {
|
||||
// 防止SQL注入
|
||||
this.checkForSQLInjection(parameter);
|
||||
// 拼接查询条件
|
||||
StringBuilder selectCondition = new StringBuilder("where del_flag = 0");
|
||||
// 非动态查询条件
|
||||
@@ -1773,6 +1775,26 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
return selectCondition.toString();
|
||||
}
|
||||
|
||||
private void checkForSQLInjection(Map<String, Object> parameterMap) {
|
||||
// 定义要检查的特殊字符
|
||||
String[] specialCharacters = {"'", "\"", "\\", "<", ">", "&", "*", ";"};
|
||||
|
||||
for (Map.Entry<String, Object> entry : parameterMap.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
|
||||
// 检查是否是字符串类型
|
||||
if (value instanceof String) {
|
||||
String strValue = (String) value;
|
||||
// 检查是否包含特殊字符
|
||||
for (String character : specialCharacters) {
|
||||
if (strValue.contains(character)) {
|
||||
throw new JeroBootException("输入字段中包含非法字符,请检查");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dynamicStateCondition(Map<String, Object> parameter, List<LawsTag> fieldListCondition, StringBuilder selectCondition) {
|
||||
parameter.forEach((k, v) -> {
|
||||
// 匹配参数和字段
|
||||
|
||||
Reference in New Issue
Block a user