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:
1 parent
03e80a76b6
commit
fd162f8895
28 files changed
+17
-32
No files matched your search
@@ -8,8 +8,7 @@ cmd-urls() {
|
|||||||
declare cmd="url"
|
declare cmd="url"
|
||||||
declare APP="$2"
|
declare APP="$2"
|
||||||
|
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
verify_app_name "$APP"
|
||||||
|
|
||||||
get_app_urls "$@"
|
get_app_urls "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ cmd-certs-set() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" CRT_FILE="$2" KEY_FILE="$3"
|
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"
|
verify_app_name "$APP"
|
||||||
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ cmd-certs-generate() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" DOMAIN="$2"
|
declare APP="$1" DOMAIN="$2"
|
||||||
|
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ cmd-certs-remove() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ cmd-certs-show() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" KEY_TYPE="$2"
|
declare APP="$1" KEY_TYPE="$2"
|
||||||
|
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
local APP_SSL_PATH="$DOKKU_ROOT/$APP/tls"
|
||||||
|
|
||||||
|
|||||||
@@ -612,6 +612,7 @@ cmd-deploy() {
|
|||||||
declare APP="$1" IMAGE_TAG="$2"
|
declare APP="$1" IMAGE_TAG="$2"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
|
verify_app_name "$APP"
|
||||||
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
|
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
|
||||||
plugn trigger scheduler-deploy "$DOKKU_SCHEDULER" "$APP" "$IMAGE_TAG"
|
plugn trigger scheduler-deploy "$DOKKU_SCHEDULER" "$APP" "$IMAGE_TAG"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ cmd-docker-options-clear() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" PHASES="$2"
|
declare APP="$1" PHASES="$2"
|
||||||
|
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
|
|
||||||
if [[ -z "$PHASES" ]]; then
|
if [[ -z "$PHASES" ]]; then
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ cmd-domains-add() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" DOMAIN_NAME="$2"
|
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> ...]"
|
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
|
||||||
|
verify_app_name "$APP"
|
||||||
domains_add "$@"
|
domains_add "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ cmd-domains-clear() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ cmd-domains-disable() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$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"
|
domains_disable "$APP"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ cmd-domains-enable() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$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"
|
domains_enable "$APP"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ cmd-domains-remove() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" DOMAIN_NAME="$2"
|
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> ...]"
|
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
|
||||||
|
verify_app_name "$APP"
|
||||||
domains_remove "$@"
|
domains_remove "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ cmd-domains-set() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" DOMAIN_NAME="$2"
|
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> ...]"
|
[[ -z "$DOMAIN_NAME" ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 $2 <domain> [<domain> ...]"
|
||||||
|
verify_app_name "$APP"
|
||||||
domains_set "$@"
|
domains_set "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ cmd-domains-setup() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$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"
|
domains_setup "$APP"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ cmd-git-initialize() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
|
||||||
is_valid_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
dokku_log_info1_quiet "Initializing git repository for $APP"
|
dokku_log_info1_quiet "Initializing git repository for $APP"
|
||||||
fn-git-create-hook "$APP"
|
fn-git-create-hook "$APP"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ cmd-git-set() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" KEY="$2" VALUE="$3"
|
declare APP="$1" KEY="$2" VALUE="$3"
|
||||||
local VALID_KEYS=("deploy-branch" "keep-git-dir" "rev-env-var")
|
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"
|
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
|
||||||
|
|
||||||
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
||||||
|
|||||||
@@ -112,5 +112,6 @@ cmd-nginx-validate-config() {
|
|||||||
fi
|
fi
|
||||||
declare APP="$1" FLAG="$2"
|
declare APP="$1" FLAG="$2"
|
||||||
|
|
||||||
|
verify_app_name "$APP"
|
||||||
validate_nginx "$APP" "$FLAG"
|
validate_nginx "$APP" "$FLAG"
|
||||||
}
|
}
|
||||||
@@ -6,9 +6,9 @@ source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
|
|||||||
|
|
||||||
cmd-nginx-logs() {
|
cmd-nginx-logs() {
|
||||||
declare desc="display app nginx logs from command line"
|
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 "$@"
|
nginx_logs "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ cmd-nginx-build-config() {
|
|||||||
declare cmd="nginx:build-config"
|
declare cmd="nginx:build-config"
|
||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
verify_app_name "$APP"
|
||||||
dokku_log_warn "Deprecated: Please use proxy:build-config"
|
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
|
local PROXY_APP_TYPE
|
||||||
PROXY_APP_TYPE="$(plugn trigger proxy-type "$APP")"
|
PROXY_APP_TYPE="$(plugn trigger proxy-type "$APP")"
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ cmd-nginx-set() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" KEY="$2" VALUE="$3"
|
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")
|
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"
|
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
|
||||||
|
|
||||||
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ cmd-scheduler-docker-local-set() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" KEY="$2" VALUE="$3"
|
declare APP="$1" KEY="$2" VALUE="$3"
|
||||||
local VALID_KEYS=("disable-chown")
|
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"
|
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
|
||||||
|
|
||||||
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
||||||
|
|||||||
@@ -81,9 +81,8 @@ cmd-storage-list() {
|
|||||||
declare cmd="storage:list"
|
declare cmd="storage:list"
|
||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
|
||||||
local passed_phases="deploy"
|
local passed_phases="deploy"
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
dokku_log_quiet "$APP volume bind-mounts:"
|
dokku_log_quiet "$APP volume bind-mounts:"
|
||||||
get_bind_mounts "$(get_phase_file_path "$passed_phases")"
|
get_bind_mounts "$(get_phase_file_path "$passed_phases")"
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ cmd-storage-mount() {
|
|||||||
declare APP="$1" MOUNT_PATH="$2"
|
declare APP="$1" MOUNT_PATH="$2"
|
||||||
local passed_phases=(deploy run)
|
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_app_name "$APP"
|
||||||
verify_paths "$MOUNT_PATH"
|
verify_paths "$MOUNT_PATH"
|
||||||
check_if_path_exists "$MOUNT_PATH" "$(get_phase_file_path "${passed_phases[@]}")" && dokku_log_fail "Mount path already exists."
|
check_if_path_exists "$MOUNT_PATH" "$(get_phase_file_path "${passed_phases[@]}")" && dokku_log_fail "Mount path already exists."
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ cmd-storage-unmount() {
|
|||||||
declare APP="$1" MOUNT_PATH="$2"
|
declare APP="$1" MOUNT_PATH="$2"
|
||||||
local passed_phases=(deploy run)
|
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_app_name "$APP"
|
||||||
verify_paths "$MOUNT_PATH"
|
verify_paths "$MOUNT_PATH"
|
||||||
check_if_path_exists "$MOUNT_PATH" "$(get_phase_file_path "${passed_phases[@]}")" || dokku_log_fail "Mount path does not exist."
|
check_if_path_exists "$MOUNT_PATH" "$(get_phase_file_path "${passed_phases[@]}")" || dokku_log_fail "Mount path does not exist."
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ cmd-tags-create() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" IMAGE_TAG="$2"
|
declare APP="$1" IMAGE_TAG="$2"
|
||||||
|
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
|
|
||||||
local IMAGE_REPO=$(get_app_image_repo "$APP")
|
local IMAGE_REPO=$(get_app_image_repo "$APP")
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ cmd-tags-default() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1"
|
declare APP="$1"
|
||||||
|
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
|
|
||||||
local IMAGE_REPO=$(get_app_image_repo "$APP")
|
local IMAGE_REPO=$(get_app_image_repo "$APP")
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ cmd-tags-deploy() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" IMAGE_TAG="$2"
|
declare APP="$1" IMAGE_TAG="$2"
|
||||||
|
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
|
|
||||||
local IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")"
|
local IMAGE="$(get_app_image_name "$APP" "$IMAGE_TAG")"
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ cmd-tags-destroy() {
|
|||||||
[[ "$1" == "$cmd" ]] && shift 1
|
[[ "$1" == "$cmd" ]] && shift 1
|
||||||
declare APP="$1" IMAGE_TAG="$2"
|
declare APP="$1" IMAGE_TAG="$2"
|
||||||
|
|
||||||
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
||||||
verify_app_name "$APP"
|
verify_app_name "$APP"
|
||||||
|
|
||||||
local IMAGE_REPO=$(get_app_image_repo "$APP")
|
local IMAGE_REPO=$(get_app_image_repo "$APP")
|
||||||
|
|||||||
Reference in new issue
Block a user