assertRejected('127.0.0.1', 'Loopback-IP (127.0.0.1) wird abgelehnt'); $this->assertRejected('localhost', 'localhost wird abgelehnt'); $this->assertRejected('10.0.0.5', 'RFC1918-IP (10.0.0.5) wird abgelehnt'); $this->assertRejected('192.168.1.1', 'RFC1918-IP (192.168.1.1) wird abgelehnt'); $this->assertRejected('169.254.169.254', 'Link-Local/Metadata-IP (169.254.169.254) wird abgelehnt'); $this->assertRejected('[::1]', 'IPv6-Loopback wird abgelehnt'); $this->assertRejected('', 'Leerer Host wird abgelehnt'); // Öffentliche IP-Literale werden akzeptiert try { SsrfGuard::assertPublicHost('8.8.8.8'); $this->assert(true, 'Öffentliches IP-Literal (8.8.8.8) wird akzeptiert'); } catch (\RuntimeException $e) { $this->assert(false, 'Öffentliches IP-Literal (8.8.8.8) wird akzeptiert (Fehler: ' . $e->getMessage() . ')'); } } private function assertRejected(string $host, string $message): void { try { SsrfGuard::assertPublicHost($host); $this->assert(false, $message); } catch (\RuntimeException $e) { $this->assert(true, $message); } } }