10 Star 0 Fork 12

src-openEuler / KubeOS

 / 详情

1、kbimg.sh脚本入参异常时未打印usage信息;2、kbimg.sh脚本-b参数没有校验路径有效性

已完成
缺陷
创建于  
2022-08-19 10:29

【问题复现步骤】
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参数的路径有效性进行校验,提前拦截不合理的路径
【实际结果】
见【问题复现步骤】中的描述

评论 (1)

哦那真是一级棒 创建了缺陷

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

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
5329419 openeuler ci bot 1632792936
1
https://gitee.com/src-openeuler/KubeOS.git
git@gitee.com:src-openeuler/KubeOS.git
src-openeuler
KubeOS
KubeOS

搜索帮助