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
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use App\Command\RestoreCommand;
|
||||
use App\Infrastructure\ConnectionFactory;
|
||||
use App\Ops\Backup;
|
||||
use App\Ops\CommandRunner;
|
||||
use App\Ops\Updater;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
/**
|
||||
* cms:restore schaltet die Wartung nur ab, wenn es sie selbst eingeschaltet hat.
|
||||
*
|
||||
* Vorher hob der Befehl eine Wartung immer auf - auch die eines offenen Updates oder eine, die
|
||||
* jemand mit Absicht eingeschaltet hatte. Eine halb geschaltete Installation ging damit live.
|
||||
*/
|
||||
final class RestoreCommandTest extends TestCase
|
||||
{
|
||||
private string $root;
|
||||
private Connection $db;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->root = str_replace('\\', '/', sys_get_temp_dir()).'/kant-restore-'.bin2hex(random_bytes(6));
|
||||
mkdir($this->root.'/var/media', 0o775, true);
|
||||
file_put_contents($this->root.'/VERSION', "1.0.0\n");
|
||||
$this->db = ConnectionFactory::create('sqlite:///'.$this->root.'/var/cms.db');
|
||||
TestSchema::build($this->db);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->db->close();
|
||||
gc_collect_cycles();
|
||||
self::remove($this->root);
|
||||
}
|
||||
|
||||
public function testAMaintenanceStateThatWasAlreadyOnStaysOn(): void
|
||||
{
|
||||
file_put_contents($this->root.'/'.Updater::MAINTENANCE_FILE, "an\n");
|
||||
$this->command()->execute(['name' => 'sicherung-gibt-es-nicht'], ['interactive' => false]);
|
||||
self::assertFileExists($this->root.'/'.Updater::MAINTENANCE_FILE);
|
||||
}
|
||||
|
||||
public function testAMaintenanceStateTheCommandSwitchedOnIsSwitchedOffAgain(): void
|
||||
{
|
||||
$this->command()->execute(['name' => 'sicherung-gibt-es-nicht'], ['interactive' => false]);
|
||||
self::assertFileDoesNotExist($this->root.'/'.Updater::MAINTENANCE_FILE);
|
||||
}
|
||||
|
||||
private function command(): CommandTester
|
||||
{
|
||||
$runner = new CommandRunner();
|
||||
$url = 'sqlite:///'.$this->root.'/var/cms.db';
|
||||
|
||||
return new CommandTester(new RestoreCommand(
|
||||
new Backup($this->root, $url, $this->root.'/var/media', $this->db, $runner),
|
||||
new Updater($this->root, $url, $runner, $this->db),
|
||||
));
|
||||
}
|
||||
|
||||
private static function remove(string $path): void
|
||||
{
|
||||
foreach (glob($path.'/{,.}[!.]*', GLOB_BRACE) ?: [] as $entry) {
|
||||
is_dir($entry) ? self::remove($entry) : @unlink($entry);
|
||||
}
|
||||
@rmdir($path);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user