fix: remove DomainStatus enum

This commit is contained in:
Maël Gangloff 2024-07-14 21:15:13 +02:00
parent d202aa8964
commit 8a8059a366
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
6 changed files with 257 additions and 76 deletions

View File

@ -11,9 +11,10 @@
"doctrine/doctrine-bundle": "^2.12", "doctrine/doctrine-bundle": "^2.12",
"doctrine/doctrine-migrations-bundle": "^3.3", "doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.2", "doctrine/orm": "^3.2",
"eluceo/ical": "^2.13", "eluceo/ical": "^2.14",
"phpdocumentor/reflection-docblock": "^5.4", "phpdocumentor/reflection-docblock": "^5.4",
"phpstan/phpdoc-parser": "^1.29", "phpstan/phpdoc-parser": "^1.29",
"protonlabs/vobject": "^4.31",
"psr/http-client": "^1.0", "psr/http-client": "^1.0",
"symfony/asset": "7.1.*", "symfony/asset": "7.1.*",
"symfony/asset-mapper": "7.1.*", "symfony/asset-mapper": "7.1.*",

235
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "5f504b40613dac0da1ea6c1dc972bbe8", "content-hash": "139867d77c0de3a6d8dfd5df9210b52b",
"packages": [ "packages": [
{ {
"name": "composer/semver", "name": "composer/semver",
@ -1763,6 +1763,110 @@
}, },
"time": "2024-05-31T08:52:43+00:00" "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", "name": "psr/cache",
"version": "3.0.0", "version": "3.0.0",
@ -2174,6 +2278,135 @@
}, },
"time": "2021-07-14T16:46:02+00:00" "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", "name": "symfony/asset",
"version": "v7.1.1", "version": "v7.1.1",

View File

@ -1,47 +0,0 @@
<?php
namespace App\Config;
/**
* @see https://www.iana.org/assignments/rdap-json-values/rdap-json-values.xhtml
*/
enum DomainStatus: string
{
case Validated = 'validated';
case RenewProhibited = 'renew prohibited';
case UpdateProhibited = 'update prohibited';
case TransferProhibited = 'transfer prohibited';
case DeleteProhibited = 'delete prohibited';
case Proxy = 'proxy';
case Private = 'private';
case Removed = 'removed';
case Obscured = 'obscured';
case Associated = 'associated';
case Active = 'active';
case Inactive = 'inactive';
case Locked = 'locked';
case PendingCreate = 'pending create';
case PendingRenew = 'pending renew';
case PendingTransfer = 'pending transfer';
case PendingUpdate = 'pending update';
case PendingDelete = 'pending delete';
case AddPeriod = 'add period';
case AutoRenewPeriod = 'auto renew period';
case ClientDeleteProhibited = 'client delete prohibited';
case ClientHold = 'client hold';
case ClientRenewProhibited = 'client renew prohibited';
case ClientTransferProhibited = 'client transfer prohibited';
case ClientUpdateProhibited = 'client update prohibited';
case PendingRestore = 'pending restore';
case RedemptionPeriod = 'redemption period';
case RenewPeriod = 'renew period';
case ServerDeleteProhibited = 'server delete prohibited';
case ServerRenewProhibited = 'server renew prohibited';
case ServerTransferProhibited = 'server transfer prohibited';
case ServerUpdateProhibited = 'server update prohibited';
case ServerRecoverProhibited = 'server recover prohibited';
case ServerHold = 'server hold';
case TransferPeriod = 'transfer period';
case Administrative = 'administrative';
case Reserved = 'reserved';
}

View File

@ -2,7 +2,6 @@
namespace App\Entity; namespace App\Entity;
use App\Config\DomainStatus;
use App\Repository\DomainRepository; use App\Repository\DomainRepository;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@ -31,7 +30,7 @@ class Domain
#[ORM\OneToMany(targetEntity: DomainEntity::class, mappedBy: 'domain', cascade: ['persist'], orphanRemoval: true)] #[ORM\OneToMany(targetEntity: DomainEntity::class, mappedBy: 'domain', cascade: ['persist'], orphanRemoval: true)]
private Collection $domainEntities; private Collection $domainEntities;
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)] #[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $status = []; private array $status = [];
/** /**
@ -142,9 +141,6 @@ class Domain
return $this; return $this;
} }
/**
* @return DomainStatus[]
*/
public function getStatus(): array public function getStatus(): array
{ {
return $this->status; return $this->status;

View File

@ -3,7 +3,6 @@
namespace App\Entity; namespace App\Entity;
use App\Config\DomainRole; use App\Config\DomainRole;
use App\Config\DomainStatus;
use App\Repository\NameserverEntityRepository; use App\Repository\NameserverEntityRepository;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -25,7 +24,7 @@ class NameserverEntity
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainRole::class)] #[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainRole::class)]
private array $roles = []; private array $roles = [];
#[ORM\Column(type: Types::SIMPLE_ARRAY, enumType: DomainStatus::class)] #[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $status = []; private array $status = [];
public function getNameserver(): ?Nameserver public function getNameserver(): ?Nameserver
@ -67,9 +66,6 @@ class NameserverEntity
return $this; return $this;
} }
/**
* @return DomainStatus[]
*/
public function getStatus(): array public function getStatus(): array
{ {
return $this->status; return $this->status;

View File

@ -4,7 +4,6 @@
namespace App\Service; namespace App\Service;
use App\Config\DomainRole; use App\Config\DomainRole;
use App\Config\DomainStatus;
use App\Config\EventAction; use App\Config\EventAction;
use App\Entity\Domain; use App\Entity\Domain;
use App\Entity\DomainEntity; use App\Entity\DomainEntity;
@ -27,19 +26,19 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\HttpClientInterface;
use Throwable; use Throwable;
class RDAPService readonly class RDAPService
{ {
public function __construct(private readonly HttpClientInterface $client, public function __construct(private HttpClientInterface $client,
private readonly EntityRepository $entityRepository, private EntityRepository $entityRepository,
private readonly DomainRepository $domainRepository, private DomainRepository $domainRepository,
private readonly DomainEventRepository $domainEventRepository, private DomainEventRepository $domainEventRepository,
private readonly NameserverRepository $nameserverRepository, private NameserverRepository $nameserverRepository,
private readonly NameserverEntityRepository $nameserverEntityRepository, private NameserverEntityRepository $nameserverEntityRepository,
private readonly EntityEventRepository $entityEventRepository, private EntityEventRepository $entityEventRepository,
private readonly DomainEntityRepository $domainEntityRepository, private DomainEntityRepository $domainEntityRepository,
private readonly EntityManagerInterface $em, private EntityManagerInterface $em,
private readonly ParameterBagInterface $params private ParameterBagInterface $params
) )
{ {
@ -53,7 +52,7 @@ class RDAPService
$idnDomain = idn_to_ascii($fqdn); $idnDomain = idn_to_ascii($fqdn);
try { try {
$rdapServer = $this->getRDAPServer(RDAPService::getTld($idnDomain)); $rdapServer = $this->getRDAPServer(RDAPService::getTld($idnDomain));
} catch (Exception $e) { } catch (Exception) {
throw new Exception("Unable to determine which RDAP server to contact"); throw new Exception("Unable to determine which RDAP server to contact");
} }
@ -61,7 +60,7 @@ class RDAPService
$res = $this->client->request( $res = $this->client->request(
'GET', $rdapServer . 'domain/' . $idnDomain 'GET', $rdapServer . 'domain/' . $idnDomain
)->toArray(); )->toArray();
} catch (Throwable $e) { } catch (Throwable) {
throw new Exception("Unable to contact RDAP server"); throw new Exception("Unable to contact RDAP server");
} }
@ -71,7 +70,7 @@ class RDAPService
$domain $domain
->setLdhName($res['ldhName']) ->setLdhName($res['ldhName'])
->setHandle($res['handle']) ->setHandle($res['handle'])
->setStatus(array_map(fn($str): DomainStatus => DomainStatus::from($str), $res['status'])); ->setStatus($res['status']);
foreach ($res['events'] as $rdapEvent) { foreach ($res['events'] as $rdapEvent) {
@ -79,7 +78,7 @@ class RDAPService
if ($eventAction === EventAction::LastUpdateOfRDAPDatabase) continue; if ($eventAction === EventAction::LastUpdateOfRDAPDatabase) continue;
$event = $this->domainEventRepository->findOneBy([ $event = $this->domainEventRepository->findOneBy([
"action" => EventAction::from($rdapEvent["eventAction"]), "action" => $eventAction,
"date" => new DateTimeImmutable($rdapEvent["eventDate"]), "date" => new DateTimeImmutable($rdapEvent["eventDate"]),
"domain" => $domain "domain" => $domain
]); ]);
@ -146,7 +145,7 @@ class RDAPService
$nameserver->addNameserverEntity($nameserverEntity $nameserver->addNameserverEntity($nameserverEntity
->setNameserver($nameserver) ->setNameserver($nameserver)
->setEntity($entity) ->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']))); ->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"); throw new Exception("This TLD ($tld) is not supported");
} }
/**
* @throws Exception
*/
private static function getTld($domain): string private static function getTld($domain): string
{ {
$lastDotPosition = strrpos($domain, '.'); $lastDotPosition = strrpos($domain, '.');