Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cms_sys
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
西魏
cms_sys
Commits
32124236
Commit
32124236
authored
May 11, 2020
by
sgjj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
防sql注入
parent
0834087b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
15 deletions
+28
-15
MCmsAction.java
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
+18
-4
IContentDao.xml
src/main/java/net/mingsoft/cms/dao/IContentDao.xml
+10
-11
No files found.
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
View file @
32124236
...
...
@@ -55,6 +55,8 @@ import java.util.ArrayList;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* 动态生成页面,需要后台配置自定义页数据
...
...
@@ -378,8 +380,16 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
catch
(
IOException
e1
)
{
e1
.
printStackTrace
();
}
Map
<
String
,
Object
>
searchMap
=
BasicUtil
.
assemblyRequestMap
();
searchMap
.
forEach
((
k
,
v
)->{
//sql注入过滤
if
(
sqlFilter
(
v
.
toString
())){
searchMap
.
put
(
k
,
""
);
}
});
//查询数量
int
count
=
contentBiz
.
getSearchCount
(
contentModel
,
fieldValueList
,
BasicUtil
.
assemblyRequestMap
()
,
BasicUtil
.
getAppId
(),
categoryIds
);
int
count
=
contentBiz
.
getSearchCount
(
contentModel
,
fieldValueList
,
searchMap
,
BasicUtil
.
getAppId
(),
categoryIds
);
int
total
=
PageUtil
.
totalPage
(
count
,
size
);
int
pageNo
=
BasicUtil
.
getInt
(
ParserUtil
.
PAGE_NO
,
1
);
...
...
@@ -412,7 +422,6 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
page
.
setPreUrl
(
preUrl
);
page
.
setLastUrl
(
lastUrl
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
Map
<
String
,
Object
>
searchMap
=
BasicUtil
.
assemblyRequestMap
();
searchMap
.
put
(
ParserUtil
.
PAGE_NO
,
pageNo
);
map
.
put
(
SEARCH
,
searchMap
);
map
.
put
(
ParserUtil
.
PAGE
,
page
);
...
...
@@ -420,6 +429,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
map
.
put
(
ParserUtil
.
IS_DO
,
false
);
//设置动态请求的模块路径
map
.
put
(
ParserUtil
.
MODEL_NAME
,
"mcms"
);
//解析后的内容
String
content
=
""
;
try
{
...
...
@@ -437,6 +447,11 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
this
.
outString
(
response
,
content
);
}
public
static
boolean
sqlFilter
(
String
str
){
Pattern
pattern
=
Pattern
.
compile
(
"\\b(and|exec|insert|select|drop|grant|alter|delete|update|count|chr|mid|master|truncate|char|declare|or)\\b|(\\*|;|\\+|'|%)"
);
Matcher
matcher
=
pattern
.
matcher
(
str
);
return
matcher
.
find
();
}
private
Map
get
(
String
key
,
List
<
Map
>
fields
)
{
for
(
Map
field
:
fields
)
{
...
...
@@ -472,4 +487,4 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
\ No newline at end of file
}
src/main/java/net/mingsoft/cms/dao/IContentDao.xml
View file @
32124236
...
...
@@ -259,33 +259,33 @@
<where>
a.app_id = #{websiteId}
<if
test=
"ids!=null and ids!=''"
>
and FIND_IN_SET(content_category_id,
'${ids}'
)
and FIND_IN_SET(content_category_id,
#{ids}
)
</if>
<if
test=
"map.content_title!=null"
>
and a.content_title like CONCAT("%",
'${map.content_title}'
,"%")
and a.content_title like CONCAT("%",
#{map.content_title}
,"%")
</if>
<if
test=
"map.content_author!=null"
>
and a.content_author like CONCAT("%",
'${map.content_author}'
,"%")
and a.content_author like CONCAT("%",
#{map.content_author}
,"%")
</if>
<if
test=
"map.content_source!=null"
>
and a.content_source like CONCAT("%",
'${map.content_source}'
,"%")
and a.content_source like CONCAT("%",
#{map.content_source}
,"%")
</if>
<if
test=
"map.content_type!=null"
>
and a.content_type like CONCAT("%",
'${map.content_type}'
,"%")
and a.content_type like CONCAT("%",
#{map.content_type}
,"%")
</if>
<if
test=
"map.content_description!=null"
>
and a.content_description like CONCAT("%",
'${map.content_description}'
,"%")
and a.content_description like CONCAT("%",
#{map.content_description}
,"%")
</if>
<if
test=
"map.content_keyword!=null"
>
and a.content_keyword like CONCAT("%",
'${map.content_keyword}'
,"%")
and a.content_keyword like CONCAT("%",
#{map.content_keyword}
,"%")
</if>
<if
test=
"map.content_details!=null"
>
and a.content_details like CONCAT("%",
'${map.content_details}'
,"%")
and a.content_details like CONCAT("%",
#{map.content_details}
,"%")
</if>
<if
test=
"tableName!=null and tableName!='' and diyMap!=null"
>
<foreach
item=
"item"
index=
"index"
collection=
"diyList"
open=
""
separator=
""
close=
""
>
and d.${item.key} like CONCAT("%",
'${item.value}'
,"%")
and d.${item.key} like CONCAT("%",
#{item.value}
,"%")
</foreach>
</if>
</where>
...
...
@@ -293,4 +293,4 @@
</select>
</mapper>
\ No newline at end of file
</mapper>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment