Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
8ed7916b
Commit
8ed7916b
authored
Jul 30, 2021
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时任务屏蔽http(s)远程调用
parent
2de5cc52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
14 deletions
+45
-14
ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java
...mon/src/main/java/com/ruoyi/common/utils/StringUtils.java
+23
-0
ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java
...in/java/com/ruoyi/quartz/controller/SysJobController.java
+22
-14
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java
View file @
8ed7916b
...
@@ -324,6 +324,29 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
...
@@ -324,6 +324,29 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
return
list
;
return
list
;
}
}
/**
* 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写
*
* @param cs 指定字符串
* @param searchCharSequences 需要检查的字符串数组
* @return 是否包含任意一个字符串
*/
public
static
boolean
containsAnyIgnoreCase
(
CharSequence
cs
,
CharSequence
...
searchCharSequences
)
{
if
(
isEmpty
(
cs
)
||
isEmpty
(
searchCharSequences
))
{
return
false
;
}
for
(
CharSequence
testStr
:
searchCharSequences
)
{
if
(
containsIgnoreCase
(
cs
,
testStr
))
{
return
true
;
}
}
return
false
;
}
/**
/**
* 驼峰转下划线命名
* 驼峰转下划线命名
*/
*/
...
...
ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java
View file @
8ed7916b
...
@@ -79,18 +79,22 @@ public class SysJobController extends BaseController
...
@@ -79,18 +79,22 @@ public class SysJobController extends BaseController
@PreAuthorize
(
"@ss.hasPermi('monitor:job:add')"
)
@PreAuthorize
(
"@ss.hasPermi('monitor:job:add')"
)
@Log
(
title
=
"定时任务"
,
businessType
=
BusinessType
.
INSERT
)
@Log
(
title
=
"定时任务"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
@PostMapping
public
AjaxResult
add
(
@RequestBody
SysJob
sysJ
ob
)
throws
SchedulerException
,
TaskException
public
AjaxResult
add
(
@RequestBody
SysJob
j
ob
)
throws
SchedulerException
,
TaskException
{
{
if
(!
CronUtils
.
isValid
(
sysJ
ob
.
getCronExpression
()))
if
(!
CronUtils
.
isValid
(
j
ob
.
getCronExpression
()))
{
{
return
AjaxResult
.
error
(
"新增任务'"
+
sysJ
ob
.
getJobName
()
+
"'失败,Cron表达式不正确"
);
return
error
(
"新增任务'"
+
j
ob
.
getJobName
()
+
"'失败,Cron表达式不正确"
);
}
}
else
if
(
StringUtils
.
containsIgnoreCase
(
sysJ
ob
.
getInvokeTarget
(),
Constants
.
LOOKUP_RMI
))
else
if
(
StringUtils
.
containsIgnoreCase
(
j
ob
.
getInvokeTarget
(),
Constants
.
LOOKUP_RMI
))
{
{
return
AjaxResult
.
error
(
"新增任务'"
+
sysJ
ob
.
getJobName
()
+
"'失败,目标字符串不允许'rmi://'调用"
);
return
error
(
"新增任务'"
+
j
ob
.
getJobName
()
+
"'失败,目标字符串不允许'rmi://'调用"
);
}
}
sysJob
.
setCreateBy
(
SecurityUtils
.
getUsername
());
else
if
(
StringUtils
.
containsAnyIgnoreCase
(
job
.
getInvokeTarget
(),
new
String
[]
{
Constants
.
HTTP
,
Constants
.
HTTPS
}))
return
toAjax
(
jobService
.
insertJob
(
sysJob
));
{
return
error
(
"新增任务'"
+
job
.
getJobName
()
+
"'失败,目标字符串不允许'http(s)//'调用"
);
}
job
.
setCreateBy
(
SecurityUtils
.
getUsername
());
return
toAjax
(
jobService
.
insertJob
(
job
));
}
}
/**
/**
...
@@ -99,18 +103,22 @@ public class SysJobController extends BaseController
...
@@ -99,18 +103,22 @@ public class SysJobController extends BaseController
@PreAuthorize
(
"@ss.hasPermi('monitor:job:edit')"
)
@PreAuthorize
(
"@ss.hasPermi('monitor:job:edit')"
)
@Log
(
title
=
"定时任务"
,
businessType
=
BusinessType
.
UPDATE
)
@Log
(
title
=
"定时任务"
,
businessType
=
BusinessType
.
UPDATE
)
@PutMapping
@PutMapping
public
AjaxResult
edit
(
@RequestBody
SysJob
sysJ
ob
)
throws
SchedulerException
,
TaskException
public
AjaxResult
edit
(
@RequestBody
SysJob
j
ob
)
throws
SchedulerException
,
TaskException
{
{
if
(!
CronUtils
.
isValid
(
sysJob
.
getCronExpression
()))
if
(!
CronUtils
.
isValid
(
job
.
getCronExpression
()))
{
return
error
(
"修改任务'"
+
job
.
getJobName
()
+
"'失败,Cron表达式不正确"
);
}
else
if
(
StringUtils
.
containsIgnoreCase
(
job
.
getInvokeTarget
(),
Constants
.
LOOKUP_RMI
))
{
{
return
AjaxResult
.
error
(
"修改任务'"
+
sysJob
.
getJobName
()
+
"'失败,Cron表达式不正确
"
);
return
error
(
"修改任务'"
+
job
.
getJobName
()
+
"'失败,目标字符串不允许'rmi://'调用
"
);
}
}
else
if
(
StringUtils
.
contains
IgnoreCase
(
sysJob
.
getInvokeTarget
(),
Constants
.
LOOKUP_RMI
))
else
if
(
StringUtils
.
contains
AnyIgnoreCase
(
job
.
getInvokeTarget
(),
new
String
[]
{
Constants
.
HTTP
,
Constants
.
HTTPS
}
))
{
{
return
AjaxResult
.
error
(
"修改任务'"
+
sysJob
.
getJobName
()
+
"'失败,目标字符串不允许'rmi:
//'调用"
);
return
error
(
"修改任务'"
+
job
.
getJobName
()
+
"'失败,目标字符串不允许'http(s)
//'调用"
);
}
}
sysJ
ob
.
setUpdateBy
(
SecurityUtils
.
getUsername
());
j
ob
.
setUpdateBy
(
SecurityUtils
.
getUsername
());
return
toAjax
(
jobService
.
updateJob
(
sysJ
ob
));
return
toAjax
(
jobService
.
updateJob
(
j
ob
));
}
}
/**
/**
...
...
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