Compare commits

..
Author SHA1 Message Date
PlexicusAI 1f16492f44 SQL Injection 2025-12-11 11:17:19 +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 75 additions and 25 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 }}
+39 -25
View File
@@ -9,41 +9,55 @@ $dbname = "tu_base_de_datos";
$conn = new mysqli($servername, $username, $password, $dbname); $conn = new mysqli($servername, $username, $password, $dbname);
// Verificar conexión // Verificar conexión
// mi personalizacuin
if ($conn->connect_error) { if ($conn->connect_error) {
die("Conexión fallida: " . $conn->connect_error); // No exponer detalles de la conexión al usuario. Registrar el error y mostrar un mensaje genérico.
error_log("Conexión fallida: " . $conn->connect_error);
die("Error de conexión a la base de datos.");
} }
// Vulnerabilidad de SQL Injection // Manejo seguro de entrada para evitar 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']; // Entrada del usuario
// Analysis: Fix SQL Injection by using a prepared statement with parameter binding.
// This prevents user-controlled input from altering the query structure. // Validar que el id sea numérico (whitelist): solo dígitos permitidos
$id = intval($_GET['id']); // Input del usuario tomado directamente desde la URL (cast to int) if (!preg_match('/^\d+$/', $id_raw)) {
// Use prepared statement to prevent SQL injection // Entrada no válida
$stmt = $conn->prepare("SELECT * FROM usuarios WHERE id = ?"); echo "ID inválido";
if ($stmt) {
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
} else { } else {
// If prepare fails, preserve behavior by setting $result to false $id = (int)$id_raw;
$result = false;
}
if ($result->num_rows > 0) { // Preparar la consulta usando sentencias preparadas y enlazado de parámetros
while($row = $result->fetch_assoc()) { $stmt = $conn->prepare("SELECT id, nombre FROM usuarios WHERE id = ?");
if ($stmt) {
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
if ($result && $result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
// Escapar la salida para prevenir XSS también en datos provenientes de la BD
$safe_id = htmlspecialchars($row['id'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
$safe_nombre = htmlspecialchars($row['nombre'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
echo "id: " . $safe_id . " - Nombre: " . $safe_nombre . "<br>";
}
} else {
echo "0 resultados";
}
$stmt->close();
} else {
// Registrar el error para auditoría sin exponer detalles al usuario
error_log("Prepare failed: " . $conn->error);
echo "Ocurrió un error al procesar la solicitud.";
} }
} else {
echo "0 resultados";
} }
} }
// Vulnerabilidad de Cross-Site Scripting (XSS) // Evitar XSS en parámetros de texto simples: escapar antes de imprimir
// 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'];
$mensaje = $_GET['mensaje']; // Input del usuario susceptible a XSS echo "<div>" . htmlspecialchars($mensaje, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') . "</div>";
echo "<div>$mensaje</div>"; // Vulnerable a XSS
} }
// Cerrar conexión // Cerrar conexión