diff --git a/0001-fix-input-validation-problem.patch b/0001-fix-input-validation-problem.patch new file mode 100644 index 0000000000000000000000000000000000000000..422f54de4446ab651f334e647860293b5dca23e2 --- /dev/null +++ b/0001-fix-input-validation-problem.patch @@ -0,0 +1,148 @@ +From cde779dda45612036d1c25a993a80d940805e65d Mon Sep 17 00:00:00 2001 +From: hugang <18768366022@163.com> +Date: Thu, 17 Oct 2024 17:03:06 +0800 +Subject: [PATCH] fix input validation problem + +--- + packages/cron-select/index.vue | 13 ++++++++++++- + packages/cron-select/locales/lang/en.json | 3 ++- + packages/cron-select/locales/lang/zh-cn.json | 3 ++- + src/locales/lang/en.json | 1 + + src/locales/lang/zh-cn.json | 1 + + src/views/assests/HostEdition.vue | 4 +++- + src/views/execution/components/NewCommand.vue | 3 ++- + src/views/execution/components/NewScript.vue | 3 ++- + 8 files changed, 25 insertions(+), 6 deletions(-) + +diff --git a/packages/cron-select/index.vue b/packages/cron-select/index.vue +index 3720d29..2c27fd3 100644 +--- a/packages/cron-select/index.vue ++++ b/packages/cron-select/index.vue +@@ -7,7 +7,7 @@ import Month from './Month.vue' + import Weeks from './Week.vue' + import Seconds from './Seconds.vue' + import Year from './Year.vue' +-import { ElInput, ElPopover, ElTabPane, ElTabs } from 'element-plus' ++import { ElInput, ElPopover, ElTabPane, ElTabs, ElMessage } from 'element-plus' + import 'element-plus/es/components/tabs/style/css' + import 'element-plus/es/components/tab-pane/style/css' + import 'element-plus/es/components/popover/style/css' +@@ -54,6 +54,17 @@ const emits = defineEmits(['change']) + const handleChange = (index: number, value: string) => { + if (_cron.value) { + _cron.value[index] = value ++ if (index === 3 && value !== '?') { ++ if (_cron.value[5] !== '?') { ++ ElMessage.warning(t('conflictWarning')) ++ _cron.value[5] = '?' ++ } ++ } else if (index === 5 && value !== '?') { ++ if (_cron.value[3] !== '?') { ++ ElMessage.warning(t('conflictWarning')) ++ _cron.value[3] = '?' ++ } ++ } + } else { + _cron.value = [value] + } +diff --git a/packages/cron-select/locales/lang/en.json b/packages/cron-select/locales/lang/en.json +index 98cf2ed..1fea02a 100644 +--- a/packages/cron-select/locales/lang/en.json ++++ b/packages/cron-select/locales/lang/en.json +@@ -21,5 +21,6 @@ + "start": "Start", + "unspecified": "Unspecified", + "week": "Week", +- "year": "Year" ++ "year": "Year", ++ "conflictWarning" : "Week and day conflict, the other has been set to unspecified" + } +diff --git a/packages/cron-select/locales/lang/zh-cn.json b/packages/cron-select/locales/lang/zh-cn.json +index 327b2cf..4bf5429 100644 +--- a/packages/cron-select/locales/lang/zh-cn.json ++++ b/packages/cron-select/locales/lang/zh-cn.json +@@ -20,5 +20,6 @@ + "select": "选择", + "unspecified": "不指定", + "week": "星期", +- "year": "年" ++ "year": "年", ++ "conflictWarning" : "周与日冲突,已将另一个设置为不指定" + } +diff --git a/src/locales/lang/en.json b/src/locales/lang/en.json +index 52c74fc..3191ee6 100644 +--- a/src/locales/lang/en.json ++++ b/src/locales/lang/en.json +@@ -150,6 +150,7 @@ + "password": "Please set the host login password", + "sshPort": "Please enter a positive integer between 0 and 65535", + "ssh_pkey": "Please set the host ssh_pkey", ++ "requireHostName": "Please enter the host name", + "username": "please enter user name", + "username_one": "Usernames are composed of numbers, English letters or special characters. They cannot contain spaces and the following special characters: :<>&,'\"\\/%.", + "username_three": "The user name consists of numbers, English letters or special characters. It cannot contain spaces and the following special characters: :<>", +diff --git a/src/locales/lang/zh-cn.json b/src/locales/lang/zh-cn.json +index c6d5b37..368818a 100644 +--- a/src/locales/lang/zh-cn.json ++++ b/src/locales/lang/zh-cn.json +@@ -148,6 +148,7 @@ + "ip": "请输入IP地址在 0.0.0.0~255.255.255.255 区间内", + "management": "请选择管理还是监控节点", + "password": "请设置主机登录密码", ++ "requireHostName": "请输入主机名称", + "sshPort": "请输入 0~65535 内正整数", + "ssh_pkey": "请输入主机登录密钥", + "username": "请输入用户名", +diff --git a/src/views/assests/HostEdition.vue b/src/views/assests/HostEdition.vue +index 87ed5e9..219912f 100644 +--- a/src/views/assests/HostEdition.vue ++++ b/src/views/assests/HostEdition.vue +@@ -92,7 +92,8 @@ function validateHostUsername(_rule: Rule, value: string) { + * @param value + */ + function validateHostName(_rule: Rule, value: string) { +- if (/^\S?$/.test(value)) ++ if (value.length === 0) return Promise.resolve() ++ if (/^\s|.*\s$/.test(value)) + return Promise.reject(new Error(t('assests.validateMsg.hostName_one'))) + if (!/^(?!\s*$).+/.test(value)) + return Promise.reject(new Error(t('assests.validateMsg.hostName_two'))) +@@ -102,6 +103,7 @@ function validateHostName(_rule: Rule, value: string) { + // form validate rules + const rules = computed>(() => ({ + host_name: [ ++ { required: true, message: t('assests.validateMsg.requireHostName'), trigger: 'blur' }, + { max: 50, message: t('assests.validateMsg.hostName'), trigger: 'blur' }, + { + validator: validateHostName, +diff --git a/src/views/execution/components/NewCommand.vue b/src/views/execution/components/NewCommand.vue +index e063c06..c36cfb1 100644 +--- a/src/views/execution/components/NewCommand.vue ++++ b/src/views/execution/components/NewCommand.vue +@@ -93,7 +93,8 @@ function validateTimeout(_rule: Rule, value: any) { + if (!value) { + return Promise.resolve() + } +- if (Number(value) < 1 || Number(value) > 86400) { ++ const val = Number(value) ++ if (val < 1 || val > 86400 || isNaN(val)) { + return Promise.reject(new Error(t('execution.command.validate.timeoutRange'))) + } + return Promise.resolve() +diff --git a/src/views/execution/components/NewScript.vue b/src/views/execution/components/NewScript.vue +index 1ea8ef5..642c412 100644 +--- a/src/views/execution/components/NewScript.vue ++++ b/src/views/execution/components/NewScript.vue +@@ -154,7 +154,8 @@ function validateTimeout(_rule: Rule, value: any): Promise { + if (!value) { + return Promise.resolve() + } +- if (Number(value) < 1 || Number(value) > 86400) { ++ const val = Number(value) ++ if (val < 1 || val > 86400 || isNaN(val)) { + return Promise.reject(new Error(t('execution.command.validate.timeoutRange'))) + } + return Promise.resolve() +-- +2.43.0.windows.1 + diff --git a/aops-hermes.spec b/aops-hermes.spec index 9db898a32860c98356a6cdf0b9143c8f23ab1879..18d9ff995cb6753aa9c74f293b961655114c73df 100644 --- a/aops-hermes.spec +++ b/aops-hermes.spec @@ -2,13 +2,14 @@ Name: aops-hermes Version: v2.0.1 -Release: 1 +Release: 2 Summary: Web for an intelligent diagnose frame License: MulanPSL2 URL: https://gitee.com/openeuler/%{name} Source0: %{name}-%{version}.tar.gz Source1: node_modules.tar.gz +Patch001: 0001-fix-input-validation-problem.patch BuildRequires: nodejs @@ -37,6 +38,11 @@ cp -r deploy/aops-hermes.service %{buildroot}/usr/lib/systemd/system/ %changelog +* Thu Oct 17 2024 Hugang <18768366022@163.com> - v2.0.1-2 +- Fixed the issue that the input format was not verified when creating commands and scripts with timeouts +- Fixed the issue in the cron expression selection plugin that caused a backend error when selecting conflicting categories of day and week +- Added some internationalized text + * Mon Oct 14 2024 Hugang <18768366022@163.com> - 2.0.1-1 - Integrated osmind