Sicherheitsupdate nach Audit (0.29.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m50s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m34s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m45s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m30s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m7s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m9s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m8s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m5s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 48s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m5s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m50s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m34s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 5m45s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m30s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m7s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m9s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m8s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m5s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 48s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m5s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a37895a16a
commit
f1202bea08
226 changed files with 1952 additions and 450 deletions
|
|
@ -15,7 +15,7 @@ Route::middleware('auth')->group(function () {
|
|||
Route::get('/', 'index')->name('index');
|
||||
Route::post('/', 'store')->name('store');
|
||||
Route::post('/bilder', 'uploadImage')->name('images');
|
||||
Route::post('/vorschau', 'preview')->name('preview');
|
||||
Route::post('/vorschau', 'preview')->middleware('throttle:60,1')->name('preview');
|
||||
Route::get('/{snippet}', 'edit')->name('edit');
|
||||
Route::put('/{snippet}', 'update')->name('update');
|
||||
Route::delete('/{snippet}', 'destroy')->name('destroy');
|
||||
|
|
@ -39,6 +39,6 @@ Route::middleware('auth')->group(function () {
|
|||
Route::post('/{page}/sperre/freigeben', 'unlock')->name('unlock');
|
||||
Route::post('/{page}/bilder', 'uploadImage')->name('images');
|
||||
Route::post('/{page}/dateien', 'uploadFile')->name('files');
|
||||
Route::post('/{page}/vorschau', 'preview')->name('preview');
|
||||
Route::post('/{page}/vorschau', 'preview')->middleware('throttle:60,1')->name('preview');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -62,7 +62,12 @@ class PageController extends Controller
|
|||
public function file(Request $request, PageFile $file, PageTree $tree): StreamedResponse
|
||||
{
|
||||
$page = $file->page;
|
||||
abort_unless($tree->isVisible($page->id, $request->user()) || $request->user()->can('update', $page), 404);
|
||||
$user = $request->user();
|
||||
|
||||
// Redaktion: alle Dateien der Seite. Sonst nur Dateien, die im veröffentlichten Inhalt
|
||||
// für diese Person sichtbar eingebunden sind (Downloads-Block oder Link im Text) –
|
||||
// nicht Dateien aus Entwürfen oder aus Blöcken für andere Zielgruppen.
|
||||
abort_unless($user->can('update', $page) || ($tree->isVisible($page->id, $user) && self::referenced($page, $file, $user)), 404);
|
||||
|
||||
return Storage::disk(PageFile::DISK)->download($file->path, $file->name, [
|
||||
'Content-Type' => $file->mime ?: 'application/octet-stream',
|
||||
|
|
@ -70,4 +75,17 @@ class PageController extends Controller
|
|||
'X-Content-Type-Options' => 'nosniff',
|
||||
]);
|
||||
}
|
||||
|
||||
private static function referenced(Page $page, PageFile $file, $user): bool
|
||||
{
|
||||
if ($page->content === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$rendered = app(Content::class)->render($page->content, $user, ['page_id' => $page->id]);
|
||||
$inBlocks = collect(app(Content::class)->collect($rendered, fn (array $block) => $block['type'] === 'downloads' ? (array) ($block['data']['files'] ?? []) : []))
|
||||
->map(fn ($id) => (int) $id)->contains($file->id);
|
||||
|
||||
return $inBlocks || str_contains((string) json_encode($rendered, JSON_UNESCAPED_SLASHES), '/dateien/seiten/'.$file->id.'/');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use App\Notifications\PortalNotification;
|
|||
use App\Pagebuilder\Blocks;
|
||||
use App\Pagebuilder\Content;
|
||||
use App\Support\Audit;
|
||||
use App\Support\BlockedFiles;
|
||||
use App\Support\Permissions\Audiences;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
|
@ -39,7 +40,7 @@ use Inhaus\Plugins\Pages\Publishers;
|
|||
class PageEditorController extends Controller
|
||||
{
|
||||
/** Dateiendungen, die nie als Download angenommen werden. */
|
||||
private const BLOCKED_EXTENSIONS = ['php', 'phtml', 'phar', 'php3', 'php4', 'php5', 'php7', 'php8', 'pht', 'shtml', 'htaccess', 'exe', 'bat', 'cmd', 'com', 'sh', 'js', 'mjs', 'html', 'htm', 'svg', 'xhtml', 'jsp', 'asp', 'aspx', 'cgi', 'pl', 'py'];
|
||||
private const BLOCKED_EXTENSIONS = BlockedFiles::EXTENSIONS;
|
||||
|
||||
public function __construct(private readonly Content $content) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use Illuminate\Validation\Rules\File;
|
|||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Inhaus\Plugins\Pages\Models\ContentSnippet;
|
||||
use Inhaus\Plugins\Pages\Models\Page;
|
||||
use Inhaus\Plugins\Pages\Snippets;
|
||||
|
||||
/**
|
||||
|
|
@ -31,6 +32,9 @@ class SnippetController extends Controller
|
|||
*/
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
// Namen der Bausteine und Vorlagen nur für die Seiten-Redaktion
|
||||
abort_unless($request->user()->can('viewAny', Page::class), 403);
|
||||
|
||||
$request->validate(['kind' => ['nullable', Rule::in(array_keys(ContentSnippet::KINDS))]]);
|
||||
|
||||
return response()->json(['snippets' => ContentSnippet::query()
|
||||
|
|
|
|||
|
|
@ -3,13 +3,14 @@
|
|||
namespace Inhaus\Plugins\Pages;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Pagebuilder\Content;
|
||||
use App\Search\GlobalSearch;
|
||||
use Inhaus\Plugins\Pages\Models\Page;
|
||||
|
||||
/** Suchquelle für die globale Suche: veröffentlichte, sichtbare Seiten */
|
||||
class PageSearch
|
||||
{
|
||||
public function __construct(private readonly PageTree $tree) {}
|
||||
public function __construct(private readonly PageTree $tree, private readonly Content $content) {}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
|
|
@ -27,27 +28,30 @@ class PageSearch
|
|||
}
|
||||
});
|
||||
|
||||
return $query->orderBy('title')->limit($limit * 3)->get()
|
||||
->filter(fn (Page $page) => $this->tree->isVisible($page->id, $user))
|
||||
->take($limit)
|
||||
->map(fn (Page $page) => [
|
||||
$terms = GlobalSearch::terms($search);
|
||||
$results = [];
|
||||
|
||||
foreach ($query->orderBy('title')->limit($limit * 3)->get() as $page) {
|
||||
if (count($results) >= $limit || ! $this->tree->isVisible($page->id, $user)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Treffer und Auszug nur aus dem, was diese Person auf der Seite sieht
|
||||
// (Blöcke mit eingeschränkter Sichtbarkeit zählen nicht)
|
||||
$text = $this->content->plainText($this->content->render($page->content, $user, ['page_id' => $page->id]));
|
||||
|
||||
if (! collect($terms)->every(fn (string $term) => mb_stripos($page->title.' '.$text, $term) !== false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$results[] = [
|
||||
'title' => $page->title,
|
||||
'url' => $page->url(),
|
||||
'excerpt' => GlobalSearch::excerpt($this->text($page->content), $search),
|
||||
'excerpt' => GlobalSearch::excerpt($text, $search),
|
||||
'meta' => collect($this->tree->ancestors($page->id))->pluck('title')->filter()->implode(' › ') ?: 'Seite',
|
||||
])->values()->all();
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/** Alle Texte aus den Pagebuilder-Blöcken */
|
||||
private function text(mixed $content): string
|
||||
{
|
||||
$parts = [];
|
||||
array_walk_recursive($content, function ($value, $key) use (&$parts) {
|
||||
if (is_string($value) && ! in_array($key, ['type', 'id', 'url', 'image', 'icon', 'layout', 'variant'], true) && ! preg_match('#^(https?:|/|[a-z0-9_.-]+$)#i', $value)) {
|
||||
$parts[] = $value;
|
||||
}
|
||||
});
|
||||
|
||||
return implode(' ', $parts);
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,9 +190,13 @@ class PagesPlugin extends Plugin
|
|||
Field::ids('files', 'Dateien', 'page-file'),
|
||||
])
|
||||
->resolveUsing(function (array $data, ?User $user, array $context) {
|
||||
$files = PageFile::query()->whereIn('id', $data['files'])
|
||||
->when(isset($context['page_id']), fn ($q) => $q->where('page_id', $context['page_id']))
|
||||
->get()->keyBy('id');
|
||||
// Nur Dateien der eigenen Seite – außerhalb einer Seite (Beitrag, Startseite) keine,
|
||||
// sonst ließen sich Namen von Dateien fremder Seiten per Nummer auslesen.
|
||||
if (! isset($context['page_id'])) {
|
||||
return ['files' => []];
|
||||
}
|
||||
|
||||
$files = PageFile::query()->whereIn('id', $data['files'])->where('page_id', $context['page_id'])->get()->keyBy('id');
|
||||
|
||||
return ['files' => collect($data['files'])->map(fn ($id) => $files->get($id)?->toBlockArray())->filter()->values()->all()];
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue