mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-07-14 05:45:18 +02:00
b290620cf9
* Declare ext-intl and ext-zip as explicit composer requirements DataExportService uses ZipArchive directly and the Dutch-locale format_datetime Twig filter needs real ext-intl (the polyfill only supports en), but composer.json only declared ext-ctype/ext-iconv. Adding them lets `composer check-platform-reqs` catch a missing extension before a runtime crash. * Add authorization checks to PrepareEliminationController index and viewElimination had no IsGranted guard, unlike every other backoffice/elimination controller, so any authenticated user could prepare or overwrite another season's elimination screens. * Prevent formula injection in spreadsheet exports Answer/candidate text starting with =, +, -, or @ was written to XLSX exports as a live formula rather than plain text. Since seasons can have multiple owners, a co-owner could plant a formula that runs (and can exfiltrate data) when another owner opens the export in Excel. * Add rate limiting to login and season-code entry points Neither /login nor the public season-code guess form (POST /) had any throttling, making both an unlimited brute-force/enumeration oracle. Adds symfony/rate-limiter and enables login_throttling on the main firewall, plus a dedicated per-IP rate limiter on the season-code form. * Add unique constraint to prevent double-submit score inflation A candidate could submit two concurrent POSTs for the same question before either committed, since GivenAnswer had no unique constraint and the "next question" check was subject to a TOCTOU race — each insert was then counted as a correct answer. * Address CodeRabbit review findings Include a Retry-After header on the season-code rate limit, correct stale line references in the security audit doc, and fix a stray comma in the reset-password email.
53 lines
1.9 KiB
PHP
53 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/** Auto-generated Migration: Please modify to your needs! */
|
|
final class Version20260713194340 extends AbstractMigration
|
|
{
|
|
#[\Override]
|
|
public function getDescription(): string
|
|
{
|
|
return 'Denormalize the question onto given_answer and add a partial unique index on (candidate_id, question_id) to prevent duplicate answers for the same question';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE given_answer ADD question_id UUID DEFAULT NULL');
|
|
$this->addSql(<<<'SQL'
|
|
UPDATE given_answer
|
|
SET question_id = answer.question_id
|
|
FROM answer
|
|
WHERE answer.id = given_answer.answer_id
|
|
SQL);
|
|
$this->addSql('ALTER TABLE given_answer ALTER COLUMN question_id SET NOT NULL');
|
|
$this->addSql(<<<'SQL'
|
|
ALTER TABLE
|
|
given_answer
|
|
ADD
|
|
CONSTRAINT FK_9AC61A301E27F6BF FOREIGN KEY (question_id) REFERENCES question (id) NOT DEFERRABLE
|
|
SQL);
|
|
$this->addSql('CREATE INDEX IDX_9AC61A301E27F6BF ON given_answer (question_id)');
|
|
$this->addSql(<<<'SQL'
|
|
CREATE UNIQUE INDEX UNIQ_9AC61A3091BD87811E27F6BF ON given_answer (candidate_id, question_id)
|
|
WHERE
|
|
(deleted_at IS NULL)
|
|
SQL);
|
|
}
|
|
|
|
#[\Override]
|
|
public function down(Schema $schema): void
|
|
{
|
|
// this down() migration is auto-generated, please modify it to your needs
|
|
$this->addSql('ALTER TABLE given_answer DROP CONSTRAINT FK_9AC61A301E27F6BF');
|
|
$this->addSql('DROP INDEX IDX_9AC61A301E27F6BF');
|
|
$this->addSql('DROP INDEX UNIQ_9AC61A3091BD87811E27F6BF');
|
|
$this->addSql('ALTER TABLE given_answer DROP question_id');
|
|
}
|
|
}
|