Loheide-eu-mitarbeiterplatt.../tests/Unit/SafeOutboundTest.php
Friederich Loheide f1202bea08
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
Sicherheitsupdate nach Audit (0.29.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 11:34:54 +00:00

23 lines
1 KiB
PHP

<?php
namespace Tests\Unit;
use App\Support\SafeOutbound;
use PHPUnit\Framework\TestCase;
class SafeOutboundTest extends TestCase
{
public function test_internal_targets_are_rejected(): void
{
SafeOutbound::fakeResolve(['public.test' => '93.184.216.34', 'rebind.test' => ['93.184.216.34', '10.0.0.1']]);
$this->assertTrue(SafeOutbound::isPublicUrl('https://public.test/bild.jpg'));
$this->assertFalse(SafeOutbound::isPublicUrl('https://rebind.test/x'), 'eine interne Adresse genügt');
foreach (['http://127.0.0.1/', 'http://localhost/', 'http://10.1.2.3/', 'http://192.168.0.5/', 'http://169.254.169.254/latest/meta-data/', 'http://[::1]/', 'http://[fd00::1]/', 'ftp://public.test/', 'http://user@public.test/', 'https://intranet.local/', 'file:///etc/passwd', 'http://nichtaufloesbar.invalid/'] as $url) {
$this->assertFalse(SafeOutbound::isPublicUrl($url), $url);
}
$this->assertFalse(SafeOutbound::isPublicUrl('http://public.test/', ['https']), 'nur https erlaubt');
}
}