Skip to content

Commit

Permalink
Merge pull request #43650 from Commifreak/log_host_ip_for_access_viol…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
skjnldsv authored Feb 24, 2024
2 parents ef8cf53 + 51739ad commit e79d426
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/private/Http/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected function preventLocalAddress(string $uri, array $options): void {
throw new LocalServerException('Could not detect any host');
}
if (!$this->remoteHostValidator->isValid($host)) {
throw new LocalServerException('Host violates local access rules');
throw new LocalServerException('Host "'.$host.'" violates local access rules');
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/private/Http/Client/DnsPinMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function addDnsPinning() {
foreach ($targetIps as $ip) {
if ($this->ipAddressClassifier->isLocalAddress($ip)) {
// TODO: continue with all non-local IPs?
throw new LocalServerException('Host violates local access rules');
throw new LocalServerException('Host "'.$ip.'" ('.$hostName.':'.$port.') violates local access rules');
}
$curlResolves["$hostName:$port"][] = $ip;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Http/Client/DnsPinMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static function (RequestInterface $request, array $options) {

public function testRejectIPv4() {
$this->expectException(LocalServerException::class);
$this->expectExceptionMessage('Host violates local access rules');
$this->expectExceptionMessage('violates local access rules');

$mockHandler = new MockHandler([
static function (RequestInterface $request, array $options) {
Expand Down Expand Up @@ -334,7 +334,7 @@ static function (RequestInterface $request, array $options) {

public function testRejectIPv6() {
$this->expectException(LocalServerException::class);
$this->expectExceptionMessage('Host violates local access rules');
$this->expectExceptionMessage('violates local access rules');

$mockHandler = new MockHandler([
static function (RequestInterface $request, array $options) {
Expand Down Expand Up @@ -381,7 +381,7 @@ static function (RequestInterface $request, array $options) {

public function testRejectCanonicalName() {
$this->expectException(LocalServerException::class);
$this->expectExceptionMessage('Host violates local access rules');
$this->expectExceptionMessage('violates local access rules');

$mockHandler = new MockHandler([
static function (RequestInterface $request, array $options) {
Expand Down

0 comments on commit e79d426

Please sign in to comment.