mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
fix: avoid save info that concerns IANA reserved IDs
This commit is contained in:
@@ -79,6 +79,12 @@ readonly class RDAPService
|
|||||||
public const ENTITY_HANDLE_BLACKLIST = [
|
public const ENTITY_HANDLE_BLACKLIST = [
|
||||||
'REDACTED_FOR_PRIVACY',
|
'REDACTED_FOR_PRIVACY',
|
||||||
'ANO00-FRNIC',
|
'ANO00-FRNIC',
|
||||||
|
'not applicable',
|
||||||
|
];
|
||||||
|
|
||||||
|
/* @see https://www.iana.org/assignments/registrar-ids/registrar-ids.xhtml */
|
||||||
|
public const ENTITY_IANA_RESERVED_IDS = [
|
||||||
|
1, 3, 8, 119, 365, 376, 9994, 9995, 9996, 9997, 9998, 9999, 10009, 4000001, 8888888,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(private HttpClientInterface $client,
|
public function __construct(private HttpClientInterface $client,
|
||||||
@@ -338,10 +344,6 @@ readonly class RDAPService
|
|||||||
|
|
||||||
if (array_key_exists('entities', $rdapData) && is_array($rdapData['entities'])) {
|
if (array_key_exists('entities', $rdapData) && is_array($rdapData['entities'])) {
|
||||||
foreach ($rdapData['entities'] as $rdapEntity) {
|
foreach ($rdapData['entities'] as $rdapEntity) {
|
||||||
if (array_key_exists('handle', $rdapEntity) && in_array($rdapEntity['handle'], self::ENTITY_HANDLE_BLACKLIST)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$roles = $this->extractEntityRoles($rdapData['entities'], $rdapEntity);
|
$roles = $this->extractEntityRoles($rdapData['entities'], $rdapEntity);
|
||||||
$entity = $this->registerEntity($rdapEntity, $roles, $domain->getLdhName());
|
$entity = $this->registerEntity($rdapEntity, $roles, $domain->getLdhName());
|
||||||
|
|
||||||
@@ -468,7 +470,22 @@ readonly class RDAPService
|
|||||||
*/
|
*/
|
||||||
private function registerEntity(array $rdapEntity, array $roles, string $domain): Entity
|
private function registerEntity(array $rdapEntity, array $roles, string $domain): Entity
|
||||||
{
|
{
|
||||||
if (!array_key_exists('handle', $rdapEntity) || '' === $rdapEntity['handle']) {
|
/*
|
||||||
|
* If the RDAP server transmits the entity's IANA number, it is used as a priority to identify the entity
|
||||||
|
*/
|
||||||
|
if (array_key_exists('publicIds', $rdapEntity)) {
|
||||||
|
foreach ($rdapEntity['publicIds'] as $publicId) {
|
||||||
|
if ('IANA Registrar ID' === $publicId['type'] && array_key_exists('identifier', $publicId)) {
|
||||||
|
$rdapEntity['handle'] = $publicId['identifier'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there is no number to identify the entity, one is generated from the domain name and the roles associated with this entity
|
||||||
|
*/
|
||||||
|
if (!array_key_exists('handle', $rdapEntity) || '' === $rdapEntity['handle'] || in_array($rdapEntity['handle'], self::ENTITY_HANDLE_BLACKLIST)) {
|
||||||
$rdapEntity['handle'] = 'DW-FAKEHANDLE-'.$domain.'-'.join(',', $roles);
|
$rdapEntity['handle'] = 'DW-FAKEHANDLE-'.$domain.'-'.join(',', $roles);
|
||||||
|
|
||||||
$this->logger->warning('The entity {handle} has no handle key.', [
|
$this->logger->warning('The entity {handle} has no handle key.', [
|
||||||
@@ -490,7 +507,7 @@ readonly class RDAPService
|
|||||||
|
|
||||||
$entity->setHandle($rdapEntity['handle']);
|
$entity->setHandle($rdapEntity['handle']);
|
||||||
|
|
||||||
if (array_key_exists('vcardArray', $rdapEntity)) {
|
if (array_key_exists('vcardArray', $rdapEntity) && !in_array($rdapEntity['handle'], self::ENTITY_IANA_RESERVED_IDS)) {
|
||||||
if (empty($entity->getJCard())) {
|
if (empty($entity->getJCard())) {
|
||||||
$entity->setJCard($rdapEntity['vcardArray']);
|
$entity->setJCard($rdapEntity['vcardArray']);
|
||||||
} else {
|
} else {
|
||||||
@@ -505,7 +522,7 @@ readonly class RDAPService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!array_key_exists('events', $rdapEntity)) {
|
if (!array_key_exists('events', $rdapEntity) || in_array($rdapEntity['handle'], self::ENTITY_IANA_RESERVED_IDS)) {
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user