Files
oracle-deep-data-security-lab/scripts/run-scenario.sh
Rodrigo Pace 97cab6d894
Some checks failed
Repo Quality / structure (push) Has been cancelled
Add Linux and macOS execution commands
2026-05-08 12:25:51 -03:00

45 lines
1.0 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
usage() {
echo "Usage: $0 <scenario> [connect_string] [sql_client]" >&2
echo "Example: $0 01-ai-prompt-injection 'admin/password@db_high' sql" >&2
}
if [[ $# -lt 1 ]]; then
usage
exit 1
fi
SCENARIO="$1"
CONNECT_STRING="${2:-}"
SQL_CLIENT="${3:-sql}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
SQL_DIR="$REPO_ROOT/scenarios/$SCENARIO/sql"
if [[ ! -d "$SQL_DIR" ]]; then
echo "Scenario SQL directory not found: $SQL_DIR" >&2
exit 1
fi
mapfile -t SCRIPTS < <(find "$SQL_DIR" -maxdepth 1 -type f -name "*.sql" ! -name "99_reset.sql" | sort)
echo "Scenario: $SCENARIO"
echo "Scripts to execute:"
for script in "${SCRIPTS[@]}"; do
echo " - $(basename "$script")"
done
if [[ -z "$CONNECT_STRING" ]]; then
echo "WARNING: Connect string not provided. Review the SQL files above and execute them manually with SQLcl or SQL*Plus." >&2
exit 0
fi
for script in "${SCRIPTS[@]}"; do
echo "Running $script"
"$SQL_CLIENT" "$CONNECT_STRING" "@$script"
done