Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8441834cae | ||
|
|
0cf50dc6f3 | ||
|
|
acd11d16ce | ||
|
|
d1b0b9476b |
No files matched your search
@@ -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 }}
|
||||
@@ -13,56 +13,39 @@ if ($conn->connect_error) {
|
||||
die("Conexión fallida: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// ejemplo Julian
|
||||
// Vulnerabilidad de SQL Injection
|
||||
// Este bloque ha sido corregido: se valida/castea el id, se usa sentencia preparada y se codifica la salida para mitigar SQLi y XSS.
|
||||
if(isset($_GET['id'])) {
|
||||
$id = $_GET['id']; // Input del usuario tomado directamente desde la URL
|
||||
|
||||
// Corrección: Uso de sentencias preparadas para evitar SQL Injection
|
||||
if (isset($_GET['id'])) {
|
||||
// Validar y sanitizar el parámetro 'id'
|
||||
$id_raw = $_GET['id'];
|
||||
$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";
|
||||
// Validar que el id contiene sólo dígitos (evita inyección y coerción de tipo)
|
||||
if (!ctype_digit($id)) {
|
||||
echo "Parámetro inválido.";
|
||||
} else {
|
||||
$id = (int) $id_valid;
|
||||
|
||||
// Preparar la sentencia para evitar inyección SQL
|
||||
// Usar prepared statement para evitar SQL Injection
|
||||
$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);
|
||||
$int_id = (int)$id;
|
||||
$stmt->bind_param("i", $int_id);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
// Obtener resultados usando bind_result para mayor compatibilidad
|
||||
$stmt->bind_result($res_id, $res_nombre);
|
||||
|
||||
$hasResults = false;
|
||||
while ($stmt->fetch()) {
|
||||
$hasResults = true;
|
||||
// Escapar la salida para prevenir XSS
|
||||
$safe_nombre = htmlspecialchars($res_nombre, ENT_QUOTES, 'UTF-8');
|
||||
$safe_id = htmlspecialchars((string)$res_id, ENT_QUOTES, 'UTF-8');
|
||||
echo "id: " . $safe_id . " - Nombre: " . $safe_nombre . "<br>";
|
||||
if ($result && $result->num_rows > 0) {
|
||||
while($row = $result->fetch_assoc()) {
|
||||
// Codificar la salida para prevenir XSS
|
||||
echo "id: " . htmlspecialchars($row["id"], ENT_QUOTES, 'UTF-8') . " - Nombre: " . htmlspecialchars($row["nombre"], ENT_QUOTES, 'UTF-8') . "<br>";
|
||||
}
|
||||
|
||||
if (! $hasResults) {
|
||||
} else {
|
||||
echo "0 resultados";
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Corregir vulnerabilidad XSS al mostrar 'mensaje'
|
||||
if (isset($_GET['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'])) {
|
||||
$mensaje = $_GET['mensaje']; // Input del usuario susceptible a XSS
|
||||
$safe_mensaje = htmlspecialchars($mensaje, ENT_QUOTES, 'UTF-8');
|
||||
echo "<div>" . $safe_mensaje . "</div>";
|
||||
echo "<div>$mensaje</div>"; // Vulnerable a XSS
|
||||
}
|
||||
|
||||
// Cerrar conexión
|
||||
|
||||
Reference in new issue
Block a user