Fix findings of the full security and bug scan
- Update Symfony to 7.4.24/25 and Twig to 3.31.1 (19 advisories), npm ws - Forms: honeypot no longer named "website" (a field labelled Website silently dropped every submission), reserve technical field names, keep single-line fields on one line - Installer: English installations stored pages under "en" and served 404 - Schedules from before ADR 116 no longer publish the latest draft - Moving a page: refuse reserved addresses, claim the version atomically - Content packages: check close(), require all media, verify extracted bytes, clean up on failure, clear the media mirror after import - Updater: failed copies in public/ and plugins/ abort and roll back public/ - Restore: missing media fail the restore; cms:restore keeps maintenance on - Editor preview honours the page's header and footer choice Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4a33090905
commit
33dc413ef6
22 files changed
+659
-246
No files matched your search
@@ -227,6 +227,23 @@ final class EditorSecurityTest extends WebTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testThePreviewHonoursThePagesChoiceOfHeader(): void
|
||||
{
|
||||
// Eine Landingpage ohne Kopf: die Website zeigt keinen, die Vorschau zeigte trotzdem den Standardkopf.
|
||||
$client = $this->login();
|
||||
$data = $this->data($client);
|
||||
$preview = function () use ($client, $data): string {
|
||||
$this->post($client, 'preview', ['document' => $data['document'], 'expectedVersion' => $data['version']], $data['csrfToken']);
|
||||
self::assertResponseIsSuccessful();
|
||||
|
||||
return (string) $client->getResponse()->getContent();
|
||||
};
|
||||
self::assertStringContainsString('area-header', $preview());
|
||||
$this->db->executeStatement("UPDATE page SET header_area = 'none' WHERE id = ?", ['p1']);
|
||||
self::assertStringNotContainsString('area-header', $preview());
|
||||
self::assertStringContainsString('area-footer', $preview(), 'Der Fuß bleibt, wo nur der Kopf abgewählt ist.');
|
||||
}
|
||||
|
||||
private function data(KernelBrowser $client): array
|
||||
{
|
||||
$client->request('GET', '/admin/api/pages/p1');
|
||||
@@ -418,6 +435,24 @@ final class EditorSecurityTest extends WebTestCase
|
||||
self::assertNull($this->db->fetchOne('SELECT publish_revision_id FROM page WHERE id = ?', [$id]));
|
||||
}
|
||||
|
||||
public function testAScheduleFromBeforeTheRevisionColumnDoesNotPublishTheLatestDraft(): void
|
||||
{
|
||||
// Ein Termin aus der Zeit vor ADR 116: publish_at gesetzt, keine Fassung festgehalten.
|
||||
// Danach speichert ein Redakteur einen ungeprüften Entwurf - der ging früher zum Termin online.
|
||||
$pages = new PageRepository($this->db, new DocumentValidator(), new SiteSettings($this->db, new MediaLibrary($this->db, $this->path.'-media')));
|
||||
$id = $pages->createPage('alt-termin', null, 'page', DemoContent::starter('Ungeprüft'));
|
||||
$this->db->executeStatement('UPDATE page SET publish_at = ? WHERE id = ?', ['2026-01-01 08:00:00', $id]);
|
||||
|
||||
$log = ini_set('error_log', \PHP_OS_FAMILY === 'Windows' ? 'NUL' : '/dev/null');
|
||||
try {
|
||||
self::assertSame([], $pages->publishDue());
|
||||
} finally {
|
||||
ini_set('error_log', (string) $log);
|
||||
}
|
||||
self::assertNull($this->db->fetchOne('SELECT published_revision_id FROM page WHERE id = ?', [$id]));
|
||||
self::assertNull($this->db->fetchOne('SELECT publish_at FROM page WHERE id = ?', [$id]), 'Der Termin verfällt, statt ewig fällig zu bleiben.');
|
||||
}
|
||||
|
||||
public function testAdministratorsDeleteAPageWithAllRevisionsOnlyWithACsrfToken(): void
|
||||
{
|
||||
$client = $this->login('admin');
|
||||
@@ -560,7 +595,7 @@ final class EditorSecurityTest extends WebTestCase
|
||||
private function validBody(string $issued): array
|
||||
{
|
||||
return [
|
||||
'page' => 'home', 'block' => 'formblock', 'website' => '',
|
||||
'page' => 'home', 'block' => 'formblock', FormRepository::HONEYPOT => '',
|
||||
'issued' => $issued, 'issuedSignature' => FormRepository::stamp('kontakt', (int) $issued, 'isolated-test-secret'),
|
||||
'name' => 'Umut', 'email' => 'umut@example.com', 'thema' => 'Beratung',
|
||||
'nachricht' => 'Bitte um Rückruf.', 'datenschutz' => 'ja',
|
||||
@@ -578,7 +613,7 @@ final class EditorSecurityTest extends WebTestCase
|
||||
self::assertStringContainsString('<button class="button cms-button" type="submit">Absenden</button>', $html);
|
||||
self::assertStringContainsString('Ich willige ein.', $html);
|
||||
// The honeypot exists but is kept out of the tab order and away from assistive technology.
|
||||
self::assertStringContainsString('name="website"', $html);
|
||||
self::assertStringContainsString('name="'.FormRepository::HONEYPOT.'"', $html);
|
||||
self::assertStringContainsString('tabindex="-1"', $html);
|
||||
self::assertStringNotContainsString('<script', $client->getResponse()->getContent());
|
||||
|
||||
@@ -674,7 +709,9 @@ final class EditorSecurityTest extends WebTestCase
|
||||
public static function droppedSubmissions(): iterable
|
||||
{
|
||||
$sign = static fn (string $issued): string => FormRepository::stamp('kontakt', (int) $issued, 'isolated-test-secret');
|
||||
yield 'honeypot filled' => [static fn (array $body): array => [...$body, 'website' => 'https://spam.example']];
|
||||
yield 'honeypot filled' => [static fn (array $body): array => [...$body, FormRepository::HONEYPOT => 'https://spam.example']];
|
||||
// Eine Seite aus dem Zwischenspeicher trägt noch den alten Namen des Honigtopfs.
|
||||
yield 'old honeypot filled' => [static fn (array $body): array => [...$body, 'website' => 'https://spam.example']];
|
||||
yield 'submitted too fast' => [static fn (array $body): array => [...$body, 'issued' => (string) time(), 'issuedSignature' => $sign((string) time())]];
|
||||
yield 'timestamp forged' => [static fn (array $body): array => [...$body, 'issuedSignature' => 'nicht-signiert']];
|
||||
yield 'timestamp far in the past' => [static function (array $body) use ($sign): array {
|
||||
@@ -697,6 +734,40 @@ final class EditorSecurityTest extends WebTestCase
|
||||
self::assertSame(0, (int) $this->db->fetchOne('SELECT COUNT(*) FROM form_submission'));
|
||||
}
|
||||
|
||||
public function testAFieldNamedWebsiteIsAnsweredNotMistakenForTheHoneypot(): void
|
||||
{
|
||||
// Der Editor macht aus der Beschriftung „Website“ den Namen „website“ - so hieß früher der
|
||||
// Honigtopf, und jede Anfrage mit ausgefüllter Adresse verschwand still.
|
||||
$forms = new FormRepository($this->db);
|
||||
$forms->save('kontakt', 'Kontakt', [
|
||||
['name' => 'email', 'type' => 'email', 'label' => 'E-Mail', 'required' => true],
|
||||
['name' => 'website', 'type' => 'text', 'label' => 'Website', 'required' => false],
|
||||
['name' => 'name', 'type' => 'text', 'label' => 'Name', 'required' => false],
|
||||
], ['recipient' => 'info@kant-it.de', 'subject' => 'Anfrage', 'success' => 'Danke.'], 0);
|
||||
$this->pageWithForm();
|
||||
$client = self::createClient();
|
||||
|
||||
$body = [...$this->validBody((string) (time() - 10)), 'website' => 'https://kunde.example', 'name' => "Max\nE-Mail: chef@firma.example"];
|
||||
$client->request('POST', '/formular/kontakt', $body);
|
||||
self::assertResponseStatusCodeSame(303);
|
||||
$data = json_decode((string) $this->db->fetchOne('SELECT data FROM form_submission'), true);
|
||||
self::assertSame('https://kunde.example', $data['website'] ?? null);
|
||||
// Ein einzeiliges Feld bleibt einzeilig und kann keine Zeile der Benachrichtigung fälschen.
|
||||
self::assertSame('Max E-Mail: chef@firma.example', $data['name'] ?? null);
|
||||
}
|
||||
|
||||
public function testNamesTheFormSendsItselfAreRefusedAsFieldNames(): void
|
||||
{
|
||||
foreach (FormRepository::RESERVED_NAMES as $name) {
|
||||
try {
|
||||
(new FormRepository($this->db))->save('reserviert-'.$name, 'Reserviert', [['name' => $name, 'type' => 'text', 'label' => 'Feld']], ['recipient' => 'info@kant-it.de'], 0);
|
||||
self::fail($name.' wurde als Feldname angenommen.');
|
||||
} catch (InvalidForm $e) {
|
||||
self::assertStringContainsString('reserviert', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testRateLimitStopsTheSixthSubmissionWithinAnHour(): void
|
||||
{
|
||||
$forms = $this->contactForm();
|
||||
|
||||
Reference in new issue
Block a user