代码拉取完成,页面将自动刷新
【问题复现步骤】
1、kbimg.sh脚本入参异常时未打印usage信息
[root@openEuler scripts]# bash kbimg.sh create pxe-image -p -d; echo $?
[ ERROR ] - Aug 19 2022 10:12:14 option not found
3
[root@openEuler scripts]# bash kbimg.sh create pxe-image -p /etc/yum.repos.d/euleros_9.82.201.30.repo -v v1 -b ../bin/os-agent -b -b; echo $?
[ ERROR ] - Aug 19 2022 10:23:15 option -e is mandatory, please check input
3
[root@openEuler scripts]# sh kbimg.sh create vm-image -p /etc/yum.repos.d -e '''$1$xyz$RdLyKTL32WEvK3lg8CXID0''' -v v1 -b ../bin/os-agent; echo $?
[ ERROR ] - Aug 19 2022 10:26:55 REPO path is invalid.
3
上述几种异常参数场景下未打印usage信息。其他异常参数场景会打印:
[root@openEuler scripts]# bash kbimg.sh create pxe-image -d; echo $?
[ ERROR ] - Aug 19 2022 10:11:48 the number of parameters is incorrect, please check it.
Usage : kbimg create pxe-image -p iso-path -v os-version -b os-agent-dir -e os-password
or
kbimg create pxe-image -d repository/name:tag
options:
-p repo path
-v KubeOS version
-b directory of os-agent binary
-e os encrypted password
-d docker image like repository/name:tag
-h,--help show help information
3
2、kbimg.sh脚本-b参数没有校验路径有效性
[root@openEuler scripts]# sh kbimg.sh create vm-image -p /etc/yum.repos.d/euleros_9.82.201.30.repo -e '''$1$xyz$RdLyKTL32WEvK3lg8CXID0''' -v v1 -b ../; echo $?
install package..
Unable to detect release version (use '--releasever' to specify release version)
Euler 7.9 MB/s | 3.4 MB 00:00
^Ceverything 14% [======- ] 761 kB/s | 2.4 MB 00:18 ETeverything 473 kB/s | 2.4 MB 00:05
Error: Failed to download metadata for repo 'everything': Librepo was interrupted by a signal
[ INFO ] - Aug 19 2022 10:25:17 Unmount /opt/kubeOS/scripts/rootfs/sys
[ INFO ] - Aug 19 2022 10:25:17 Unmount /opt/kubeOS/scripts/rootfs/proc
[ INFO ] - Aug 19 2022 10:25:17 Unmount /opt/kubeOS/scripts/rootfs/dev/pts
[ INFO ] - Aug 19 2022 10:25:18 Unmount /opt/kubeOS/scripts/rootfs/dev
1
当-b参数指向一个目录时,入参校验不会拦截。应该参考-p参数的处理方式,对目录、不存在的路径进行校验:
[root@openEuler scripts]# sh kbimg.sh create vm-image -p /etc/yum.repos.d -e '''$1$xyz$RdLyKTL32WEvK3lg8CXID0''' -v v1 -b ../bin/os-agent; echo $?
[ ERROR ] - Aug 19 2022 10:26:55 REPO path is invalid.
3
【预期结果】
1、参数校验异常导致的失败统一都打印usage信息
2、对-b参数的路径有效性进行校验,提前拦截不合理的路径
【实际结果】
见【问题复现步骤】中的描述
Hi oh_thats_great, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: sig-CloudNative, and any of the maintainers: @yangzhao_kl , @weibaohui , @biannm , @pixiake , @haomintsai , @Jianmin , @haozi007
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
登录 后才可以发表评论