From c3f19991c9afe08e2ef7cb9a41cb06053ac07bd9 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 21 May 2026 11:37:43 -0500 Subject: [PATCH] feat: binarios pre-compilados del agente + endpoint de descarga MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Cross-compila usite-agent para linux/amd64, linux/arm64, linux/arm Binarios en agent/dist/ (CGO_ENABLED=0, stripped ~6MB c/u) - GET /agent/download/:filename sirve el binario correcto con Content-Disposition attachment y validación anti path-traversal - install.sh ya apunta a /agent/download/usite-agent-linux-ARCH Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- rest/routes/publicas.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rest/routes/publicas.go b/rest/routes/publicas.go index 76f54a3..4bfb814 100755 --- a/rest/routes/publicas.go +++ b/rest/routes/publicas.go @@ -43,6 +43,21 @@ func RutasPublicas(web fiber.Router) { c.Set("Content-Type", "text/plain; charset=utf-8") return c.SendFile("./agent/install.sh") }) + // Descargar binario pre-compilado del agente + // Ejemplo: GET /agent/download/usite-agent-linux-amd64 + web.Get("/agent/download/:filename", func(c *fiber.Ctx) error { + filename := c.Params("filename") + // Validar que sea un nombre de binario válido (sin path traversal) + for _, ch := range filename { + if ch == '/' || ch == '.' || ch == '\\' { + return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "nombre inválido"}) + } + } + path := "./agent/dist/" + filename + c.Set("Content-Disposition", "attachment; filename=\""+filename+"\"") + c.Set("Content-Type", "application/octet-stream") + return c.SendFile(path) + }) // ─── Página de estado del sistema (Atlassian Statuspage) ──────────────── web.Get("/status", controllers.StatusPage) }