Add Linux and macOS execution commands
Some checks failed
Repo Quality / structure (push) Has been cancelled
Some checks failed
Repo Quality / structure (push) Has been cancelled
This commit is contained in:
82
README.md
82
README.md
@@ -34,38 +34,104 @@ apps/ Espaço para app Spring Boot, agente AI e simulador BI
|
|||||||
- SQLcl, SQL*Plus ou outro cliente compatível.
|
- SQLcl, SQL*Plus ou outro cliente compatível.
|
||||||
- Acesso a uma versão de Oracle AI Database compatível com Deep Data Security.
|
- Acesso a uma versão de Oracle AI Database compatível com Deep Data Security.
|
||||||
|
|
||||||
## Execução Em 7 Passos
|
## Execucao Em 7 Passos
|
||||||
|
|
||||||
1. Clone o repositório.
|
1. Clone o repositorio.
|
||||||
2. Copie o arquivo de exemplo:
|
|
||||||
|
2. Copie o arquivo de exemplo.
|
||||||
|
|
||||||
|
Linux/macOS:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cp terraform/envs/demo/terraform.tfvars.example terraform/envs/demo/terraform.tfvars
|
cp terraform/envs/demo/terraform.tfvars.example terraform/envs/demo/terraform.tfvars
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Edite `terraform/envs/demo/terraform.tfvars` com seus OCIDs e região.
|
Windows PowerShell:
|
||||||
4. Valide a infraestrutura:
|
|
||||||
|
```powershell
|
||||||
|
Copy-Item terraform\envs\demo\terraform.tfvars.example terraform\envs\demo\terraform.tfvars
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Edite `terraform/envs/demo/terraform.tfvars` com seus OCIDs, regiao e parametros do banco.
|
||||||
|
|
||||||
|
Linux/macOS:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vi terraform/envs/demo/terraform.tfvars
|
||||||
|
```
|
||||||
|
|
||||||
|
Windows PowerShell:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
notepad terraform\envs\demo\terraform.tfvars
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Valide a infraestrutura.
|
||||||
|
|
||||||
|
Linux/macOS:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x scripts/*.sh
|
||||||
|
./scripts/validate-terraform.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Windows PowerShell:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
powershell -ExecutionPolicy Bypass -File .\scripts\validate-terraform.ps1
|
powershell -ExecutionPolicy Bypass -File .\scripts\validate-terraform.ps1
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Faça o deploy:
|
5. Faca o deploy.
|
||||||
|
|
||||||
|
Linux/macOS:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd terraform/envs/demo
|
cd terraform/envs/demo
|
||||||
terraform init
|
terraform init
|
||||||
terraform plan -out tfplan
|
terraform plan -out tfplan
|
||||||
terraform apply tfplan
|
terraform apply tfplan
|
||||||
|
cd ../../..
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Instale um cenário:
|
Windows PowerShell:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Set-Location terraform\envs\demo
|
||||||
|
terraform init
|
||||||
|
terraform plan -out tfplan
|
||||||
|
terraform apply tfplan
|
||||||
|
Set-Location ..\..\..
|
||||||
|
```
|
||||||
|
|
||||||
|
6. Instale um cenario.
|
||||||
|
|
||||||
|
Linux/macOS:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/run-scenario.sh 01-ai-prompt-injection "<connect_string>"
|
||||||
|
```
|
||||||
|
|
||||||
|
Windows PowerShell:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
powershell -ExecutionPolicy Bypass -File .\scripts\run-scenario.ps1 -Scenario 01-ai-prompt-injection -ConnectString "<connect_string>"
|
powershell -ExecutionPolicy Bypass -File .\scripts\run-scenario.ps1 -Scenario 01-ai-prompt-injection -ConnectString "<connect_string>"
|
||||||
```
|
```
|
||||||
|
|
||||||
7. Execute os testes descritos no `README.md` do cenário.
|
7. Execute testes e reset quando necessario.
|
||||||
|
|
||||||
|
Linux/macOS:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/run-scenario.sh 05-legacy-app-ai-extension "<connect_string>"
|
||||||
|
./scripts/reset-scenario.sh 05-legacy-app-ai-extension "<connect_string>"
|
||||||
|
```
|
||||||
|
|
||||||
|
Windows PowerShell:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
powershell -ExecutionPolicy Bypass -File .\scripts\run-scenario.ps1 -Scenario 05-legacy-app-ai-extension -ConnectString "<connect_string>"
|
||||||
|
powershell -ExecutionPolicy Bypass -File .\scripts\reset-scenario.ps1 -Scenario 05-legacy-app-ai-extension -ConnectString "<connect_string>"
|
||||||
|
```
|
||||||
|
|
||||||
## Segurança Por Padrão
|
## Segurança Por Padrão
|
||||||
|
|
||||||
|
|||||||
15
scripts/bootstrap.sh
Normal file
15
scripts/bootstrap.sh
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
echo "Checking local tools..."
|
||||||
|
|
||||||
|
for tool in git terraform; do
|
||||||
|
if command -v "$tool" >/dev/null 2>&1; then
|
||||||
|
echo "$tool found: $(command -v "$tool")"
|
||||||
|
else
|
||||||
|
echo "WARNING: $tool not found in PATH" >&2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Bootstrap check finished."
|
||||||
|
|
||||||
28
scripts/reset-scenario.sh
Normal file
28
scripts/reset-scenario.sh
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 <scenario> <connect_string> [sql_client]" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $# -lt 2 ]]; 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)"
|
||||||
|
RESET_SCRIPT="$REPO_ROOT/scenarios/$SCENARIO/sql/99_reset.sql"
|
||||||
|
|
||||||
|
if [[ ! -f "$RESET_SCRIPT" ]]; then
|
||||||
|
echo "Reset script not found: $RESET_SCRIPT" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Resetting scenario $SCENARIO"
|
||||||
|
"$SQL_CLIENT" "$CONNECT_STRING" "@$RESET_SCRIPT"
|
||||||
|
|
||||||
44
scripts/run-scenario.sh
Normal file
44
scripts/run-scenario.sh
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
23
scripts/validate-terraform.sh
Normal file
23
scripts/validate-terraform.sh
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ENVIRONMENT="${1:-demo}"
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
|
TF_DIR="$REPO_ROOT/terraform/envs/$ENVIRONMENT"
|
||||||
|
|
||||||
|
if [[ ! -d "$TF_DIR" ]]; then
|
||||||
|
echo "Terraform environment not found: $TF_DIR" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v terraform >/dev/null 2>&1; then
|
||||||
|
echo "Terraform is not installed or not in PATH. Install Terraform 1.6+ and rerun this script." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$TF_DIR"
|
||||||
|
terraform fmt -recursive -check
|
||||||
|
terraform init -backend=false
|
||||||
|
terraform validate
|
||||||
|
|
||||||
Reference in New Issue
Block a user