MCPcopy Create free account
hub / github.com/Rello/analytics / ExternalUrlValidatorTest

Class ExternalUrlValidatorTest

tests/Security/ExternalUrlValidatorTest.php:12–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10use PHPUnit\Framework\TestCase;
11
12class 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected