Compare commits

..
Author SHA1 Message Date
PlexicusAI 5671f0cd94 SQL Injection 2026-03-04 20:27:35 +00:00
JuanJoseFlorez 0cf50dc6f3 Revert "Plexalyzer Workflow Integration by Plexicus"
This reverts commit d1b0b9476b.
2025-02-07 16:48:49 -05:00
Juan José Florez acd11d16ce Merge pull request #104 from plexicus/Plexicus-Workflow-Integration
Plexalyzer Workflow Integration by Plexicus
2025-02-07 16:40:13 -05:00
PlexicusAI d1b0b9476b Plexalyzer Workflow Integration by Plexicus 2025-02-07 21:38:04 +00:00
2 changed files with 25 additions and 58 deletions

No files matched your search

-36
View File
@@ -1,36 +0,0 @@
name: PLEXALYZER Analysis
on:
pull_request:
types: [opened, synchronize]
jobs:
analyze:
if: ${{ !startsWith(github.head_ref, 'Plexicus-AI-Remediation-') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Changed Files and Save to File
id: get_changed_files
shell: bash
run: |
# Capture changed files and save to a temporary file
changed_files=$(git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}")
echo "$changed_files" | jq -R -s -c 'split("\n")[:-1]' > files_to_scan.json
echo "files_path=$(pwd)/files_to_scan.json" >> $GITHUB_ENV
- name: Run PLEXALYZER Analysis
uses: plexicus/plexicus-action@dev
with:
plexalyzer-token: ${{ secrets.PLEXALYZER_TOKEN }}
default-owner: ${{ github.event.repository.owner.login }}
repo-id: ${{ vars.COVULOR_REPO_ID }}
repo-name: ${{ github.repository }}
branch: ${{ github.event.pull_request.base.ref }}
url: ${{ github.event.repository.clone_url }}
pr-id: ${{ github.event.pull_request.number }}
files-path: ${{ env.files_path }}
workspace-path: ${{ github.workspace }}
+25 -22
View File
@@ -13,41 +13,44 @@ if ($conn->connect_error) {
die("Conexión fallida: " . $conn->connect_error); die("Conexión fallida: " . $conn->connect_error);
} }
// Mitigación: uso de prepared statements y validación de entrada // Vulnerabilidad de SQL Injection
// El siguiente código es vulnerable a SQL Injection ya que el input del usuario se concatena directamente en la consulta SQL sin validación o sanitización.
if(isset($_GET['id'])) { if(isset($_GET['id'])) {
$id_raw = $_GET['id']; // Tomar y validar el parámetro 'id' como entero
// Validar que el id es un entero $raw_id = $_GET['id']; // Input del usuario tomado directamente desde la URL
if (filter_var($id_raw, FILTER_VALIDATE_INT) === false) { $id = filter_var($raw_id, FILTER_VALIDATE_INT);
echo "ID inválido"; if ($id === false) {
// Parámetro no válido: no ejecutar la consulta y devolver un mensaje genérico
echo "Parámetro 'id' inválido";
} else { } else {
$id = (int)$id_raw; // Uso de prepared statement para evitar SQL Injection
// Preparar consulta con parámetros y seleccionar columnas específicas $stmt = $conn->prepare("SELECT id, nombre FROM usuarios WHERE id = ?");
if ($stmt = $conn->prepare("SELECT id, nombre FROM usuarios WHERE id = ?")) { if ($stmt) {
$stmt->bind_param("i", $id); $stmt->bind_param("i", $id);
$stmt->execute(); $stmt->execute();
$stmt->bind_result($res_id, $res_nombre); $result = $stmt->get_result();
$found = false;
while ($stmt->fetch()) { if ($result && $result->num_rows > 0) {
$found = true; while($row = $result->fetch_assoc()) {
// Escapar salida para prevenir XSS echo "id: " . $row["id"]. " - Nombre: " . $row["nombre"]. "<br>";
echo "id: " . htmlspecialchars($res_id, ENT_QUOTES, 'UTF-8') . " - Nombre: " . htmlspecialchars($res_nombre, ENT_QUOTES, 'UTF-8') . "<br>";
} }
if (!$found) { } else {
echo "0 resultados"; echo "0 resultados";
} }
$stmt->close(); $stmt->close();
} else { } else {
// No revelar detalles internos al usuario // No exponer detalles internos en caso de error
echo "Error en la consulta"; echo "Error en la consulta.";
} }
} }
} }
// Mitigación de Cross-Site Scripting (XSS) // Vulnerabilidad de Cross-Site Scripting (XSS)
// Escapar la salida del mensaje para evitar ejecución de HTML/JS // El siguiente código es vulnerable a XSS ya que imprime directamente en el HTML el contenido de una variable que puede ser manipulada por el usuario sin ninguna sanitización.
if(isset($_GET['mensaje'])) {
$mensaje = $_GET['mensaje']; $mensaje = $_GET['mensaje']; // Input del usuario susceptible a XSS
echo "<div>" . htmlspecialchars($mensaje, ENT_QUOTES, 'UTF-8') . "</div>"; echo "<div>$mensaje</div>"; // Vulnerable a XSS
} }
// Cerrar conexión // Cerrar conexión