src/Entity/ExposedSubDomain.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ExposedSubDomainRepository;
  4. use App\Traits\DateTimeTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\Common\Collections\ReadableCollection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Overblog\GraphQLBundle\Annotation\Field;
  10. use App\Attribute\Searchable;
  11. use DateTimeImmutable;
  12. #[ORM\Entity(repositoryClassExposedSubDomainRepository::class)]
  13. #[ORM\HasLifecycleCallbacks]
  14. class ExposedSubDomain extends BasicEntity
  15. {
  16.     use DateTimeTrait;
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column(type'integer')]
  20.     #[Field(name"id"type"int")]
  21.     private $id;
  22.     #[ORM\Column(type'string'length255)]
  23.     #[Field(name"sub_domain"type"string")]
  24.     #[Searchable(name'sub_domain')]
  25.     private $subDomain;
  26.     #[ORM\ManyToOne(targetEntityDomain::class, inversedBy'exposedSubDomains')]
  27.     #[ORM\JoinColumn(nullablefalse)]
  28.     #[Field(name"domain")]
  29.     private $domain;
  30.     #[ORM\Column(type'boolean')]
  31.     #[Field(name"is_normal"type"boolean")]
  32.     private $isNormal;
  33.     #[ORM\ManyToOne(inversedBy'exposedSubDomains'targetEntityExposedIp::class, cascade: ['persist''remove'])]
  34.     #[Field(name"exposed_ip"nullabletrue)]
  35.     private $exposedIp;
  36.     #[ORM\Column(type"boolean"options: ['default' => true])]
  37.     #[Field(name"is_active"type"boolean")]
  38.     private $isActive;
  39.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  40.     #[Field(name"last_seen"type"string")]
  41.     private $lastSeen;
  42.     #[ORM\ManyToOne(targetEntityStatus::class, inversedBy'exposedSubDomains')]
  43.     #[ORM\JoinColumn(nullabletrueoptions: ['default' => 1])]
  44.     #[Field(name"status")]
  45.     private $status;
  46.     #[ORM\Column(options: ['default' => false])]
  47.     #[Field(name"is_deleted"type"boolean")]
  48.     private ?bool $isDeleted null;
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getSubDomain(): ?string
  54.     {
  55.         return $this->subDomain;
  56.     }
  57.     public function setSubDomain(string $subDomain): self
  58.     {
  59.         $this->subDomain $subDomain;
  60.         return $this;
  61.     }
  62.     public function getDomain(): ?Domain
  63.     {
  64.         return $this->domain;
  65.     }
  66.     public function setDomain(?Domain $domain): self
  67.     {
  68.         $this->domain $domain;
  69.         return $this;
  70.     }
  71.     public function getIsNormal(): ?bool
  72.     {
  73.         return $this->isNormal;
  74.     }
  75.     public function setIsNormal(bool $isNormal): self
  76.     {
  77.         $this->isNormal $isNormal;
  78.         return $this;
  79.     }
  80.     public function getIsActive(): ?bool
  81.     {
  82.         return $this->isActive;
  83.     }
  84.     public function setIsActive(?bool $isActive): self
  85.     {
  86.         $this->isActive $isActive;
  87.         return $this;
  88.     }
  89.     public function getLastSeen(): ?DateTimeImmutable
  90.     {
  91.         return $this->lastSeen;
  92.     }
  93.     public function setLastSeen(?DateTimeImmutable $lastSeen): self
  94.     {
  95.         $this->lastSeen $lastSeen;
  96.         return $this;
  97.     }
  98.     public function getStatus(): ?Status
  99.     {
  100.         return $this->status;
  101.     }
  102.     public function setStatus(?Status $status): self
  103.     {
  104.         $this->status $status;
  105.         return $this;
  106.     }
  107.     public function getExposedIp(): ?ExposedIp
  108.     {
  109.         return $this->exposedIp;
  110.     }
  111.     public function setExposedIp(?ExposedIp $exposedIp): self
  112.     {
  113.         $this->exposedIp $exposedIp;
  114.         return $this;
  115.     }
  116.     public function getVulnerabilities(): ReadableCollection
  117.     {
  118.         $sub $this->subDomain.".".substr($this->getDomain()->getUrl(), 1);
  119.         return $this->getDomain()->getVulnerabilities()
  120.             ->filter(function(Vulnerability $v) use ($sub){
  121.                return str_contains(
  122.                    $v->getMetadata(),
  123.                    $sub
  124.                );
  125.             });
  126.     }
  127.     public function getIsDeleted(): ?bool
  128.     {
  129.         return $this->isDeleted;
  130.     }
  131.     public function setIsDeleted(?bool $isDeleted): self
  132.     {
  133.         $this->isDeleted $isDeleted;
  134.         return $this;
  135.     }
  136. }