Umsetzung von docs/specs/self-updater.md für Laravel: - Installierter Stand als SHA in storage/.version, Fortschritt in storage/.update-progress, selbstheilender Wartungsmodus in storage/.maintenance - Update-Client je Kanal (stable/development), nur HTTPS, begrenzte Redirects, ZIP-Download per Stream mit PK- und SHA-256-Prüfung - Entpacken mit zweistufigem ZIP-Slip-Schutz, Übernahme mit geschützten Pfaden (atomar je Datei, nie löschen), Migrationen, Cache- und OPcache-Reset - Lizenzspeicher außerhalb der DB, Geräte-ID als Zufallszahl, rotierendes Gerätetoken wird bei jeder Antwort (auch Fehler und Downloads) sofort gespeichert - Lizenzfehler mit verständlichen Meldungen – sie sperren nie das Portal - Seite „Aktualisierung“ mit Kanal, Suche, Changelog-Vorschau, Fortschritt, Migrationen, Änderungsprotokoll, Lizenz und Datenschutzhinweis - Wartungs-Middleware (503 + Retry-After) und Auto-Migration per Fingerabdruck - Audit-Log für Updates, Kanalwechsel und Lizenzänderungen - Version 0.2.0 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
37 lines
927 B
PHP
37 lines
927 B
PHP
<?php
|
|
|
|
namespace App\Support\Update;
|
|
|
|
/**
|
|
* Pfade, die ein Update nie überschreibt. Verzeichnisse enden mit „/“ und
|
|
* schützen alles darunter; Dateien werden exakt verglichen.
|
|
*/
|
|
class ProtectedPaths
|
|
{
|
|
/**
|
|
* @param list<string> $paths
|
|
*/
|
|
public function __construct(private readonly array $paths) {}
|
|
|
|
public static function fromConfig(): self
|
|
{
|
|
return new self(config('updater.protected_paths', []));
|
|
}
|
|
|
|
public function isProtected(string $relativePath): bool
|
|
{
|
|
$path = ltrim(str_replace('\\', '/', $relativePath), '/');
|
|
|
|
foreach ($this->paths as $protected) {
|
|
if (str_ends_with($protected, '/')) {
|
|
if (str_starts_with($path.'/', $protected)) {
|
|
return true;
|
|
}
|
|
} elseif ($path === $protected) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|