From 4aae0f1a1da4d9f4182676e28c0bb8f3365e4364 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 17 Jun 2020 01:28:56 -0400 Subject: [PATCH] fix: do not allow slashes in app names There is likely a better regex for the actually allowed names, but this will suffice for ensuring folks don't do weird things with their folder structures... Closes #4013 --- plugins/common/common.go | 2 +- tests/unit/10_apps.bats | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/common/common.go b/plugins/common/common.go index ce60f3c47..f8d5ce8c1 100644 --- a/plugins/common/common.go +++ b/plugins/common/common.go @@ -582,7 +582,7 @@ func IsValidAppName(appName string) error { return fmt.Errorf("APP must not be null") } - r, _ := regexp.Compile("^[a-z0-9][^:A-Z]*$") + r, _ := regexp.Compile("^[a-z0-9][^/:A-Z]*$") if r.MatchString(appName) { return nil } diff --git a/tests/unit/10_apps.bats b/tests/unit/10_apps.bats index 82ce74dc4..1a19699db 100644 --- a/tests/unit/10_apps.bats +++ b/tests/unit/10_apps.bats @@ -81,6 +81,11 @@ teardown() { echo "status: $status" assert_failure + run /bin/bash -c "dokku apps:create test/app" + echo "output: $output" + echo "status: $status" + assert_failure + run /bin/bash -c "dokku --app $TEST_APP apps:create" echo "output: $output" echo "status: $status"