Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
182b9e2b
Commit
182b9e2b
authored
Aug 22, 2021
by
季圣华
Browse files
增加防御代码,防止恶意攻击(优化)
parent
d21e6a4f
Changes
3
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/LogMapperEx.java
View file @
182b9e2b
...
...
@@ -30,6 +30,7 @@ public interface LogMapperEx {
@Param
(
"content"
)
String
content
);
Long
getCountByIpAndDate
(
@Param
(
"moduleName"
)
String
moduleName
,
@Param
(
"clientIp"
)
String
clientIp
,
@Param
(
"createTime"
)
String
createTime
);
}
\ No newline at end of file
jshERP-boot/src/main/java/com/jsh/erp/service/log/LogService.java
View file @
182b9e2b
...
...
@@ -150,7 +150,7 @@ public class LogService {
if
(
userId
!=
null
)
{
String
clientIp
=
getLocalIp
(
request
);
String
createTime
=
Tools
.
getNow3
();
Long
count
=
logMapperEx
.
getCountByIpAndDate
(
clientIp
,
createTime
);
Long
count
=
logMapperEx
.
getCountByIpAndDate
(
moduleName
,
clientIp
,
createTime
);
if
(
count
>
0
)
{
//如果某1个IP在同1秒内连续操作两遍,此时需要删除该redis记录,使其退出,防止恶意攻击
redisService
.
deleteObjectByKeyAndIp
(
"clientIp"
,
clientIp
,
"userId"
);
...
...
jshERP-boot/src/main/resources/mapper_xml/LogMapperEx.xml
View file @
182b9e2b
...
...
@@ -72,6 +72,6 @@
</select>
<select
id=
"getCountByIpAndDate"
resultType=
"java.lang.Long"
>
select count(1) from jsh_log where client_ip=#{clientIp} and create_time=#{createTime}
select count(1) from jsh_log where
operation=#{moduleName} and
client_ip=#{clientIp} and create_time=#{createTime}
</select>
</mapper>
\ No newline at end of file
Write
Preview
Supports
Markdown
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