summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorMichal Ptacek <m.ptacek@partner.samsung.com>2019-03-26 14:29:55 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-26 14:29:55 +0000
commit47171a8dc441ae9526b74d210b88751cb7842c79 (patch)
treee05bf4ecaa8598910edff8109a3c133bb096f54b /build
parentfc7ca30540c2cd926346b27c9d4656272ca70e96 (diff)
parentfdf9798024a2c7f6c6cfc4199434376d0bcc3f7f (diff)
Merge "Sanitize input arguments validation"
Diffstat (limited to 'build')
-rwxr-xr-xbuild/package.sh22
1 files changed, 18 insertions, 4 deletions
diff --git a/build/package.sh b/build/package.sh
index c527db2e..a3c1ded2 100755
--- a/build/package.sh
+++ b/build/package.sh
@@ -31,6 +31,12 @@ crash () {
exit "${exit_code}"
}
+crash_arguments () {
+ echo "Missing some mandatory arguments!"
+ usage
+ exit 1
+}
+
usage () {
echo "Usage:"
echo " ./$(basename $0) <project_name> <version> <packaging_target_dir> [--conf <file>] [--force]"
@@ -200,16 +206,21 @@ APPLICATION_FILES_IN_PACKAGE="ansible/application"
# adjusted accordingly.
HELM_CHARTS_DIR_IN_PACKAGE="${APPLICATION_FILES_IN_PACKAGE}/helm_charts"
-if [ "$#" -lt 3 ]; then
- echo "Missing some mandatory arguments!"
- usage
- exit 1
+if [ $# -eq 0 ]; then
+ crash_arguments
fi
CONF_FILE=""
FORCE_REMOVE=0
+arg_ind=0
for arg in "$@"; do
shift
+ ((arg_ind+=1))
+ if [[ ${arg} =~ ^[-]{1,2}[a-zA-Z-]+$ && ${arg_ind} -lt 4 ]]; then
+ echo "Non-positional parameters should follow mandatory arguments!"
+ usage
+ exit 1
+ fi
case "$arg" in
-c|--conf)
CONF_FILE="$1" ;;
@@ -217,6 +228,9 @@ for arg in "$@"; do
FORCE_REMOVE=1 ;;
*)
set -- "$@" "$arg"
+ if [ "$#" -lt 3 ]; then
+ crash_arguments
+ fi ;;
esac
done