Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccd457a287 | ||
|
|
8a4f9f050b | ||
|
|
b03937036e | ||
|
|
211b48ce16 | ||
|
|
30ea310907 | ||
|
|
716277d550 |
No files matched your search
@@ -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 }}
|
||||||
@@ -13,46 +13,56 @@ if ($conn->connect_error) {
|
|||||||
die("Conexión fallida: " . $conn->connect_error);
|
die("Conexión fallida: " . $conn->connect_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vulnerabilidad de SQL Injection
|
// ejemplo Julian
|
||||||
// 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'])) {
|
// Corrección: Uso de sentencias preparadas para evitar SQL Injection
|
||||||
$id = $_GET['id']; // Input del usuario tomado directamente desde la URL
|
if (isset($_GET['id'])) {
|
||||||
// Validate that id is an integer (whitelist) before using it in a query
|
// Validar y sanitizar el parámetro 'id'
|
||||||
if (filter_var($id, FILTER_VALIDATE_INT) === false) {
|
$id_raw = $_GET['id'];
|
||||||
echo "Entrada 'id' inválida";
|
$id_valid = filter_var($id_raw, FILTER_VALIDATE_INT);
|
||||||
|
|
||||||
|
if ($id_valid === false) {
|
||||||
|
// El id no es un entero válido
|
||||||
|
echo "ID inválido";
|
||||||
} else {
|
} else {
|
||||||
$id = (int)$id;
|
$id = (int) $id_valid;
|
||||||
// Use a prepared statement to avoid SQL injection
|
|
||||||
$stmt = $conn->prepare("SELECT * FROM usuarios WHERE id = ?");
|
// Preparar la sentencia para evitar inyección SQL
|
||||||
if ($stmt) {
|
$stmt = $conn->prepare("SELECT id, nombre FROM usuarios WHERE id = ?");
|
||||||
|
if ($stmt === false) {
|
||||||
|
// Error en la preparación
|
||||||
|
error_log("Fallo al preparar la consulta: " . $conn->error);
|
||||||
|
echo "Error en la consulta";
|
||||||
|
} else {
|
||||||
$stmt->bind_param("i", $id);
|
$stmt->bind_param("i", $id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$result = $stmt->get_result();
|
|
||||||
|
|
||||||
if ($result === false) {
|
// Obtener resultados usando bind_result para mayor compatibilidad
|
||||||
echo "Error en la consulta";
|
$stmt->bind_result($res_id, $res_nombre);
|
||||||
} else {
|
|
||||||
if ($result->num_rows > 0) {
|
$hasResults = false;
|
||||||
while($row = $result->fetch_assoc()) {
|
while ($stmt->fetch()) {
|
||||||
echo "id: " . $row["id"]. " - Nombre: " . $row["nombre"]. "<br>";
|
$hasResults = true;
|
||||||
}
|
// Escapar la salida para prevenir XSS
|
||||||
} else {
|
$safe_nombre = htmlspecialchars($res_nombre, ENT_QUOTES, 'UTF-8');
|
||||||
echo "0 resultados";
|
$safe_id = htmlspecialchars((string)$res_id, ENT_QUOTES, 'UTF-8');
|
||||||
}
|
echo "id: " . $safe_id . " - Nombre: " . $safe_nombre . "<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $hasResults) {
|
||||||
|
echo "0 resultados";
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
} else {
|
|
||||||
echo "Error al preparar la consulta";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Corregir vulnerabilidad XSS al mostrar 'mensaje'
|
||||||
// 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
|
$safe_mensaje = htmlspecialchars($mensaje, ENT_QUOTES, 'UTF-8');
|
||||||
|
echo "<div>" . $safe_mensaje . "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cerrar conexión
|
// Cerrar conexión
|
||||||
|
|||||||
Reference in new issue
Block a user