| | |
| | | * @throws ServiceException |
| | | */ |
| | | @Override |
| | | public boolean saveOrUpdateServiceInfo(DeployAppsVO deployAppsVO) throws ServiceException { |
| | | return this.saveOrUpdate(deployAppsVO); |
| | | public R saveOrUpdateServiceInfo(DeployAppsVO deployAppsVO) throws ServiceException { |
| | | boolean checkBoolean = checkCmdVer(deployAppsVO.getStartCmd()) && checkCmdVer(deployAppsVO.getStopCmd()) && checkCmdVer(deployAppsVO.getRestartCmd()); |
| | | if(checkBoolean){ |
| | | return R.fail("配置的命令中包含危险命令,如:rm、mv、rm -rf、chmod等命令和关键词! "); |
| | | } |
| | | return R.status(this.saveOrUpdate(deployAppsVO)); |
| | | } |
| | | |
| | | /** |
| | |
| | | if(Func.isEmpty(cmd)){ |
| | | return "The executed command is empty"; |
| | | } |
| | | if(checkCmdVer(cmd)){ |
| | | return "配置的命令中包含危险命令,如:rm、mv、rm -rf、chmod等命令和关键词! "; |
| | | } |
| | | // 执行Linux命令 |
| | | log.info("开始执行命令:"+cmd); |
| | | // Process process = Runtime.getRuntime().exec(cmd); |
| | |
| | | return "8080"; |
| | | } |
| | | |
| | | /** |
| | | * 启动、停止、重启命令校验 |
| | | * @param cmd |
| | | * @return true: 包含高风险命令, false:不包含 |
| | | */ |
| | | private boolean checkCmdVer(String cmd){ |
| | | if(Func.isEmpty(cmd)){ |
| | | return false; |
| | | } |
| | | String[] highRiskCommands = {"rm", "rmdir", "mv", "unlink", "rm -rf", "mv -rf", "dd", "chmod", "chown", "mkfs", "shutdown", "reboot", "kill"}; |
| | | for(String highRiskCmd : highRiskCommands){ |
| | | if(cmd.contains(highRiskCmd)){ |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | } |