Linux heartbeat Agent als Download verfügbar

This commit is contained in:
2025-06-20 22:09:20 +02:00
parent 27ec61485c
commit 297f76161c
3 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Watcher.Controllers;
[Authorize]
public class DownloadController : Controller
{
[HttpGet("Download/File/{filename}")]
public IActionResult FileDownload(string filename)
{
// Nur erlaubte Endungen zulassen (Sicherheit!)
var allowedExtensions = new[] { ".exe", "" };
var extension = Path.GetExtension(filename).ToLowerInvariant();
if (!allowedExtensions.Contains(extension))
return BadRequest("Dateityp nicht erlaubt");
var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "downloads", filename);
if (!System.IO.File.Exists(path))
return NotFound("Datei nicht gefunden");
// .exe MIME-Typ: application/octet-stream
var mimeType = "application/octet-stream";
var fileBytes = System.IO.File.ReadAllBytes(path);
return File(fileBytes, mimeType, filename);
//return File(fileBytes, filename);
}
}

View File

@@ -45,6 +45,10 @@
<i class="bi bi-trash me-1"></i>Löschen
</button>
</form>
<a href="/Download/File/heartbeat" class="btn btn-success">
🖥️ Tool herunterladen
</a>
</div>
</div>
}

Binary file not shown.