PHP fissato alla 8.3.36 (CVE-2026-109618, CVE-2026-109619)
- Dockerfile: ARG PHP_VERSION=8.3.36 e FROM php:${PHP_VERSION}-fpm al posto
del tag mobile php:8.3-fpm, che la cache di Docker poteva risolvere sulla
8.3.35 vulnerabile. Una build ora prende la versione corretta o fallisce.
- phpredis da GitHub (versione fissata) invece di pecl.php.net, che il
giorno della patch rispondeva 504 e bloccava la build.
- Test contro il ritorno a un tag mobile o a una versione vulnerabile.
- PHP_VERSION passabile dal compose solo per prove locali.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
44
tests/Unit/VersionePhpTest.php
Normal file
44
tests/Unit/VersionePhpTest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* L'immagine deve partire da una versione di PHP fissata alla patch, e mai
|
||||
* sotto quella che corregge CVE-2026-109618 e CVE-2026-109619 (esecuzione di
|
||||
* codice da remoto nel core di PHP, 21/10/2026). Con un tag che si sposta
|
||||
* ("8.3-fpm") la cache di Docker poteva riusare una base vulnerabile.
|
||||
*/
|
||||
class VersionePhpTest extends TestCase
|
||||
{
|
||||
private const MINIMA = '8.3.36';
|
||||
|
||||
private function dockerfile(): string
|
||||
{
|
||||
return (string) file_get_contents(dirname(__DIR__, 2) . '/docker/php/Dockerfile');
|
||||
}
|
||||
|
||||
public function test_la_versione_di_php_e_fissata_e_corretta(): void
|
||||
{
|
||||
// \s* prima di $: nella copia di lavoro su Windows il file ha CRLF.
|
||||
$this->assertMatchesRegularExpression('/^ARG PHP_VERSION=(\d+\.\d+\.\d+)\s*$/m', $this->dockerfile());
|
||||
|
||||
preg_match('/^ARG PHP_VERSION=(\d+\.\d+\.\d+)\s*$/m', $this->dockerfile(), $trovata);
|
||||
|
||||
$this->assertTrue(
|
||||
version_compare($trovata[1], self::MINIMA, '>='),
|
||||
"PHP {$trovata[1]} è vulnerabile a CVE-2026-109618/109619: serve almeno " . self::MINIMA . '.',
|
||||
);
|
||||
}
|
||||
|
||||
public function test_l_immagine_usa_la_versione_fissata_e_non_un_tag_mobile(): void
|
||||
{
|
||||
preg_match_all('/^FROM php:(\S+)/m', $this->dockerfile(), $basi);
|
||||
|
||||
$this->assertNotEmpty($basi[1]);
|
||||
foreach ($basi[1] as $tag) {
|
||||
$this->assertStringStartsWith('${PHP_VERSION}', $tag, "FROM php:{$tag}: usa ARG PHP_VERSION, non un tag che si sposta.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user