Harden cmd execution

This commit is contained in:
Fierelier 2024-02-17 09:50:15 +01:00
parent 063242f86c
commit 8ebad1735b
1 changed files with 5 additions and 0 deletions

View File

@ -4,6 +4,11 @@ APP_CMD="$(realpath "$(dirname "$BASH_SOURCE")/../app")"
APP_DIR="$(dirname "$APP_CMD")"
source "$APP_DIR/env"
if [ -f "$APP_DIR/cmd/$1" ]; then
if ! [[ "$(realpath "$APP_DIR/cmd/$1")" == "$APP_DIR/cmd/"* ]]; then
echo "ERROR: Action \"$1\" not found, use: \"$0\" help" >&2
exit 1
fi
source "$APP_DIR/cmd/$1"
exit 0
else