Compare commits

..
Author SHA1 Message Date
PlexicusAI b29ecdaaac SQL Injection 2026-01-28 20:23:58 +00:00
Jose Ramon Palanco 8a4f9f050b Delete .github/workflows/plexalyzer-scan.yaml 2025-06-11 08:46:42 +02:00
Jose Ramon Palanco b03937036e Merge pull request #160 from plexicus/Plexicus-Workflow-Integration
Plexalyzer Workflow Integration by Plexicus
2025-06-11 08:37:57 +02:00
PlexicusAI 211b48ce16 Plexalyzer Workflow Integration by Plexicus 2025-06-11 06:36:41 +00:00
Irvine Pramudya 30ea310907 Merge pull request #87 from plexicus/Plexicus-Workflow-Integration
Plexalyzer Workflow Integration by Plexicus
2025-01-18 00:47:45 +07:00
PlexicusAI 716277d550 Plexalyzer Workflow Integration by Plexicus 2025-01-14 11:27:03 +00:00
2 changed files with 60 additions and 14 deletions

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
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 }}
+24 -14
View File
@@ -13,35 +13,45 @@ if ($conn->connect_error) {
die("Conexión fallida: " . $conn->connect_error); die("Conexión fallida: " . $conn->connect_error);
} }
// Vulnerabilidad de SQL Injection (corregida) /*
// Se utiliza una consulta preparada para evitar SQL Injection. Brief analysis - ALEX:
This change fixes a SQL Injection vulnerability by using a parameterized prepared statement and strict validation of the 'id' parameter.
I will replace the concatenated SQL with a mysqli prepared statement binding the id as an integer; only index.php is modified.
*/
if(isset($_GET['id'])) { if(isset($_GET['id'])) {
$id = $_GET['id']; // Input del usuario tomado directamente desde la URL $id = $_GET['id']; // Input del usuario tomado directamente desde la URL
// Preparar la consulta con un marcador de posición
$stmt = $conn->prepare("SELECT * FROM usuarios WHERE id = ?"); // Whitelist/validate: allow only digits to prevent injection
if ($stmt === false) { if (!preg_match('/^\d+$/', $id)) {
die("Error en la preparación de la consulta: " . $conn->error); echo "Invalid id";
} } else {
// Vincular el parámetro (tipo 'i' para entero) $id_int = (int)$id;
$stmt->bind_param("i", $id);
// Ejecutar la consulta // Use a prepared statement to avoid SQL injection
$stmt = $conn->prepare("SELECT id, nombre FROM usuarios WHERE id = ?");
if ($stmt) {
$stmt->bind_param("i", $id_int);
$stmt->execute(); $stmt->execute();
// Obtener el resultado
$result = $stmt->get_result(); $result = $stmt->get_result();
if ($result->num_rows > 0) { if ($result && $result->num_rows > 0) {
while($row = $result->fetch_assoc()) { while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Nombre: " . $row["nombre"]. "<br>"; echo "id: " . $row["id"]. " - Nombre: " . $row["nombre"]. "<br>";
} }
} else { } else {
echo "0 resultados"; echo "0 resultados";
} }
// Cerrar la sentencia
$stmt->close(); $stmt->close();
} else {
// Do not execute an unsafe query if prepare() failed
echo "Query preparation failed";
}
}
} }
// Vulnerabilidad de Cross-Site Scripting (XSS)
// 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'])) { if(isset($_GET['mensaje'])) {
$mensaje = $_GET['mensaje']; // Input del usuario susceptible a XSS $mensaje = $_GET['mensaje']; // Input del usuario susceptible a XSS
echo "<div>$mensaje</div>"; // Vulnerable a XSS echo "<div>$mensaje</div>"; // Vulnerable a XSS