🤖 Auto commit for release 'develop' on 2026-03-06

This commit is contained in:
JC5
2026-03-06 06:37:08 +01:00
parent 7f08a3f594
commit 36d20137b2
9 changed files with 56 additions and 53 deletions

View File

@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace FireflyIII\Rules\Webhook;
use Closure;
@@ -7,6 +9,7 @@ use FireflyIII\Support\Facades\FireflyConfig;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpFoundation\IpUtils;
use function Safe\parse_url;
class IsValidWebhookUrl implements ValidationRule
@@ -16,13 +19,14 @@ class IsValidWebhookUrl implements ValidationRule
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$value = (string)$value;
$resolved = gethostbyname(parse_url($value, PHP_URL_HOST));
$value = (string) $value;
$resolved = gethostbyname(parse_url($value, PHP_URL_HOST));
Log::debug(sprintf('Now validating URL "%s" with IP "%s".', $value, $resolved));
// IPv4 is allowed to be in 127 range.
if(filter_var($resolved, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && IpUtils::checkIp4($resolved, '127.0.0.0/8')) {
if (filter_var($resolved, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && IpUtils::checkIp4($resolved, '127.0.0.0/8')) {
Log::debug(sprintf('Local IP "%s" is allowed', $resolved));
return;
}
@@ -31,16 +35,15 @@ class IsValidWebhookUrl implements ValidationRule
$fail('validation.no_reserved_ip')->translate();
}
$validProtocols = FireflyConfig::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;
$parts = explode(',', $validProtocols);
$valid = false;
foreach($parts as $part) {
if(str_starts_with($value, $part)) {
$parts = explode(',', $validProtocols);
$valid = false;
foreach ($parts as $part) {
if (str_starts_with($value, $part)) {
$valid = true;
}
}
if(false === $valid) {
if (false === $valid) {
$fail('validation.bad_url_prefix')->translate();
}
}
}