diff --git a/composer.json b/composer.json index 9a99367..a0e1ed5 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,10 @@ "doctrine/doctrine-bundle": "^2.12", "doctrine/doctrine-migrations-bundle": "^3.3", "doctrine/orm": "^3.2", - "eluceo/ical": "^2.13", + "eluceo/ical": "^2.14", "phpdocumentor/reflection-docblock": "^5.4", "phpstan/phpdoc-parser": "^1.29", + "protonlabs/vobject": "^4.31", "psr/http-client": "^1.0", "symfony/asset": "7.1.*", "symfony/asset-mapper": "7.1.*", diff --git a/composer.lock b/composer.lock index a86afd5..91684d1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5f504b40613dac0da1ea6c1dc972bbe8", + "content-hash": "139867d77c0de3a6d8dfd5df9210b52b", "packages": [ { "name": "composer/semver", @@ -1763,6 +1763,110 @@ }, "time": "2024-05-31T08:52:43+00:00" }, + { + "name": "protonlabs/vobject", + "version": "4.31.0", + "source": { + "type": "git", + "url": "https://github.com/ProtonMail/vobject.git", + "reference": "3ff67e1d409ca0772ae5f6acb717e36568236499" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ProtonMail/vobject/zipball/3ff67e1d409ca0772ae5f6acb717e36568236499", + "reference": "3ff67e1d409ca0772ae5f6acb717e36568236499", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "php": "^7.4 || ^8.0", + "sabre/xml": "^3.0 || ^4.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.54", + "phpstan/phpstan": "^1.11", + "phpunit/php-invoker": "^2.0 || ^3.1", + "phpunit/phpunit": "^9.6" + }, + "suggest": { + "hoa/bench": "If you would like to run the benchmark scripts" + }, + "bin": [ + "bin/vobject", + "bin/generate_vcards" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Sabre\\VObject\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + }, + { + "name": "Dominik Tobschall", + "email": "dominik@fruux.com", + "homepage": "http://tobschall.de/", + "role": "Developer" + }, + { + "name": "Ivan Enderlin", + "email": "ivan.enderlin@hoa-project.net", + "homepage": "http://mnt.io/", + "role": "Developer" + } + ], + "description": "The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects", + "homepage": "http://sabre.io/vobject/", + "keywords": [ + "availability", + "freebusy", + "iCalendar", + "ical", + "ics", + "jCal", + "jCard", + "recurrence", + "rfc2425", + "rfc2426", + "rfc2739", + "rfc4770", + "rfc5545", + "rfc5546", + "rfc6321", + "rfc6350", + "rfc6351", + "rfc6474", + "rfc6638", + "rfc6715", + "rfc6868", + "vCalendar", + "vCard", + "vcf", + "xCal", + "xCard" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "source": "https://github.com/fruux/sabre-vobject" + }, + "time": "2024-06-28T11:20:50+00:00" + }, { "name": "psr/cache", "version": "3.0.0", @@ -2174,6 +2278,135 @@ }, "time": "2021-07-14T16:46:02+00:00" }, + { + "name": "sabre/uri", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/uri.git", + "reference": "1774043c843f1db7654ecc93368a98be29b07544" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/uri/zipball/1774043c843f1db7654ecc93368a98be29b07544", + "reference": "1774043c843f1db7654ecc93368a98be29b07544", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.17", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan": "^1.10", + "phpstan/phpstan-phpunit": "^1.3", + "phpstan/phpstan-strict-rules": "^1.5", + "phpunit/phpunit": "^9.6" + }, + "type": "library", + "autoload": { + "files": [ + "lib/functions.php" + ], + "psr-4": { + "Sabre\\Uri\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + } + ], + "description": "Functions for making sense out of URIs.", + "homepage": "http://sabre.io/uri/", + "keywords": [ + "rfc3986", + "uri", + "url" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/uri/issues", + "source": "https://github.com/fruux/sabre-uri" + }, + "time": "2023-06-09T07:04:02+00:00" + }, + { + "name": "sabre/xml", + "version": "4.0.5", + "source": { + "type": "git", + "url": "https://github.com/sabre-io/xml.git", + "reference": "c29e49fcf9ca8ca058b1e350ee9abe4205c0de89" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sabre-io/xml/zipball/c29e49fcf9ca8ca058b1e350ee9abe4205c0de89", + "reference": "c29e49fcf9ca8ca058b1e350ee9abe4205c0de89", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "lib-libxml": ">=2.6.20", + "php": "^7.4 || ^8.0", + "sabre/uri": ">=2.0,<4.0.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.51", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.6" + }, + "type": "library", + "autoload": { + "files": [ + "lib/Deserializer/functions.php", + "lib/Serializer/functions.php" + ], + "psr-4": { + "Sabre\\Xml\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Evert Pot", + "email": "me@evertpot.com", + "homepage": "http://evertpot.com/", + "role": "Developer" + }, + { + "name": "Markus Staab", + "email": "markus.staab@redaxo.de", + "role": "Developer" + } + ], + "description": "sabre/xml is an XML library that you may not hate.", + "homepage": "https://sabre.io/xml/", + "keywords": [ + "XMLReader", + "XMLWriter", + "dom", + "xml" + ], + "support": { + "forum": "https://groups.google.com/group/sabredav-discuss", + "issues": "https://github.com/sabre-io/xml/issues", + "source": "https://github.com/fruux/sabre-xml" + }, + "time": "2024-04-18T10:44:25+00:00" + }, { "name": "symfony/asset", "version": "v7.1.1", diff --git a/src/Config/DomainStatus.php b/src/Config/DomainStatus.php deleted file mode 100644 index c905c1a..0000000 --- a/src/Config/DomainStatus.php +++ /dev/null @@ -1,47 +0,0 @@ -status; diff --git a/src/Entity/NameserverEntity.php b/src/Entity/NameserverEntity.php index b637285..a71b6ef 100644 --- a/src/Entity/NameserverEntity.php +++ b/src/Entity/NameserverEntity.php @@ -3,7 +3,6 @@ namespace App\Entity; use App\Config\DomainRole; -use App\Config\DomainStatus; use App\Repository\NameserverEntityRepository; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; @@ -25,7 +24,7 @@ class NameserverEntity #[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainRole::class)] private array $roles = []; - #[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)] + #[ORM\Column(type: Types::SIMPLE_ARRAY)] private array $status = []; public function getNameserver(): ?Nameserver @@ -67,9 +66,6 @@ class NameserverEntity return $this; } - /** - * @return DomainStatus[] - */ public function getStatus(): array { return $this->status; diff --git a/src/Service/RDAPService.php b/src/Service/RDAPService.php index 7e11025..dbd4e39 100644 --- a/src/Service/RDAPService.php +++ b/src/Service/RDAPService.php @@ -4,7 +4,6 @@ namespace App\Service; use App\Config\DomainRole; -use App\Config\DomainStatus; use App\Config\EventAction; use App\Entity\Domain; use App\Entity\DomainEntity; @@ -27,19 +26,19 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use Throwable; -class RDAPService +readonly class RDAPService { - public function __construct(private readonly HttpClientInterface $client, - private readonly EntityRepository $entityRepository, - private readonly DomainRepository $domainRepository, - private readonly DomainEventRepository $domainEventRepository, - private readonly NameserverRepository $nameserverRepository, - private readonly NameserverEntityRepository $nameserverEntityRepository, - private readonly EntityEventRepository $entityEventRepository, - private readonly DomainEntityRepository $domainEntityRepository, - private readonly EntityManagerInterface $em, - private readonly ParameterBagInterface $params + public function __construct(private HttpClientInterface $client, + private EntityRepository $entityRepository, + private DomainRepository $domainRepository, + private DomainEventRepository $domainEventRepository, + private NameserverRepository $nameserverRepository, + private NameserverEntityRepository $nameserverEntityRepository, + private EntityEventRepository $entityEventRepository, + private DomainEntityRepository $domainEntityRepository, + private EntityManagerInterface $em, + private ParameterBagInterface $params ) { @@ -53,7 +52,7 @@ class RDAPService $idnDomain = idn_to_ascii($fqdn); try { $rdapServer = $this->getRDAPServer(RDAPService::getTld($idnDomain)); - } catch (Exception $e) { + } catch (Exception) { throw new Exception("Unable to determine which RDAP server to contact"); } @@ -61,7 +60,7 @@ class RDAPService $res = $this->client->request( 'GET', $rdapServer . 'domain/' . $idnDomain )->toArray(); - } catch (Throwable $e) { + } catch (Throwable) { throw new Exception("Unable to contact RDAP server"); } @@ -71,7 +70,7 @@ class RDAPService $domain ->setLdhName($res['ldhName']) ->setHandle($res['handle']) - ->setStatus(array_map(fn($str): DomainStatus => DomainStatus::from($str), $res['status'])); + ->setStatus($res['status']); foreach ($res['events'] as $rdapEvent) { @@ -79,7 +78,7 @@ class RDAPService if ($eventAction === EventAction::LastUpdateOfRDAPDatabase) continue; $event = $this->domainEventRepository->findOneBy([ - "action" => EventAction::from($rdapEvent["eventAction"]), + "action" => $eventAction, "date" => new DateTimeImmutable($rdapEvent["eventDate"]), "domain" => $domain ]); @@ -146,7 +145,7 @@ class RDAPService $nameserver->addNameserverEntity($nameserverEntity ->setNameserver($nameserver) ->setEntity($entity) - ->setStatus(array_map(fn($str): DomainStatus => DomainStatus::from($str), $rdapNameserver['status'])) + ->setStatus($rdapNameserver['status']) ->setRoles(array_map(fn($str): DomainRole => DomainRole::from($str), $rdapEntity['roles']))); } @@ -174,6 +173,9 @@ class RDAPService throw new Exception("This TLD ($tld) is not supported"); } + /** + * @throws Exception + */ private static function getTld($domain): string { $lastDotPosition = strrpos($domain, '.');