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

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 11:34:54 +00:00
parent a37895a16a
commit f1202bea08
226 changed files with 1952 additions and 450 deletions

View file

@ -86,11 +86,22 @@ class BirthdayList
*
* @return list<array{date: string, person: array<string, mixed>}>
*/
public function inMonth(int $year, int $month): array
public function inMonth(int $year, int $month, ?User $viewer = null): array
{
$scope = $this->scope();
return Birthday::query()
->where('month', $month)
->whereHas('user', fn ($q) => $q->where('is_active', true))
->whereHas('user', function ($q) use ($viewer, $scope) {
$q->where('is_active', true);
// Derselbe Kreis wie in der Geburtstagsliste (Abteilung bzw. Standort)
if ($viewer && $scope === 'department') {
$viewer->department ? $q->where('department', $viewer->department) : $q->whereKey($viewer->id);
} elseif ($viewer && $scope === 'location') {
$viewer->location ? $q->where('location', $viewer->location) : $q->whereKey($viewer->id);
}
})
->with('user')
->get()
->filter(fn (Birthday $b) => checkdate($month, $b->day, $year) || ($month === 2 && $b->day === 29))

View file

@ -5,6 +5,7 @@ namespace Inhaus\Plugins\Downloads\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Grant;
use App\Support\Audit;
use App\Support\BlockedFiles;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
@ -27,7 +28,7 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
class DownloadController extends Controller
{
/** Nie als Datei annehmen: ausführbarer Code, Webseiten, Skripte. */
private const BLOCKED = ['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', 'msi', 'ps1', 'vbs', 'scr'];
private const BLOCKED = BlockedFiles::EXTENSIONS;
public const MAX_KB = 100 * 1024;

View file

@ -58,7 +58,7 @@ class Calendar
private function escape(string $value): string
{
return str_replace(['\\', ';', ',', "\r\n", "\n"], ['\\\\', '\;', '\\,', '\\n', '\\n'], $value);
return str_replace(['\\', ';', ',', "\r\n", "\n", "\r"], ['\\\\', '\;', '\\,', '\\n', '\\n', '\\n'], $value);
}
/**

View file

@ -3,6 +3,7 @@
namespace Inhaus\Plugins\Events\Filament\Resources\Events;
use App\Filament\Components\AudienceSection;
use App\Filament\Components\SafeUpload;
use BackedEnum;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
@ -86,7 +87,7 @@ class EventResource extends Resource
->schema([
AudienceSection::make('event', 'Wer den Termin sieht. Leer lassen = alle.'),
Toggle::make('is_published')->label('Veröffentlicht')->default(true),
FileUpload::make('image_path')
SafeUpload::apply(FileUpload::make('image_path'))
->label('Bild')
->helperText('Optional, Querformat.')
->image()

View file

@ -75,20 +75,24 @@ class FormResource extends Resource
Toggle::make('settings.once_per_user')->label('Jede Person nur einmal')->inline(false),
Textarea::make('settings.confirmation')->label('Bestätigung nach dem Absenden')->placeholder('Vielen Dank! Ihre Angaben sind eingegangen.')->rows(2)->maxLength(1000)->columnSpanFull(),
Toggle::make('settings.anonymous')->label('Anonym')
->disabled(fn (?Form $record) => $record && ! auth()->user()->can('forms.manage') && ! auth()->user()->can('viewResults', $record))->dehydrated()
->helperText('Name und E-Mail-Adresse werden nicht gespeichert und nicht mitgeschickt – z. B. für Umfragen oder vertrauliche Meldungen an die MAV.')
->columnSpanFull(),
TextInput::make('settings.retention_days')->label('Einsendungen automatisch löschen nach')->numeric()->minValue(1)->maxValue(3650)->suffix('Tagen')
->helperText('Leer = nicht automatisch löschen.'),
]),
Tab::make('Benachrichtigung')->icon(Heroicon::OutlinedEnvelope)->schema([
TagsInput::make('settings.notify_emails')->label('E-Mail an')->placeholder('personal@firma.de')
->nestedRecursiveRules(['email'])
->helperText('Bei jeder Einsendung. Auch Funktionspostfächer möglich.'),
Toggle::make('settings.notify_viewers')->label('Alle mit Zugriff auf die Ergebnisse benachrichtigen (E-Mail und Glocke im Portal)'),
Toggle::make('settings.mail_answers')->label('Angaben in die E-Mail aufnehmen')->default(true)
->helperText('Aus, wenn die Angaben vertraulich sind – die E-Mail enthält dann nur einen Link zu den Ergebnissen.'),
Toggle::make('settings.send_copy')->label('Kopie an die ausfüllende Person'),
]),
Tab::make('Benachrichtigung')->icon(Heroicon::OutlinedEnvelope)
// Empfänger festlegen nur mit Zugriff auf die Ergebnisse
->disabled(fn (?Form $record) => $record && ! auth()->user()->can('forms.manage') && ! auth()->user()->can('viewResults', $record))
->schema([
TagsInput::make('settings.notify_emails')->label('E-Mail an')->placeholder('personal@firma.de')
->nestedRecursiveRules(['email'])
->helperText('Bei jeder Einsendung. Auch Funktionspostfächer möglich.'),
Toggle::make('settings.notify_viewers')->label('Alle mit Zugriff auf die Ergebnisse benachrichtigen (E-Mail und Glocke im Portal)'),
Toggle::make('settings.mail_answers')->label('Angaben in die E-Mail aufnehmen')->default(true)
->helperText('Aus, wenn die Angaben vertraulich sind – die E-Mail enthält dann nur einen Link zu den Ergebnissen.'),
Toggle::make('settings.send_copy')->label('Kopie an die ausfüllende Person'),
]),
Tab::make('Zugriff')->icon(Heroicon::OutlinedLockClosed)->schema([
Section::make('Ergebnisse')
->description('Welche Rollen die Einsendungen dieses Formulars sehen – z. B. nur die Personalabteilung.')

View file

@ -12,6 +12,28 @@ class EditForm extends EditRecord
{
protected static string $resource = FormResource::class;
/** Einstellungen, über die Einsendungen weitergegeben oder Personen erkennbar werden */
public const CONFIDENTIAL_SETTINGS = ['notify_emails', 'notify_viewers', 'mail_answers', 'send_copy', 'anonymous'];
/**
* Wer nur Felder bearbeiten darf (ohne Ergebnis-Rechte), kann Empfänger und Anonymität
* nicht ändern – sonst ließen sich Einsendungen umleiten oder Personen erkennbar machen.
*/
protected function mutateFormDataBeforeSave(array $data): array
{
if (! auth()->user()->can('forms.manage') && ! auth()->user()->can('viewResults', $this->record)) {
foreach (self::CONFIDENTIAL_SETTINGS as $key) {
if (array_key_exists($key, (array) $this->record->settings)) {
$data['settings'][$key] = $this->record->settings[$key];
} else {
unset($data['settings'][$key]);
}
}
}
return $data;
}
protected function getHeaderActions(): array
{
return [

View file

@ -4,6 +4,7 @@ namespace Inhaus\Plugins\Forms\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Support\Audit;
use App\Support\Csv;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Storage;
@ -56,13 +57,13 @@ class FormResultsController extends Controller
}
});
fputcsv($out, ['Eingegangen am', ...($anonymous ? [] : ['Name', 'E-Mail']), ...array_values($known)], ';', '"', '');
fputcsv($out, ['Eingegangen am', ...($anonymous ? [] : ['Name', 'E-Mail']), ...array_map(self::cell(...), array_values($known))], ';', '"', '');
$submissions()->with('user:id,name,email')->orderBy('id')->chunkById(500, function ($chunk) use ($out, $known, $anonymous) {
foreach ($chunk as $submission) {
fputcsv($out, [
$submission->created_at->timezone(config('app.timezone'))->format('d.m.Y H:i'),
...($anonymous ? [] : [$submission->user?->name ?? '', $submission->user?->email ?? '']),
...($anonymous ? [] : [self::cell($submission->user?->name ?? ''), self::cell($submission->user?->email ?? '')]),
...array_map(fn ($key) => self::cell($submission->display($key)), array_keys($known)),
], ';', '"', '');
}
@ -77,6 +78,6 @@ class FormResultsController extends Controller
*/
private static function cell(string $value): string
{
return preg_match('/^[=+\-@\t\r]/', $value) ? "'".$value : $value;
return Csv::cell($value);
}
}

View file

@ -3,6 +3,7 @@
namespace Inhaus\Plugins\Gemeinsam\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Plugins\PluginAccess;
use App\Plugins\PluginManager;
use App\Support\Audit;
use Illuminate\Http\RedirectResponse;
@ -27,11 +28,12 @@ class GemeinsamController extends Controller
foreach (Entry::SECTIONS as $key => $title) {
if ($key === 'birthdays') {
if (! app(PluginManager::class)->isLoaded('birthdays')) {
// Wie das Geburtstags-Modul selbst: nicht für ausgeschlossene Rollen, nur im eingestellten Kreis
if (! app(PluginManager::class)->isLoaded('birthdays') || ! app(PluginAccess::class)->allows('birthdays', $request->user())) {
continue;
}
$rows = app(BirthdayList::class)->inMonth($month->year, $month->month);
$rows = app(BirthdayList::class)->inMonth($month->year, $month->month, $request->user());
$sections[] = ['key' => $key, 'title' => $title, 'automatic' => true, 'entries' => array_map(fn ($row) => [
'id' => 'b'.$row['person']['id'],
'date' => $row['date'],

View file

@ -4,6 +4,7 @@ namespace Inhaus\Plugins\ItService\OpenNit;
use App\Support\Settings as PortalSettings;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Validation\ValidationException;
use Throwable;
/**
@ -75,6 +76,11 @@ class Settings
*/
public function save(array $data): void
{
// Neue Adresse: Token und Secret neu eingeben – sonst gingen die gespeicherten an den neuen Server
if (self::normalizeUrl($data['url']) !== $this->url() && $this->token() !== '' && (blank($data['token'] ?? null) || blank($data['secret'] ?? null))) {
throw ValidationException::withMessages(['data.token' => 'Die Adresse wurde geändert – bitte Token und Signier-Secret erneut eingeben.']);
}
$this->settings->set(self::URL, self::normalizeUrl($data['url']));
foreach ([self::TOKEN => $data['token'] ?? null, self::SECRET => $data['secret'] ?? null] as $key => $value) {

View file

@ -20,10 +20,9 @@ class NativeLdapConnector implements LdapConnector
$port = $options['port'] ?: ($scheme === 'ldaps' ? 636 : 389);
$uris = implode(' ', array_map(fn ($host) => str_contains($host, '://') ? $host : "{$scheme}://{$host}:{$port}", $options['hosts']));
if (! $options['verify_tls']) {
// Muss vor ldap_connect gesetzt werden, damit es für die Verbindung gilt.
ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
}
// Muss vor ldap_connect gesetzt werden und gilt prozessweit – deshalb immer ausdrücklich
// setzen, sonst prüften nach einem Server ohne Prüfung auch spätere Verbindungen nicht mehr.
ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, $options['verify_tls'] ? LDAP_OPT_X_TLS_DEMAND : LDAP_OPT_X_TLS_NEVER);
$link = ldap_connect($uris);

View file

@ -132,6 +132,11 @@ class LdapDriver extends IdentityDriver
return ['bind_password'];
}
public function destinationFields(): array
{
return ['hosts', 'port', 'bind_dn', 'encryption'];
}
public function defaultAttributeMap(): array
{
return LdapDirectory::DEFAULT_MAPS['ad'];

View file

@ -0,0 +1,28 @@
<?php
use App\Pagebuilder\Content;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
/**
* Suchtext der Beiträge neu erzeugen – ohne Blöcke mit eingeschränkter Sichtbarkeit
* (vorher landete auch deren Text in Suche und Auszügen).
*/
return new class extends Migration
{
public function up(): void
{
$content = app(Content::class);
DB::table('news_posts')->whereNotNull('content')->orderBy('id')->each(function ($post) use ($content) {
$blocks = json_decode((string) $post->content, true);
if (! is_array($blocks)) {
return;
}
$text = $content->plainText($blocks, publicOnly: true);
DB::table('news_posts')->where('id', $post->id)->update(['body' => $text !== '' ? '<p>'.e($text).'</p>' : null]);
});
}
};

View file

@ -8,7 +8,7 @@ use Inhaus\Plugins\News\Http\Controllers\NewsEditorController;
Route::middleware('auth')->group(function () {
Route::get('/neuigkeiten', [NewsController::class, 'index'])->name('news.index');
Route::get('/neuigkeiten/{post:slug}', [NewsController::class, 'show'])->name('news.show');
Route::post('/neuigkeiten/{post:slug}/kommentare', [NewsCommentController::class, 'store'])->name('news.comments.store');
Route::post('/neuigkeiten/{post:slug}/kommentare', [NewsCommentController::class, 'store'])->middleware('throttle:20,1')->name('news.comments.store');
Route::put('/kommentare/{comment}', [NewsCommentController::class, 'update'])->name('news.comments.update');
Route::delete('/kommentare/{comment}', [NewsCommentController::class, 'destroy'])->name('news.comments.destroy');
@ -16,7 +16,7 @@ Route::middleware('auth')->group(function () {
Route::get('/neu', 'create')->name('create');
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('/{post}', 'edit')->name('edit');
Route::put('/{post}', 'update')->name('update');
Route::delete('/{post}', 'destroy')->name('destroy');

View file

@ -2,6 +2,7 @@
namespace Inhaus\Plugins\News\Filament\Resources\NewsPosts;
use App\Filament\Components\SafeUpload;
use BackedEnum;
use Filament\Actions\Action;
use Filament\Actions\DeleteAction;
@ -112,7 +113,7 @@ class NewsPostResource extends Resource
->options(fn () => FormEmbed::options())
->visible(fn () => FormEmbed::available())
->searchable(),
FileUpload::make('cover_path')
SafeUpload::apply(FileUpload::make('cover_path'))
->label('Titelbild')
->helperText('Querformat, mindestens 1600 × 900 Pixel.')
->image()

View file

@ -44,7 +44,7 @@ class NewsApiController extends Controller
'author' => $post->author ? ['id' => $post->author->id, 'name' => $post->author->name, 'avatar_url' => $post->author->avatarUrl(96)] : null,
// Inhalt als Blöcke (wie im Pagebuilder) und als reiner Text
'blocks' => $rendered['blocks'],
'text' => $content->plainText($post->blocks()),
'text' => $content->plainText($rendered),
]]);
}
}

View file

@ -49,6 +49,9 @@ class NewsCommentController extends Controller
public function update(Request $request, NewsComment $comment): RedirectResponse
{
abort_unless($comment->user_id === $request->user()->id, 403);
// Nur solange der Beitrag sichtbar ist und Kommentare offen sind
$post = $comment->post;
abort_unless($post && $post->comments_enabled && $post->isPublished() && $post->isVisibleTo($request->user()), 403, 'Kommentare sind für diesen Beitrag geschlossen.');
$data = $request->validate(['body' => ['required', 'string', 'max:'.NewsComment::MAX_LENGTH]], [], ['body' => 'Kommentar']);
$comment->forceFill(['body' => trim($data['body']), 'edited_at' => now()])->save();

View file

@ -165,7 +165,8 @@ class NewsEditorController extends Controller
}
$content = $this->content->sanitize(json_decode($data['content'] ?? '[]', true) ?: []);
$text = $this->content->plainText($content);
// Nur allgemein sichtbare Blöcke – der Text dient Suche und Auszügen für alle
$text = $this->content->plainText($content, publicOnly: true);
$post->fill([
'title' => $data['title'],

View file

@ -26,9 +26,14 @@ class NewsPostPolicy
return $user->can('news.manage') || ($post->category_id && $user->can('news.post.create', ['news_category', $post->category_id]));
}
/**
* Veröffentlichte Beiträge löscht nur, wer in der Kategorie veröffentlichen darf
* (gilt im Portal und im Backend gleichermaßen).
*/
public function delete(User $user, NewsPost $post): bool
{
return $this->update($user, $post);
return $this->update($user, $post)
&& ($post->status !== NewsPost::PUBLISHED || $this->publish($user, $post->category_id));
}
public function publish(User $user, ?int $categoryId): bool

View file

@ -56,6 +56,11 @@ class OidcClient
if (! is_string($document[$field] ?? null) || $document[$field] === '') {
throw new IdentityException("Das Discovery-Dokument des Anmeldedienstes enthält kein „{$field}“.");
}
// Schlüssel und Tokens nur über HTTPS – sonst ließen sie sich unterwegs austauschen
if (! self::secureUrl($document[$field])) {
throw new IdentityException("„{$field}“ des Anmeldedienstes muss mit https:// beginnen.");
}
}
// Der Aussteller muss exakt der konfigurierten Adresse entsprechen (OIDC Discovery 4.3).
@ -233,4 +238,11 @@ class OidcClient
{
return Http::timeout(15)->connectTimeout(5)->acceptJson();
}
/** https – nur auf dem eigenen Rechner (Entwicklung) auch http */
public static function secureUrl(string $url): bool
{
return str_starts_with(strtolower($url), 'https://')
|| (app()->environment('local', 'testing') && preg_match('#^http://(localhost|127\.0\.0\.1)(:\d+)?(/|$)#i', $url));
}
}

View file

@ -51,6 +51,7 @@ class OidcDriver extends IdentityDriver
{
return [
TextInput::make('config.issuer')->label('Aussteller (Issuer-URL)')->required()->url()->maxLength(255)
->rule(fn () => fn (string $attribute, mixed $value, \Closure $fail) => OidcClient::secureUrl((string) $value) ? null : $fail('Bitte eine https://-Adresse angeben.'))
->placeholder('https://login.firma.de/realms/mitarbeitende')
->helperText('Die Adresse, unter der /.well-known/openid-configuration liegt.')
->columnSpanFull(),
@ -75,6 +76,11 @@ class OidcDriver extends IdentityDriver
return ['client_secret'];
}
public function destinationFields(): array
{
return ['issuer'];
}
public function defaultAttributeMap(): array
{
return ['first_name' => 'given_name', 'last_name' => 'family_name', 'email' => 'email'];
@ -172,6 +178,9 @@ class OidcDriver extends IdentityDriver
'email' => 'email',
]);
// Hat der Anbieter die Adresse bestätigt? (für das Verknüpfen bestehender Konten)
$profile['email_verified'] = in_array($claims['email_verified'] ?? null, [true, 'true'], true);
return new ExternalUser(
subject: $subject,
profile: $profile,

View file

@ -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');
});
});

View file

@ -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.'/');
}
}

View file

@ -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) {}

View file

@ -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()

View file

@ -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;
}
}

View file

@ -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()];
}));

View file

@ -2,6 +2,7 @@
namespace Inhaus\Plugins\Qm\Filament\Resources\QmFolders;
use App\Filament\Components\SafeUpload;
use App\Support\Icons;
use BackedEnum;
use Filament\Actions\Action;
@ -83,9 +84,8 @@ class QmFolderResource extends Resource
->getOptionLabelUsing(fn (?string $value) => $value ? Icons::option($value) : null)
->placeholder(fn (Get $get) => blank($get('parent_id')) ? 'Ordner' : 'Vom übergeordneten Ordner übernehmen')
->helperText('Alle 1.800+ Symbole über die Suche (englische Namen).'),
FileUpload::make('icon_path')->label('Oder eigenes Symbol hochladen')
->disk('uploads')->directory('qm-icons')->visibility('public')
->acceptedFileTypes(['image/svg+xml', 'image/png', 'image/webp', 'image/jpeg'])->maxSize(1024)
SafeUpload::apply(FileUpload::make('icon_path'), ['image/svg+xml', 'image/png', 'image/webp', 'image/jpeg'])->label('Oder eigenes Symbol hochladen')
->disk('uploads')->directory('qm-icons')->visibility('public')->maxSize(1024)
->helperText('SVG (empfohlen), PNG, WebP oder JPG, quadratisch. Ersetzt das Symbol aus der Auswahl.')
->live(),
Toggle::make('icon_mono')->label('Eigenes Symbol einfarbig darstellen')->default(true)

View file

@ -4,6 +4,7 @@ namespace Inhaus\Plugins\Qm\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Support\Audit;
use App\Support\Csv;
use App\Support\RichText;
use App\Support\Settings;
use Carbon\Carbon;
@ -112,7 +113,7 @@ class QmController extends Controller
$rows[] = [$p['name'], $p['department'], $p['job_title'], 'offen', ''];
}
$csv = "\u{FEFF}".collect($rows)->map(fn (array $row) => implode(';', array_map(fn ($v) => '"'.str_replace('"', '""', (string) $v).'"', $row)))->implode("\r\n");
$csv = "\u{FEFF}".collect($rows)->map(fn (array $row) => implode(';', array_map(fn ($v) => '"'.str_replace('"', '""', Csv::cell($v)).'"', $row)))->implode("\r\n");
return response($csv, 200, [
'Content-Type' => 'text/csv; charset=UTF-8',

View file

@ -90,8 +90,8 @@ class Ocr
{
$binary = trim((string) $this->settings->get(self::SETTING_BINARY, '')) ?: 'tesseract';
// Nur ein Programmname oder ein absoluter Pfad – keine Parameter.
return preg_match('#^(/[\w./-]+|[\w.-]+)$#', $binary) ? $binary : 'tesseract';
// Nur Tesseract selbst (Programmname oder absoluter Pfad dazu) – kein beliebiges Programm.
return preg_match('#^(/[\w./-]+/)?tesseract(\.exe)?$#', $binary) ? $binary : 'tesseract';
}
private function rasterizer(bool $exec): ?string

View file

@ -119,7 +119,11 @@ class SamlService
*/
public function importMetadata(string $url, ?string $entityId = null): array
{
$response = Http::timeout(15)->connectTimeout(5)->get($url);
if (! str_starts_with(strtolower($url), 'https://')) {
throw new IdentityException('Die Metadaten-Adresse muss mit https:// beginnen.');
}
$response = Http::timeout(15)->connectTimeout(5)->withOptions(['allow_redirects' => ['max' => 3, 'protocols' => ['https']]])->get($url);
if (! $response->successful()) {
throw new IdentityException('Metadaten nicht abrufbar (HTTP '.$response->status().').');

View file

@ -4,6 +4,7 @@ namespace Inhaus\Plugins\Stellen;
use App\Models\User;
use App\Notifications\PortalNotification;
use App\Plugins\PluginAccess;
use Illuminate\Support\Facades\Notification;
use Inhaus\Plugins\Stellen\Models\JobPosting;
@ -27,7 +28,12 @@ class Announcer
'briefcase',
);
User::query()->active()->whereKeyNot($posting->created_by ?? 0)->chunkById(500, fn ($users) => Notification::send($users, $notification));
// Nicht an Rollen, die vom Modul „Stellen“ ausgeschlossen sind
$excluded = app(PluginAccess::class)->excludedRoles('stellen');
User::query()->active()->whereKeyNot($posting->created_by ?? 0)
->when($excluded !== [], fn ($q) => $q->whereDoesntHave('roles', fn ($r) => $r->whereIn('roles.id', $excluded)))
->chunkById(500, fn ($users) => Notification::send($users, $notification));
}
public function announceDue(): int

View file

@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\File;
use Illuminate\Validation\ValidationException;
use Inertia\Inertia;
use Inertia\Response;
use Inhaus\Plugins\Stellen\Announcer;
@ -172,6 +173,11 @@ class JobEditorController extends Controller
'title' => 'Titel', 'deadline' => 'Bewerbungsfrist', 'apply_url' => 'Link', 'apply_email' => 'E-Mail-Adresse', 'notify_email' => 'E-Mail', 'pdf' => 'PDF',
]);
// Die Ansprechperson sieht alle Bewerbungen – sich selbst eintragen nur mit „Bewerbungen einsehen“
if ((int) ($data['contact_id'] ?? 0) === $request->user()->id && ! $request->user()->can('jobs.applications')) {
throw ValidationException::withMessages(['contact_id' => 'Sich selbst als Ansprechperson eintragen darf nur, wer Bewerbungen einsehen darf.']);
}
$url = $data['apply_mode'] === 'link' ? Field::safeUrl($data['apply_url'] ?? '') : '';
return [

View file

@ -3,6 +3,7 @@
namespace Inhaus\Plugins\WordpressImport;
use App\Support\Images;
use App\Support\SafeOutbound;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
@ -65,12 +66,26 @@ class MediaDownloader
return $known;
}
// Keine internen Adressen abrufen (die URLs stammen aus der hochgeladenen Exportdatei)
if (! SafeOutbound::isPublicUrl($url)) {
return null;
}
$tmp = tempnam(sys_get_temp_dir(), 'wpimg');
try {
$response = Http::timeout(20)->connectTimeout(10)->get($url);
// Beim Überschreiten der Größe schon während des Ladens abbrechen
$response = Http::timeout(20)->connectTimeout(10)->withOptions([
...SafeOutbound::options(),
'progress' => function ($total, $downloaded) {
if ($total > self::MAX_BYTES || $downloaded > self::MAX_BYTES) {
throw new \RuntimeException('Datei zu groß');
}
},
])->get($url);
$mime = strtolower(explode(';', (string) $response->header('Content-Type'))[0]);
$extension = ['image/jpeg' => 'jpg', 'image/png' => 'png', 'image/gif' => 'gif', 'image/webp' => 'webp'][$mime] ?? null;
$body = $response->successful() ? $response->body() : '';
if (! $extension || $body === '' || strlen($body) > self::MAX_BYTES) {

View file

@ -29,6 +29,11 @@ class WxrReader
{
$reader = new XMLReader;
// Keine eigenen Entitäten (Schutz vor „Billion Laughs“ – WordPress-Exporte nutzen keine)
if (str_contains((string) @file_get_contents($file, false, null, 0, 65536), '<!ENTITY')) {
throw new RuntimeException('Die Datei enthält nicht unterstützte XML-Entitäten.');
}
if (! @$reader->open($file, null, LIBXML_NONET | LIBXML_COMPACT | LIBXML_PARSEHUGE)) {
throw new RuntimeException('Die Datei konnte nicht gelesen werden.');
}