feat: add verify_app_name calls to all shell subcommands

Without this, folks could potentially run commands against invalid applications.
This commit is contained in:
Jose Diaz-Gonzalez
2020-12-25 01:45:35 -05:00
parent 03e80a76b6
commit fd162f8895
28 changed files with 17 additions and 32 deletions

View File

@@ -8,8 +8,7 @@ cmd-urls() {
declare cmd="url"
declare APP="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
get_app_urls "$@"
}

View File

@@ -34,7 +34,6 @@ cmd-certs-set() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" CRT_FILE="$2" KEY_FILE="$3"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"

View File

@@ -9,7 +9,6 @@ cmd-certs-generate() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"

View File

@@ -9,7 +9,6 @@ cmd-certs-remove() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"

View File

@@ -10,7 +10,6 @@ cmd-certs-show() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" KEY_TYPE="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"

View File

@@ -612,6 +612,7 @@ cmd-deploy() {
declare APP="$1" IMAGE_TAG="$2"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
verify_app_name "$APP"
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
plugn trigger scheduler-deploy "$DOKKU_SCHEDULER" "$APP" "$IMAGE_TAG"
}

View File

@@ -10,7 +10,6 @@ cmd-docker-options-clear() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" PHASES="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
if [[ -z "$PHASES" ]]; then

View File

@@ -10,8 +10,8 @@ cmd-domains-add() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN_NAME="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
verify_app_name "$APP"
domains_add "$@"
}

View File

@@ -10,7 +10,6 @@ cmd-domains-clear() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"

View File

@@ -10,7 +10,7 @@ cmd-domains-disable() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
domains_disable "$APP"
}

View File

@@ -10,7 +10,7 @@ cmd-domains-enable() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
domains_enable "$APP"
}

View File

@@ -10,8 +10,8 @@ cmd-domains-remove() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN_NAME="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
verify_app_name "$APP"
domains_remove "$@"
}

View File

@@ -10,8 +10,8 @@ cmd-domains-set() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" DOMAIN_NAME="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
verify_app_name "$APP"
domains_set "$@"
}

View File

@@ -10,7 +10,7 @@ cmd-domains-setup() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
domains_setup "$APP"
}

View File

@@ -10,7 +10,7 @@ cmd-git-initialize() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
is_valid_app_name "$APP"
verify_app_name "$APP"
dokku_log_info1_quiet "Initializing git repository for $APP"
fn-git-create-hook "$APP"
}

View File

@@ -10,8 +10,8 @@ cmd-git-set() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" KEY="$2" VALUE="$3"
local VALID_KEYS=("deploy-branch" "keep-git-dir" "rev-env-var")
verify_app_name "$APP"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then

View File

@@ -112,5 +112,6 @@ cmd-nginx-validate-config() {
fi
declare APP="$1" FLAG="$2"
verify_app_name "$APP"
validate_nginx "$APP" "$FLAG"
}

View File

@@ -6,9 +6,9 @@ source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
cmd-nginx-logs() {
declare desc="display app nginx logs from command line"
declare cmd="$1"
declare cmd="$1" APP="$2"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
nginx_logs "$@"
}

View File

@@ -8,9 +8,9 @@ cmd-nginx-build-config() {
declare cmd="nginx:build-config"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
verify_app_name "$APP"
dokku_log_warn "Deprecated: Please use proxy:build-config"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
local PROXY_APP_TYPE
PROXY_APP_TYPE="$(plugn trigger proxy-type "$APP")"

View File

@@ -10,8 +10,8 @@ cmd-nginx-set() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" KEY="$2" VALUE="$3"
local VALID_KEYS=("access-log-format" "access-log-path" "bind-address-ipv4" "bind-address-ipv6" "disable-custom-config" "error-log-path" "hsts" "hsts-include-subdomains" "hsts-preload" "hsts-max-age" "proxy-read-timeout" "proxy-buffer-size" "proxy-buffering" "proxy-buffers" "proxy-busy-buffers-size")
verify_app_name "$APP"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then

View File

@@ -10,8 +10,8 @@ cmd-scheduler-docker-local-set() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" KEY="$2" VALUE="$3"
local VALID_KEYS=("disable-chown")
verify_app_name "$APP"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then

View File

@@ -81,9 +81,8 @@ cmd-storage-list() {
declare cmd="storage:list"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
local passed_phases="deploy"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
dokku_log_quiet "$APP volume bind-mounts:"
get_bind_mounts "$(get_phase_file_path "$passed_phases")"

View File

@@ -12,9 +12,6 @@ cmd-storage-mount() {
declare APP="$1" MOUNT_PATH="$2"
local passed_phases=(deploy run)
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$MOUNT_PATH" ]] && dokku_log_fail "Please specify two paths delimited by colon."
verify_app_name "$APP"
verify_paths "$MOUNT_PATH"
check_if_path_exists "$MOUNT_PATH" "$(get_phase_file_path "${passed_phases[@]}")" && dokku_log_fail "Mount path already exists."

View File

@@ -12,8 +12,6 @@ cmd-storage-unmount() {
declare APP="$1" MOUNT_PATH="$2"
local passed_phases=(deploy run)
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
[[ -z "$MOUNT_PATH" ]] && dokku_log_fail "Please specify two paths delimited by colon."
verify_app_name "$APP"
verify_paths "$MOUNT_PATH"
check_if_path_exists "$MOUNT_PATH" "$(get_phase_file_path "${passed_phases[@]}")" || dokku_log_fail "Mount path does not exist."

View File

@@ -10,7 +10,6 @@ cmd-tags-create() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" IMAGE_TAG="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local IMAGE_REPO=$(get_app_image_repo "$APP")

View File

@@ -9,7 +9,6 @@ cmd-tags-default() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local IMAGE_REPO=$(get_app_image_repo "$APP")

View File

@@ -9,7 +9,6 @@ cmd-tags-deploy() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" IMAGE_TAG="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")"

View File

@@ -10,7 +10,6 @@ cmd-tags-destroy() {
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" IMAGE_TAG="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
local IMAGE_REPO=$(get_app_image_repo "$APP")