diff --git a/plugins/apps/functions b/plugins/apps/functions index 9cdd16b8c21..53756049141 100755 --- a/plugins/apps/functions +++ b/plugins/apps/functions @@ -4,6 +4,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" apps_create() { [[ -z $1 ]] && dokku_log_fail "Please specify an app to run the command on" + [[ ! "$1" =~ ^[a-z].* && ! "$1" =~ ^[0-9].* ]] && dokku_log_fail "App name must begin with lowercase alphanumeric character" [[ -d "$DOKKU_ROOT/$1" ]] && dokku_log_fail "Name is already taken" local APP="$1" diff --git a/plugins/common/functions b/plugins/common/functions index f2ed3a3a67e..8b18d18b5cd 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -121,6 +121,10 @@ dokku_container_log_verbose_quiet() { verify_app_name() { local APP="$1" [[ ! -n "$APP" ]] && dokku_log_fail "(verify_app_name) APP must not be null" + if [[ ! "$APP" =~ ^[a-z].* && ! "$APP" =~ ^[0-9].* ]]; then + [[ -d "$DOKKU_ROOT/$APP" ]] && rm -rf "$DOKKU_ROOT/$APP" + dokku_log_fail "App name must begin with lowercase alphanumeric character" + fi [[ ! -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "App $APP does not exist" return 0 diff --git a/tests/unit/10_apps.bats b/tests/unit/10_apps.bats index 587d562b47c..118bf95610e 100644 --- a/tests/unit/10_apps.bats +++ b/tests/unit/10_apps.bats @@ -17,6 +17,17 @@ load test_helper echo "status: "$status assert_success destroy_app + + run dokku apps:create 1994testapp + echo "output: "$output + echo "status: "$status + assert_success + dokku --force apps:destroy 1994testapp + + run dokku apps:create TestApp + echo "output: "$output + echo "status: "$status + assert_failure } @test "(apps) apps:destroy" {