Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Model/VersionRange.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@

readonly class VersionRange
{
public const string VERSION_REGEX = '/^(\d+\.)(\d+\.)(\d+)$/';

public function __construct(
private ?string $minVersion,
private ?string $maxVersion,
) {
if ($minVersion !== null && preg_match(self::VERSION_REGEX, $minVersion) === 0) {
throw new InvalidArgumentException('Invalid min version number: ' . $minVersion);
}

if ($maxVersion !== null && preg_match(self::VERSION_REGEX, $maxVersion) === 0) {
throw new InvalidArgumentException('Invalid max version number: ' . $maxVersion);
}

if ($minVersion !== null && $maxVersion !== null && version_compare($minVersion, $maxVersion, '>')) {
throw new InvalidArgumentException('minVersion must be less than or equal to maxVersion');
}
Expand Down
6 changes: 6 additions & 0 deletions src/Service/Scanner/Health/HealthScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Gared\EtherScan\Service\Scanner\Health;

use Gared\EtherScan\Model\Config;
use Gared\EtherScan\Model\VersionRange;
use Gared\EtherScan\Service\ScannerServiceCallbackInterface;
use Gared\EtherScan\Service\VersionRangeService;
use GuzzleHttp\Client;
Expand Down Expand Up @@ -38,6 +39,11 @@ public function scan(Config $config, VersionRangeService $versionRangeService, S
return;
}

if (preg_match(VersionRange::VERSION_REGEX, $healthData['releaseId']) === 0) {
$callback->onHealthException(new HealthResponseException('Invalid version in realeaseId: ' . $healthData['releaseId']));
return;
}

$callback->onHealthResult($healthData);
$versionRangeService->setHealthVersion($healthData['releaseId']);
}
Expand Down
1 change: 1 addition & 0 deletions src/Service/Scanner/PluginDefinitionScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function scan(Config $config, ScannerServiceCallbackInterface $callback):
}

$onlyPlugins = $data['plugins'];
unset($onlyPlugins['ep_etherpad-lite']);
$callback->onScanPluginsList($onlyPlugins);
} catch (JsonException $e) {
$callback->onScanApiException($e);
Expand Down
Loading