Ajuste peticiones API y paginacion
This commit is contained in:
1 parent
6221817400
commit
5487b994c1
5 files changed
+728
-40
No files matched your search
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
docker build --no-cache -t harbor-security-portal .
|
||||||
+508
@@ -0,0 +1,508 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es" class="h-full bg-slate-950 text-slate-100">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Portal de Seguridad Harbor - Inspector de Vulnerabilidades y SBOM</title>
|
||||||
|
<script src="assets/js/tailwindcss.js"></script>
|
||||||
|
<link rel="stylesheet" href="assets/css/fontawesome.all.min.css">
|
||||||
|
<script>
|
||||||
|
tailwind.config = {
|
||||||
|
theme: {
|
||||||
|
extend: {
|
||||||
|
fontFamily: { sans: ['system-ui', '-apple-system', 'sans-serif'], mono: ['ui-monospace', 'monospace'] },
|
||||||
|
colors: { harbor: { bg: '#0F172A', card: '#1E293B', border: '#334155', accent: '#0EA5E9' } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body class="h-full font-sans antialiased bg-slate-950 text-slate-200 flex flex-col">
|
||||||
|
|
||||||
|
<header class="bg-slate-900 border-b border-slate-800 px-6 py-4 flex flex-wrap items-center justify-between gap-4 sticky top-0 z-30 shadow-lg">
|
||||||
|
<div class="flex items-center space-x-4">
|
||||||
|
<div class="bg-sky-500/10 p-2.5 rounded-lg border border-sky-500/20 text-sky-400">
|
||||||
|
<i class="fa-solid fa-shield-halved text-2xl"></i>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h1 class="text-xl font-bold tracking-tight text-white flex items-center gap-2">
|
||||||
|
Portal de Seguridad Harbor
|
||||||
|
<span class="text-xs font-normal px-2.5 py-0.5 rounded-full bg-sky-500/10 text-sky-400 border border-sky-500/20">API v2.0 Live</span>
|
||||||
|
</h1>
|
||||||
|
<p class="text-xs text-slate-400">Inspector Centralizado de Vulnerabilidades vía API</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center space-x-3">
|
||||||
|
<div id="connection-badge" class="flex items-center space-x-2 bg-amber-500/10 border border-amber-500/20 text-amber-400 px-3 py-1.5 rounded-md text-xs font-medium">
|
||||||
|
<span id="connection-dot" class="w-2 h-2 rounded-full bg-amber-400 animate-pulse"></span>
|
||||||
|
<span id="connection-status-text">Sin Autenticar</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Botón de Exportar a Excel (CSV) -->
|
||||||
|
<button onclick="exportToCsv()" class="flex items-center space-x-2 bg-slate-800 hover:bg-slate-700 text-slate-200 border border-slate-700 px-3.5 py-2 rounded-lg text-sm font-medium transition">
|
||||||
|
<i class="fa-solid fa-file-excel text-emerald-400"></i>
|
||||||
|
<span>Exportar Excel</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button onclick="openConfigModal()" class="flex items-center space-x-2 bg-slate-800 hover:bg-slate-700 text-slate-200 border border-slate-700 px-3.5 py-2 rounded-lg text-sm font-medium transition">
|
||||||
|
<i class="fa-solid fa-key text-sky-400"></i>
|
||||||
|
<span>Credenciales</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="flex-1 w-full px-4 sm:px-6 lg:px-8 py-6 space-y-6">
|
||||||
|
<!-- Métricas Globales (Summary) -->
|
||||||
|
<div class="grid grid-cols-2 md:grid-cols-5 gap-4">
|
||||||
|
<div class="bg-slate-900 border border-slate-800 p-4 rounded-xl flex items-center justify-between">
|
||||||
|
<div><p class="text-xs text-slate-400 uppercase font-semibold">Total CVEs</p><p id="count-total" class="text-2xl font-bold text-white mt-1">0</p></div>
|
||||||
|
<div class="p-3 bg-slate-800 rounded-lg text-slate-400"><i class="fa-solid fa-bug text-xl"></i></div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-slate-900 border border-red-500/20 p-4 rounded-xl flex items-center justify-between">
|
||||||
|
<div><p class="text-xs text-red-400 uppercase font-semibold">Críticas</p><p id="count-critical" class="text-2xl font-bold text-red-400 mt-1">0</p></div>
|
||||||
|
<div class="p-3 bg-red-500/10 rounded-lg text-red-400"><i class="fa-solid fa-triangle-exclamation text-xl"></i></div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-slate-900 border border-orange-500/20 p-4 rounded-xl flex items-center justify-between">
|
||||||
|
<div><p class="text-xs text-orange-400 uppercase font-semibold">Altas</p><p id="count-high" class="text-2xl font-bold text-orange-400 mt-1">0</p></div>
|
||||||
|
<div class="p-3 bg-orange-500/10 rounded-lg text-orange-400"><i class="fa-solid fa-radiation text-xl"></i></div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-slate-900 border border-yellow-500/20 p-4 rounded-xl flex items-center justify-between">
|
||||||
|
<div><p class="text-xs text-yellow-400 uppercase font-semibold">Medias</p><p id="count-medium" class="text-2xl font-bold text-yellow-400 mt-1">0</p></div>
|
||||||
|
<div class="p-3 bg-yellow-500/10 rounded-lg text-yellow-400"><i class="fa-solid fa-circle-exclamation text-xl"></i></div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-slate-900 border border-blue-500/20 p-4 rounded-xl flex items-center justify-between col-span-2 md:col-span-1">
|
||||||
|
<div><p class="text-xs text-blue-400 uppercase font-semibold">Bajas</p><p id="count-low" class="text-2xl font-bold text-blue-400 mt-1">0</p></div>
|
||||||
|
<div class="p-3 bg-blue-500/10 rounded-lg text-blue-400"><i class="fa-solid fa-circle-info text-xl"></i></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Panel de Filtros API -->
|
||||||
|
<div class="bg-slate-900 border border-slate-800 rounded-xl p-5 shadow-sm space-y-4">
|
||||||
|
<h2 class="text-lg font-semibold text-white flex items-center gap-2 border-b border-slate-800 pb-3">
|
||||||
|
<i class="fa-solid fa-filter text-sky-400"></i> Búsqueda Directa en API de Harbor (/security/vul)
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div class="flex flex-col md:flex-row items-stretch md:items-center gap-4">
|
||||||
|
<div class="w-full md:w-64 flex-shrink-0">
|
||||||
|
<label class="block text-xs font-medium text-slate-400 mb-1">Filter by</label>
|
||||||
|
<select id="filter-type" onchange="onFilterTypeChange()" class="w-full bg-slate-800 border border-slate-700 text-slate-200 text-sm rounded-lg p-2.5 outline-none">
|
||||||
|
<option value="All">All</option>
|
||||||
|
<option value="Severity">Severity</option>
|
||||||
|
<option value="CVE ID">CVE ID</option>
|
||||||
|
<option value="CVSS3">CVSS3 (Rango)</option>
|
||||||
|
<option value="Repository Name">Repository Name</option>
|
||||||
|
<option value="Package">Package</option>
|
||||||
|
<option value="Digest">Digest</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex-1" id="filter-input-container">
|
||||||
|
<!-- Dinámico -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-end gap-2 pt-5 md:pt-0">
|
||||||
|
<button onclick="applyFilters(1)" class="bg-sky-500 hover:bg-sky-600 text-white font-semibold text-sm px-6 py-2.5 rounded-lg flex items-center gap-2 transition shadow-md">
|
||||||
|
<i id="search-btn-icon" class="fa-solid fa-magnifying-glass"></i>
|
||||||
|
<span>SEARCH API</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Tabla -->
|
||||||
|
<div class="bg-slate-900 border border-slate-800 rounded-xl overflow-hidden shadow-lg">
|
||||||
|
<div class="p-4 border-b border-slate-800 flex flex-wrap justify-between items-center gap-4 bg-slate-900/50">
|
||||||
|
<span class="text-sm font-medium text-slate-400">Registros en página actual: <span id="results-count" class="text-white font-bold">0</span></span>
|
||||||
|
|
||||||
|
<div class="flex items-center space-x-2 text-sm text-slate-400">
|
||||||
|
<span>Mostrar:</span>
|
||||||
|
<select id="page-size-select" onchange="changePageSize()" class="bg-slate-800 border border-slate-700 text-slate-200 text-xs rounded-lg px-2.5 py-1.5 outline-none font-semibold">
|
||||||
|
<option value="10" selected>10</option>
|
||||||
|
<option value="20">20</option>
|
||||||
|
<option value="50">50</option>
|
||||||
|
<option value="100">100</option>
|
||||||
|
</select>
|
||||||
|
<span>por página</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="overflow-x-auto">
|
||||||
|
<table class="w-full text-left text-sm text-slate-300">
|
||||||
|
<thead class="bg-slate-950 text-xs uppercase text-slate-400 font-semibold border-b border-slate-800">
|
||||||
|
<tr>
|
||||||
|
<th class="px-4 py-3.5">CVE ID</th>
|
||||||
|
<th class="px-4 py-3.5">Severidad</th>
|
||||||
|
<th class="px-4 py-3.5">Paquete Afectado</th>
|
||||||
|
<th class="px-4 py-3.5">Proyecto</th>
|
||||||
|
<th class="px-4 py-3.5">Repositorio</th>
|
||||||
|
<th class="px-4 py-3.5">Tag / Digest</th>
|
||||||
|
<th class="px-4 py-3.5 text-center">CVSS3</th>
|
||||||
|
<th class="px-4 py-3.5 text-right">Acciones</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="vulnerabilities-tbody" class="divide-y divide-slate-800/60"></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div id="empty-state" class="py-16 text-center space-y-4">
|
||||||
|
<div class="inline-flex items-center justify-center w-16 h-16 rounded-full bg-slate-800 text-slate-400 mb-2"><i class="fa-solid fa-magnifying-glass text-2xl"></i></div>
|
||||||
|
<h3 class="text-lg font-medium text-slate-300">Realiza una búsqueda para consultar la API</h3>
|
||||||
|
<p class="text-sm text-slate-500">Selecciona un filtro superior y pulsa SEARCH API.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Controles de Paginación -->
|
||||||
|
<div class="p-4 border-t border-slate-800 flex items-center justify-between bg-slate-900/50">
|
||||||
|
<span class="text-sm text-slate-400">
|
||||||
|
Página <span id="current-page-label" class="text-white font-bold">1</span>
|
||||||
|
</span>
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<button onclick="changePage(-1)" id="prev-page-btn" class="bg-slate-800 hover:bg-slate-700 text-slate-300 border border-slate-700 px-3 py-1.5 rounded-lg text-xs font-medium transition disabled:opacity-50 disabled:cursor-not-allowed">
|
||||||
|
<i class="fa-solid fa-chevron-left mr-1"></i> Anterior
|
||||||
|
</button>
|
||||||
|
<button onclick="changePage(1)" id="next-page-btn" class="bg-slate-800 hover:bg-slate-700 text-slate-300 border border-slate-700 px-3 py-1.5 rounded-lg text-xs font-medium transition">
|
||||||
|
Siguiente <i class="fa-solid fa-chevron-right ml-1"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<!-- Modal Config (Conectar) -->
|
||||||
|
<div id="config-modal" class="fixed inset-0 z-50 bg-slate-950/80 backdrop-blur-sm hidden flex items-center justify-center p-4">
|
||||||
|
<div class="bg-slate-900 border border-slate-800 rounded-xl w-full max-w-lg shadow-2xl p-6 space-y-5">
|
||||||
|
<h3 class="text-lg font-bold text-white flex items-center gap-2"><i class="fa-solid fa-key text-sky-400"></i> Autenticación Harbor</h3>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div><label class="block text-xs text-slate-400 mb-1">Usuario</label><input type="text" id="config-harbor-user" class="w-full bg-slate-800 border border-slate-700 text-sm rounded-lg p-2.5 outline-none font-mono"></div>
|
||||||
|
<div><label class="block text-xs text-slate-400 mb-1">Token / Contraseña</label><input type="password" id="config-harbor-token" class="w-full bg-slate-800 border border-slate-700 text-sm rounded-lg p-2.5 outline-none font-mono"></div>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-end gap-3 border-t border-slate-800 pt-4">
|
||||||
|
<button onclick="closeConfigModal()" class="px-4 py-2 bg-slate-800 text-slate-300 rounded-lg text-sm">Cancelar</button>
|
||||||
|
<button onclick="saveConfig()" class="px-5 py-2 bg-sky-500 hover:bg-sky-600 text-white rounded-lg text-sm font-semibold transition">Conectar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal CVE con Alineación Izquierda Corregida -->
|
||||||
|
<div id="cve-modal" class="fixed inset-0 z-50 bg-slate-950/80 backdrop-blur-sm hidden flex items-center justify-center p-4">
|
||||||
|
<div class="bg-slate-900 border border-slate-800 rounded-xl w-full max-w-2xl shadow-2xl p-6 space-y-5">
|
||||||
|
<div class="flex justify-between items-start border-b border-slate-800 pb-3">
|
||||||
|
<div>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<h3 id="modal-cve-id" class="text-xl font-mono font-bold text-sky-400">CVE</h3>
|
||||||
|
<span id="modal-cve-severity-badge" class="px-2 py-0.5 rounded text-xs font-bold">CRITICAL</span>
|
||||||
|
</div>
|
||||||
|
<p id="modal-cve-package" class="text-xs text-slate-400 mt-1 font-mono"></p>
|
||||||
|
</div>
|
||||||
|
<button onclick="closeCveModal()" class="text-slate-400 hover:text-white text-lg"><i class="fa-solid fa-xmark"></i></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-2 gap-4 bg-slate-950 p-4 rounded-lg border border-slate-800">
|
||||||
|
<div>
|
||||||
|
<p class="text-xs text-slate-400 uppercase tracking-wider font-semibold">Puntuación CVSS v3</p>
|
||||||
|
<p id="modal-cve-cvss" class="text-xl font-mono font-bold text-white mt-1">0.0</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="text-xs text-slate-400 uppercase tracking-wider font-semibold">Versión de Corrección (Fix)</p>
|
||||||
|
<p id="modal-cve-fix" class="text-xl font-mono font-bold text-emerald-400 mt-1">N/A</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-2">
|
||||||
|
<p class="text-xs font-semibold uppercase text-slate-400">Descripción</p>
|
||||||
|
<div id="modal-cve-desc" class="bg-slate-950 p-4 rounded-lg border border-slate-800 text-xs text-slate-300 leading-relaxed max-h-32 overflow-y-auto"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-2">
|
||||||
|
<p class="text-xs font-semibold uppercase text-slate-400">Ubicación del Artefacto en Harbor</p>
|
||||||
|
<!-- Clases text-left, break-all para asegurar alineación izquierda limpia -->
|
||||||
|
<div id="modal-cve-location" class="bg-slate-950 p-4 rounded-lg border border-slate-800 text-xs font-mono text-slate-300 space-y-1 text-left break-all"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-end pt-2">
|
||||||
|
<button onclick="closeCveModal()" class="px-5 py-2 bg-slate-800 hover:bg-slate-700 text-slate-200 rounded-lg text-sm font-medium transition">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let filteredVulnerabilities = [];
|
||||||
|
let userAuth = { user: '', token: '' };
|
||||||
|
let currentPage = 1;
|
||||||
|
let pageSize = 10;
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
loadSessionAuth();
|
||||||
|
onFilterTypeChange();
|
||||||
|
fetchGlobalSummary();
|
||||||
|
applyFilters(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function fetchGlobalSummary() {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/summary', { headers: getAuthHeaders() });
|
||||||
|
if (!response.ok) return;
|
||||||
|
const summary = await response.json();
|
||||||
|
|
||||||
|
document.getElementById('count-total').textContent = summary.total_vuls || 0;
|
||||||
|
document.getElementById('count-critical').textContent = summary.critical_cnt || 0;
|
||||||
|
document.getElementById('count-high').textContent = summary.high_cnt || 0;
|
||||||
|
document.getElementById('count-medium').textContent = summary.medium_cnt || 0;
|
||||||
|
document.getElementById('count-low').textContent = summary.low_cnt || 0;
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error obteniendo summary global:", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFilterTypeChange() {
|
||||||
|
const filterType = document.getElementById('filter-type').value;
|
||||||
|
const container = document.getElementById('filter-input-container');
|
||||||
|
|
||||||
|
if (filterType === 'Severity') {
|
||||||
|
container.innerHTML = `
|
||||||
|
<label class="block text-xs font-medium text-slate-400 mb-1">Nivel de Severidad</label>
|
||||||
|
<select id="search-severity" class="w-full bg-slate-800 border border-slate-700 text-slate-200 text-sm rounded-lg p-2.5 outline-none font-semibold">
|
||||||
|
<option value="ALL">Todas</option>
|
||||||
|
<option value="Critical">Critical</option>
|
||||||
|
<option value="High">High</option>
|
||||||
|
<option value="Medium">Medium</option>
|
||||||
|
<option value="Low">Low</option>
|
||||||
|
<option value="n/a">n/a</option>
|
||||||
|
<option value="None">None</option>
|
||||||
|
</select>
|
||||||
|
`;
|
||||||
|
} else if (filterType === 'CVSS3') {
|
||||||
|
container.innerHTML = `
|
||||||
|
<label class="block text-xs font-medium text-slate-400 mb-1">Rango CVSS v3 (0.0 - 10.0)</label>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<input type="number" id="cvss-from" step="0.1" min="0" max="10" placeholder="Desde" class="w-full bg-slate-800 border border-slate-700 text-sm rounded-lg p-2.5 outline-none">
|
||||||
|
<span class="text-slate-500">-</span>
|
||||||
|
<input type="number" id="cvss-to" step="0.1" min="0" max="10" placeholder="Hasta" class="w-full bg-slate-800 border border-slate-700 text-sm rounded-lg p-2.5 outline-none">
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
} else {
|
||||||
|
let placeholderText = "Ej. CVE-2025-68121, netty...";
|
||||||
|
if (filterType === 'Repository Name') placeholderText = "Ej. demo8/mysql";
|
||||||
|
|
||||||
|
container.innerHTML = `
|
||||||
|
<label class="block text-xs font-medium text-slate-400 mb-1">Término de Búsqueda (${filterType})</label>
|
||||||
|
<input type="text" id="search-query" onkeyup="if(event.key==='Enter')applyFilters(1)" placeholder="${placeholderText}" class="w-full bg-slate-800 border border-slate-700 text-sm rounded-lg p-2.5 outline-none font-mono">
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadSessionAuth() {
|
||||||
|
userAuth.user = sessionStorage.getItem('harbor_user') || '';
|
||||||
|
userAuth.token = sessionStorage.getItem('harbor_token') || '';
|
||||||
|
document.getElementById('config-harbor-user').value = userAuth.user;
|
||||||
|
document.getElementById('config-harbor-token').value = userAuth.token;
|
||||||
|
if(userAuth.user) updateConnectionBadge(true, `Usuario: ${userAuth.user}`);
|
||||||
|
else updateConnectionBadge(false, 'Sin Autenticar');
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveConfig() {
|
||||||
|
userAuth.user = document.getElementById('config-harbor-user').value.trim();
|
||||||
|
userAuth.token = document.getElementById('config-harbor-token').value.trim();
|
||||||
|
sessionStorage.setItem('harbor_user', userAuth.user);
|
||||||
|
sessionStorage.setItem('harbor_token', userAuth.token);
|
||||||
|
closeConfigModal();
|
||||||
|
loadSessionAuth();
|
||||||
|
fetchGlobalSummary();
|
||||||
|
applyFilters(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAuthHeaders() {
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.append('Accept', 'application/json');
|
||||||
|
if (userAuth.user && userAuth.token) {
|
||||||
|
headers.append('Authorization', `Basic ${btoa(`${userAuth.user}:${userAuth.token}`)}`);
|
||||||
|
}
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function applyFilters(targetPage = 1) {
|
||||||
|
currentPage = targetPage;
|
||||||
|
const filterType = document.getElementById('filter-type').value;
|
||||||
|
let query = '';
|
||||||
|
let severity = '';
|
||||||
|
let cvssFrom = '';
|
||||||
|
let cvssTo = '';
|
||||||
|
|
||||||
|
if (filterType === 'Severity') {
|
||||||
|
severity = document.getElementById('search-severity').value;
|
||||||
|
} else if (filterType === 'CVSS3') {
|
||||||
|
cvssFrom = document.getElementById('cvss-from').value;
|
||||||
|
cvssTo = document.getElementById('cvss-to').value;
|
||||||
|
} else {
|
||||||
|
const qInput = document.getElementById('search-query');
|
||||||
|
query = qInput ? qInput.value.trim() : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchIcon = document.getElementById('search-btn-icon');
|
||||||
|
searchIcon.className = "fa-solid fa-spinner fa-spin";
|
||||||
|
|
||||||
|
try {
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
filter_type: filterType,
|
||||||
|
query,
|
||||||
|
severity,
|
||||||
|
cvss_from: cvssFrom,
|
||||||
|
cvss_to: cvssTo,
|
||||||
|
page: currentPage,
|
||||||
|
page_size: pageSize
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await fetch(`/api/search?${params.toString()}`, { headers: getAuthHeaders() });
|
||||||
|
if(!response.ok) throw new Error("Error en la consulta a la API");
|
||||||
|
|
||||||
|
filteredVulnerabilities = await response.json();
|
||||||
|
renderTable(filteredVulnerabilities);
|
||||||
|
updatePaginationControls();
|
||||||
|
} catch (e) {
|
||||||
|
alert("Error consultando la API: " + e.message);
|
||||||
|
} finally {
|
||||||
|
searchIcon.className = "fa-solid fa-magnifying-glass";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function changePageSize() {
|
||||||
|
const selectEl = document.getElementById('page-size-select');
|
||||||
|
pageSize = parseInt(selectEl.value);
|
||||||
|
applyFilters(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function changePage(direction) {
|
||||||
|
if (direction === -1 && currentPage > 1) {
|
||||||
|
applyFilters(currentPage - 1);
|
||||||
|
} else if (direction === 1) {
|
||||||
|
if (filteredVulnerabilities.length < pageSize) return;
|
||||||
|
applyFilters(currentPage + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updatePaginationControls() {
|
||||||
|
document.getElementById('current-page-label').textContent = currentPage;
|
||||||
|
document.getElementById('prev-page-btn').disabled = (currentPage <= 1);
|
||||||
|
|
||||||
|
const nextBtn = document.getElementById('next-page-btn');
|
||||||
|
if (filteredVulnerabilities.length < pageSize) {
|
||||||
|
nextBtn.disabled = true;
|
||||||
|
nextBtn.classList.add('opacity-50', 'cursor-not-allowed');
|
||||||
|
} else {
|
||||||
|
nextBtn.disabled = false;
|
||||||
|
nextBtn.classList.remove('opacity-50', 'cursor-not-allowed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTable(items) {
|
||||||
|
const tbody = document.getElementById('vulnerabilities-tbody');
|
||||||
|
const emptyState = document.getElementById('empty-state');
|
||||||
|
document.getElementById('results-count').textContent = items.length;
|
||||||
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
|
if (items.length === 0) {
|
||||||
|
emptyState.classList.remove('hidden');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emptyState.classList.add('hidden');
|
||||||
|
|
||||||
|
items.forEach((item, index) => {
|
||||||
|
const tr = document.createElement('tr');
|
||||||
|
tr.className = 'hover:bg-slate-800/40 transition';
|
||||||
|
const sev = item.severity.toLowerCase();
|
||||||
|
const sevColor = sev === 'critical' ? 'bg-red-500/10 text-red-400' :
|
||||||
|
sev === 'high' ? 'bg-orange-500/10 text-orange-400' :
|
||||||
|
sev === 'medium' ? 'bg-yellow-500/10 text-yellow-400' : 'bg-blue-500/10 text-blue-400';
|
||||||
|
|
||||||
|
tr.innerHTML = `
|
||||||
|
<td class="px-4 py-3.5 font-mono text-sky-400"><button onclick="openCveModal(${index})" class="hover:underline">${item.cve_id}</button></td>
|
||||||
|
<td class="px-4 py-3.5"><span class="px-2 py-1 rounded text-xs font-bold ${sevColor}">${item.severity}</span></td>
|
||||||
|
<td class="px-4 py-3.5 font-mono text-white">${item.package} <span class="text-xs text-slate-500 block">${item.version}</span></td>
|
||||||
|
<td class="px-4 py-3.5"><span class="px-2 py-0.5 rounded bg-slate-800 text-xs text-slate-300">${item.project}</span></td>
|
||||||
|
<td class="px-4 py-3.5 font-mono text-xs text-slate-300">${item.repository}</td>
|
||||||
|
<td class="px-4 py-3.5 font-mono text-xs text-slate-400">${item.tag}<br><span class="text-slate-500">${item.digest.substring(0,14)}...</span></td>
|
||||||
|
<td class="px-4 py-3.5 text-center font-mono font-bold text-yellow-400">${item.cvss3}</td>
|
||||||
|
<td class="px-4 py-3.5 text-right"><button onclick="openCveModal(${index})" class="bg-slate-800 hover:bg-slate-700 text-xs px-2.5 py-1.5 rounded">Ver</button></td>
|
||||||
|
`;
|
||||||
|
tbody.appendChild(tr);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function exportToCsv() {
|
||||||
|
if (!filteredVulnerabilities || filteredVulnerabilities.length === 0) {
|
||||||
|
alert("No hay datos en la tabla para exportar.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const headers = ["CVE ID", "Severity", "Package", "Version", "Fixed Version", "Project", "Repository", "Tag", "Digest", "CVSS3", "Description"];
|
||||||
|
let csvContent = "\uFEFF" + headers.join(";") + "\n";
|
||||||
|
|
||||||
|
filteredVulnerabilities.forEach(item => {
|
||||||
|
const row = [
|
||||||
|
item.cve_id,
|
||||||
|
item.severity,
|
||||||
|
item.package,
|
||||||
|
item.version,
|
||||||
|
item.fixed_version,
|
||||||
|
item.project,
|
||||||
|
item.repository,
|
||||||
|
item.tag,
|
||||||
|
item.digest,
|
||||||
|
item.cvss3,
|
||||||
|
`"${(item.description || "").replace(/"/g, '""')}"`
|
||||||
|
];
|
||||||
|
csvContent += row.join(";") + "\n";
|
||||||
|
});
|
||||||
|
|
||||||
|
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.setAttribute('href', url);
|
||||||
|
a.setAttribute('download', `harbor_vulnerabilities_export.csv`);
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
alert("Error al exportar los datos: " + e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCveModal(index) {
|
||||||
|
const item = filteredVulnerabilities[index];
|
||||||
|
const sev = item.severity.toLowerCase();
|
||||||
|
const badgeEl = document.getElementById('modal-cve-severity-badge');
|
||||||
|
|
||||||
|
badgeEl.className = sev === 'critical' ? 'px-2 py-0.5 rounded text-xs font-bold bg-red-500/10 text-red-400 border border-red-500/20' :
|
||||||
|
sev === 'high' ? 'px-2 py-0.5 rounded text-xs font-bold bg-orange-500/10 text-orange-400 border border-orange-500/20' :
|
||||||
|
sev === 'medium' ? 'px-2 py-0.5 rounded text-xs font-bold bg-yellow-500/10 text-yellow-400 border border-yellow-500/20' : 'px-2 py-0.5 rounded text-xs font-bold bg-blue-500/10 text-blue-400 border border-blue-500/20';
|
||||||
|
|
||||||
|
badgeEl.textContent = item.severity;
|
||||||
|
document.getElementById('modal-cve-id').textContent = item.cve_id;
|
||||||
|
document.getElementById('modal-cve-package').textContent = `Paquete: ${item.package} (${item.version})`;
|
||||||
|
document.getElementById('modal-cve-cvss').textContent = item.cvss3;
|
||||||
|
document.getElementById('modal-cve-fix').textContent = item.fixed_version || 'N/A';
|
||||||
|
document.getElementById('modal-cve-desc').textContent = item.description || 'Sin descripción disponible.';
|
||||||
|
|
||||||
|
// Estructura limpia en divs con alineación izquierda perfecta
|
||||||
|
document.getElementById('modal-cve-location').innerHTML = `
|
||||||
|
<div>Proyecto: ${item.project}</div>
|
||||||
|
<div>Repositorio: ${item.repository}</div>
|
||||||
|
<div>Digest: ${item.digest}</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
document.getElementById('cve-modal').classList.remove('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeCveModal() { document.getElementById('cve-modal').classList.add('hidden'); }
|
||||||
|
function openConfigModal() { document.getElementById('config-modal').classList.remove('hidden'); }
|
||||||
|
function closeConfigModal() { document.getElementById('config-modal').classList.add('hidden'); }
|
||||||
|
|
||||||
|
function updateConnectionBadge(isConnected, text) {
|
||||||
|
const badge = document.getElementById('connection-badge');
|
||||||
|
badge.className = isConnected ? "flex items-center space-x-2 bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 px-3 py-1.5 rounded-md text-xs font-medium" : "flex items-center space-x-2 bg-amber-500/10 border border-amber-500/20 text-amber-400 px-3 py-1.5 rounded-md text-xs font-medium";
|
||||||
|
document.getElementById('connection-status-text').textContent = text;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+211
-40
@@ -1,65 +1,236 @@
|
|||||||
|
import os
|
||||||
import http.server
|
import http.server
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import base64
|
import urllib.error
|
||||||
import json
|
import json
|
||||||
|
from urllib.parse import urlparse, parse_qs, urlencode
|
||||||
|
|
||||||
|
HARBOR_URL = os.environ.get("HARBOR_URL", "https://demo.goharbor.io").rstrip("/")
|
||||||
PORT = 8080
|
PORT = 8080
|
||||||
# Cambia esto por tu URL de Harbor real
|
|
||||||
HARBOR_URL = "https://harbor.midominio.com"
|
|
||||||
|
|
||||||
class ProxyHandler(http.server.SimpleHTTPRequestHandler):
|
def fetch_json(url, auth_header):
|
||||||
def do_GET(self):
|
req = urllib.request.Request(url)
|
||||||
# Si la petición va dirigida a la API, la redirigimos a Harbor haciendo de proxy
|
req.add_header("Accept", "application/json")
|
||||||
if self.path.startswith("/api/"):
|
|
||||||
target_url = HARBOR_URL + self.path
|
|
||||||
|
|
||||||
# Recuperamos las cabeceras de autorización que envíe el navegador
|
|
||||||
auth_header = self.headers.get('Authorization')
|
|
||||||
|
|
||||||
req = urllib.request.Request(target_url)
|
|
||||||
if auth_header:
|
if auth_header:
|
||||||
req.add_header('Authorization', auth_header)
|
req.add_header("Authorization", auth_header)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Realizamos la petición a Harbor ignorando problemas de certificados internos si los hubiera
|
with urllib.request.urlopen(req, timeout=8) as response:
|
||||||
import ssl
|
return json.loads(response.read().decode("utf-8"))
|
||||||
ctx = ssl.create_default_context()
|
except Exception:
|
||||||
ctx.check_hostname = False
|
return None
|
||||||
ctx.verify_mode = ssl.CERT_NONE
|
|
||||||
|
|
||||||
with urllib.request.urlopen(req, context=ctx) as response:
|
class HarborProxyHandler(http.server.BaseHTTPRequestHandler):
|
||||||
|
|
||||||
|
def do_OPTIONS(self):
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header("Access-Control-Allow-Origin", "*")
|
||||||
|
self.send_header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
|
||||||
|
self.send_header("Access-Control-Allow-Headers", "Authorization, Content-Type")
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
def do_GET(self):
|
||||||
|
parsed_url = urlparse(self.path)
|
||||||
|
path = parsed_url.path
|
||||||
|
query_params = {k: v[0] for k, v in parse_qs(parsed_url.query).items()}
|
||||||
|
auth_header = self.headers.get("Authorization")
|
||||||
|
|
||||||
|
if path == "/" or path == "/index.html":
|
||||||
|
self.serve_file("index.html", "text/html")
|
||||||
|
return
|
||||||
|
elif path.startswith("/assets/"):
|
||||||
|
self.serve_static_asset()
|
||||||
|
return
|
||||||
|
|
||||||
|
# ENDPOINT DE MÉTRICAS GLOBALES (SUMMARY)
|
||||||
|
if path == "/api/summary":
|
||||||
|
target_api = f"{HARBOR_URL}/api/v2.0/security/summary?with_dangerous_cve=false&with_dangerous_artifact=false"
|
||||||
|
req = urllib.request.Request(target_api)
|
||||||
|
req.add_header("Accept", "application/json")
|
||||||
|
if auth_header:
|
||||||
|
req.add_header("Authorization", auth_header)
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(req, timeout=10) as response:
|
||||||
data = response.read()
|
data = response.read()
|
||||||
self.send_response(response.status)
|
self.send_response(response.status)
|
||||||
self.send_header('Content-Type', response.headers.get('Content-Type', 'application/json'))
|
self.send_header("Content-Type", "application/json")
|
||||||
# Añadimos las cabeceras CORS para que el navegador no se queje nunca más
|
self.send_header("Access-Control-Allow-Origin", "*")
|
||||||
self.send_header('Access-Control-Allow-Origin', '*')
|
self.end_headers()
|
||||||
|
self.wfile.write(data)
|
||||||
|
except Exception as e:
|
||||||
|
self.send_json_response({})
|
||||||
|
return
|
||||||
|
|
||||||
|
# ENDPOINT DE EXPORTACIÓN MASIVA (CSV/EXCEL)
|
||||||
|
if path == "/api/export":
|
||||||
|
self.handle_export_vulnerabilities(query_params, auth_header)
|
||||||
|
return
|
||||||
|
|
||||||
|
# BÚSQUEDA NATIVA /security/vul CON PAGINACIÓN
|
||||||
|
if path == "/api/search":
|
||||||
|
self.handle_native_vulnerability_search(query_params, auth_header)
|
||||||
|
return
|
||||||
|
|
||||||
|
target_url = f"{HARBOR_URL}{path}"
|
||||||
|
if parsed_url.query:
|
||||||
|
target_url += f"?{parsed_url.query}"
|
||||||
|
|
||||||
|
req = urllib.request.Request(target_url)
|
||||||
|
req.add_header("Accept", "application/json")
|
||||||
|
if auth_header:
|
||||||
|
req.add_header("Authorization", auth_header)
|
||||||
|
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(req) as response:
|
||||||
|
data = response.read()
|
||||||
|
self.send_response(response.status)
|
||||||
|
self.send_header("Content-Type", "application/json")
|
||||||
|
self.send_header("Access-Control-Allow-Origin", "*")
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(data)
|
self.wfile.write(data)
|
||||||
except urllib.error.HTTPError as e:
|
except urllib.error.HTTPError as e:
|
||||||
self.send_response(e.code)
|
self.send_response(e.code)
|
||||||
|
self.send_header("Content-Type", "application/json")
|
||||||
|
self.send_header("Access-Control-Allow-Origin", "*")
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(e.read())
|
self.wfile.write(e.read())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.send_response(500)
|
self.send_response(500)
|
||||||
|
self.send_header("Content-Type", "application/json")
|
||||||
|
self.send_header("Access-Control-Allow-Origin", "*")
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(str(e).encode('utf-8'))
|
self.wfile.write(json.dumps({"error": str(e)}).encode("utf-8"))
|
||||||
else:
|
|
||||||
# Para cualquier otra ruta, sirve los archivos estáticos normales (tu HTML)
|
|
||||||
super().do_GET()
|
|
||||||
|
|
||||||
def do_OPTIONS(self):
|
def handle_native_vulnerability_search(self, params, auth_header):
|
||||||
# Respondemos automáticamente al preflight de CORS del navegador
|
self._process_vul_search(params, auth_header, is_export=False)
|
||||||
|
|
||||||
|
def handle_export_vulnerabilities(self, params, auth_header):
|
||||||
|
self._process_vul_search(params, auth_header, is_export=True)
|
||||||
|
|
||||||
|
def _process_vul_search(self, params, auth_header, is_export=False):
|
||||||
|
filter_type = params.get("filter_type", "All")
|
||||||
|
query = params.get("query", "").strip()
|
||||||
|
severity_raw = params.get("severity", "").strip()
|
||||||
|
cvss_from = params.get("cvss_from", "").strip()
|
||||||
|
cvss_to = params.get("cvss_to", "").strip()
|
||||||
|
|
||||||
|
page = "1" if is_export else params.get("page", "1")
|
||||||
|
page_size = "500" if is_export else params.get("page_size", "10")
|
||||||
|
|
||||||
|
q_conditions = []
|
||||||
|
project_map = {}
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Mapeo rápido de proyectos opcional solo para mostrar nombres bonitos en la tabla si hiciera falta
|
||||||
|
projects_data = fetch_json(f"{HARBOR_URL}/api/v2.0/projects?page_size=100", auth_header)
|
||||||
|
if projects_data:
|
||||||
|
for p in projects_data:
|
||||||
|
project_map[p.get("project_id")] = p.get("name")
|
||||||
|
|
||||||
|
if filter_type == "CVE ID" and query:
|
||||||
|
q_conditions.append(f"cve_id={query}")
|
||||||
|
elif filter_type == "Package" and query:
|
||||||
|
q_conditions.append(f"package={query}")
|
||||||
|
elif filter_type == "Repository Name" and query:
|
||||||
|
# Búsqueda directa por repositorio (ej: demo8/mysql)
|
||||||
|
q_conditions.append(f"repository_name={query}")
|
||||||
|
elif filter_type == "Digest" and query:
|
||||||
|
q_conditions.append(f"digest={query}")
|
||||||
|
elif filter_type == "Severity" and severity_raw and severity_raw.upper() != "ALL":
|
||||||
|
sev_map = {
|
||||||
|
"CRITICAL": "Critical",
|
||||||
|
"HIGH": "High",
|
||||||
|
"MEDIUM": "Medium",
|
||||||
|
"LOW": "Low",
|
||||||
|
"N/A": "n/a",
|
||||||
|
"NONE": "None"
|
||||||
|
}
|
||||||
|
mapped_sev = sev_map.get(severity_raw.upper(), severity_raw.capitalize())
|
||||||
|
q_conditions.append(f"severity={mapped_sev}")
|
||||||
|
elif filter_type == "CVSS3":
|
||||||
|
min_val = cvss_from if cvss_from else "0"
|
||||||
|
max_val = cvss_to if cvss_to else "10"
|
||||||
|
q_conditions.append(f"cvss_score_v3=[{min_val}~{max_val}]")
|
||||||
|
|
||||||
|
api_params = {
|
||||||
|
"page": page,
|
||||||
|
"page_size": page_size,
|
||||||
|
"tune_count": "false",
|
||||||
|
"with_tag": "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
if q_conditions:
|
||||||
|
api_params["q"] = ",".join(q_conditions)
|
||||||
|
|
||||||
|
target_api = f"{HARBOR_URL}/api/v2.0/security/vul?{urlencode(api_params)}"
|
||||||
|
print(f"[*] Consultando API nativa de Harbor: {target_api}")
|
||||||
|
|
||||||
|
req = urllib.request.Request(target_api)
|
||||||
|
req.add_header("Accept", "application/json")
|
||||||
|
if auth_header:
|
||||||
|
req.add_header("Authorization", auth_header)
|
||||||
|
|
||||||
|
with urllib.request.urlopen(req, timeout=15) as response:
|
||||||
|
raw_data = json.loads(response.read().decode("utf-8"))
|
||||||
|
|
||||||
|
formatted_results = []
|
||||||
|
for item in raw_data:
|
||||||
|
p_id = item.get("project_id")
|
||||||
|
project_name = project_map.get(p_id, str(p_id))
|
||||||
|
repo_name = item.get("repository_name", "")
|
||||||
|
|
||||||
|
formatted_results.append({
|
||||||
|
"cve_id": item.get("cve_id", "N/A"),
|
||||||
|
"severity": item.get("severity", "UNKNOWN").upper(),
|
||||||
|
"package": item.get("package", "Desconocido"),
|
||||||
|
"version": item.get("version", "-"),
|
||||||
|
"fixed_version": item.get("fixed_version", "N/A"),
|
||||||
|
"project": project_name,
|
||||||
|
"repository": repo_name,
|
||||||
|
"tag": item.get("tags", ["latest"])[0] if item.get("tags") else "latest",
|
||||||
|
"digest": item.get("digest", "N/A"),
|
||||||
|
"cvss3": float(item.get("cvss_v3_score", 0)),
|
||||||
|
"description": item.get("desc", "Sin descripción.")
|
||||||
|
})
|
||||||
|
|
||||||
|
self.send_json_response(formatted_results)
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
print(f"[!] Error HTTP de Harbor en /security/vul: {e.code}")
|
||||||
|
self.send_json_response([])
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[!] Error en consulta nativa: {e}")
|
||||||
|
self.send_json_response([])
|
||||||
|
|
||||||
|
def send_json_response(self, data):
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header('Access-Control-Allow-Origin', '*')
|
self.send_header("Content-Type", "application/json")
|
||||||
self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
|
self.send_header("Access-Control-Allow-Origin", "*")
|
||||||
self.send_header('Access-Control-Allow-Headers', 'Authorization, Content-Type')
|
self.end_headers()
|
||||||
|
self.wfile.write(json.dumps(data).encode("utf-8"))
|
||||||
|
|
||||||
|
def serve_file(self, filename, content_type):
|
||||||
|
if os.path.exists(filename):
|
||||||
|
with open(filename, "rb") as f:
|
||||||
|
content = f.read()
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header("Content-Type", content_type)
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(content)
|
||||||
|
else:
|
||||||
|
self.send_response(404)
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
def serve_static_asset(self):
|
||||||
|
filepath = self.path.lstrip("/")
|
||||||
|
if os.path.exists(filepath):
|
||||||
|
content_type = "text/plain"
|
||||||
|
if filepath.endswith(".js"): content_type = "application/javascript"
|
||||||
|
elif filepath.endswith(".css"): content_type = "text/css"
|
||||||
|
self.serve_file(filepath, content_type)
|
||||||
|
else:
|
||||||
|
self.send_response(404)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
server_address = ('', PORT)
|
server = http.server.HTTPServer(("0.0.0.0", PORT), HarborProxyHandler)
|
||||||
httpd = http.server.HTTPServer(server_address, ProxyHandler)
|
print(f"[*] Proxy Harbor con repositorio directo corriendo en el puerto {PORT}, conectado a: {HARBOR_URL}")
|
||||||
print(f"---------------------------------------------------------")
|
server.serve_forever()
|
||||||
print(f"Servidor proxy y web corriendo en http://localhost:{PORT}")
|
|
||||||
print(f"---------------------------------------------------------")
|
|
||||||
print(f"\nUse la URL http://localhost:{PORT} para Harbor\nen vez de {HARBOR_URL}")
|
|
||||||
httpd.serve_forever()
|
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
docker rm -f portal-harbor 2> /dev/null
|
||||||
|
#docker run -d -p 8080:8080 -e HARBOR_URL="https://tu-harbor-corporativo.com" --name portal-harbor harbor-security-portal
|
||||||
|
docker run -d -p 8080:8080 -e HARBOR_URL="https://demo.goharbor.io" --name portal-harbor harbor-security-portal
|
||||||
|
echo "Portal Harbor iniciado en http://localhost:8080"
|
||||||
Executable
+2
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
docker rm -f portal-harbor
|
||||||
Reference in new issue
Block a user