mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: do not register anonymous entities
This commit is contained in:
@@ -2,11 +2,8 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Metadata\ApiFilter;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use App\Repository\EntityRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -15,13 +12,14 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
|
||||
#[ORM\Entity(repositoryClass: EntityRepository::class)]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['jCard' => 'partial'])]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
/*
|
||||
new GetCollection(
|
||||
uriTemplate: '/entities',
|
||||
normalizationContext: ['groups' => ['entity:list', 'event:list']]
|
||||
),
|
||||
*/
|
||||
new Get(
|
||||
uriTemplate: '/entities/{handle}',
|
||||
normalizationContext: [
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use App\Repository\NameserverRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -15,6 +14,7 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
#[ORM\Entity(repositoryClass: NameserverRepository::class)]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
/*
|
||||
new GetCollection(
|
||||
uriTemplate: '/nameservers',
|
||||
normalizationContext: [
|
||||
@@ -23,6 +23,7 @@ use Symfony\Component\Serializer\Attribute\SerializedName;
|
||||
],
|
||||
]
|
||||
),
|
||||
*/
|
||||
new Get(
|
||||
uriTemplate: '/nameservers/{ldhName}',
|
||||
normalizationContext: [
|
||||
|
||||
@@ -76,6 +76,11 @@ readonly class RDAPService
|
||||
'xn--hlcj6aya9esc7a',
|
||||
];
|
||||
|
||||
public const ENTITY_HANDLE_BLACKLIST = [
|
||||
'REDACTED_FOR_PRIVACY',
|
||||
'ANO00-FRNIC',
|
||||
];
|
||||
|
||||
public function __construct(private HttpClientInterface $client,
|
||||
private EntityRepository $entityRepository,
|
||||
private DomainRepository $domainRepository,
|
||||
@@ -333,6 +338,10 @@ readonly class RDAPService
|
||||
|
||||
if (array_key_exists('entities', $rdapData) && is_array($rdapData['entities'])) {
|
||||
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);
|
||||
$entity = $this->registerEntity($rdapEntity, $roles, $domain->getLdhName());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user