| 10 | use PHPUnit\Framework\TestCase; |
| 11 | |
| 12 | class ExternalUrlValidatorTest extends TestCase { |
| 13 | /** |
| 14 | * @dataProvider blockedUrls |
| 15 | */ |
| 16 | public function testValidateRejectsPrivateAndReservedTargets(string $url): void { |
| 17 | $this->assertNotNull(ExternalUrlValidator::validate($url)); |
| 18 | } |
| 19 | |
| 20 | public function blockedUrls(): array { |
| 21 | return [ |
| 22 | 'localhost' => ['http://localhost/status'], |
| 23 | 'loopback' => ['http://127.0.0.1/status'], |
| 24 | 'private ipv4' => ['http://192.168.1.10/status'], |
| 25 | 'link local' => ['http://169.254.169.254/latest/meta-data'], |
| 26 | 'ipv6 loopback' => ['http://[::1]/status'], |
| 27 | 'ipv4-mapped ipv6 loopback' => ['http://[::ffff:127.0.0.1]/status'], |
| 28 | 'ipv4-mapped ipv6 metadata' => ['http://[::ffff:169.254.169.254]/latest/meta-data'], |
| 29 | 'userinfo' => ['https://user:password@example.com/data'], |
| 30 | 'file scheme' => ['file:///etc/passwd'], |
| 31 | ]; |
| 32 | } |
| 33 | } |
nothing calls this directly
no outgoing calls
no test coverage detected