|
@@ -9,9 +9,10 @@ use Packagist\WebBundle\SecurityAdvisory\RemoteSecurityAdvisory;
|
|
|
* @ORM\Entity(repositoryClass="Packagist\WebBundle\Entity\SecurityAdvisoryRepository")
|
|
|
* @ORM\Table(
|
|
|
* name="security_advisory",
|
|
|
- * uniqueConstraints={@ORM\UniqueConstraint(name="source_packagename_idx", columns={"source","packageName"})},
|
|
|
+ * uniqueConstraints={@ORM\UniqueConstraint(name="source_remoteid_idx", columns={"source","remoteId"})},
|
|
|
* indexes={
|
|
|
- * @ORM\Index(name="package_name_idx",columns={"packageName"})
|
|
|
+ * @ORM\Index(name="package_name_idx",columns={"packageName"}),
|
|
|
+ * @ORM\Index(name="updated_at_idx",columns={"updatedAt"})
|
|
|
* }
|
|
|
* )
|
|
|
*/
|
|
@@ -59,6 +60,11 @@ class SecurityAdvisory
|
|
|
*/
|
|
|
private $source;
|
|
|
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="datetime")
|
|
|
+ */
|
|
|
+ private $updatedAt;
|
|
|
+
|
|
|
public function __construct(RemoteSecurityAdvisory $advisory, string $source)
|
|
|
{
|
|
|
$this->source = $source;
|
|
@@ -67,6 +73,17 @@ class SecurityAdvisory
|
|
|
|
|
|
public function updateAdvisory(RemoteSecurityAdvisory $advisory): void
|
|
|
{
|
|
|
+ if (
|
|
|
+ $this->remoteId !== $advisory->getId() ||
|
|
|
+ $this->packageName !== $advisory->getPackageName() ||
|
|
|
+ $this->title !== $advisory->getTitle() ||
|
|
|
+ $this->link !== $advisory->getLink() ||
|
|
|
+ $this->cve !== $advisory->getCve() ||
|
|
|
+ $this->affectedVersions !== $advisory->getAffectedVersions()
|
|
|
+ ) {
|
|
|
+ $this->updatedAt = new \DateTime();
|
|
|
+ }
|
|
|
+
|
|
|
$this->remoteId = $advisory->getId();
|
|
|
$this->packageName = $advisory->getPackageName();
|
|
|
$this->title = $advisory->getTitle();
|
|
@@ -79,4 +96,34 @@ class SecurityAdvisory
|
|
|
{
|
|
|
return $this->remoteId;
|
|
|
}
|
|
|
+
|
|
|
+ public function getPackageName(): string
|
|
|
+ {
|
|
|
+ return $this->packageName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getTitle(): string
|
|
|
+ {
|
|
|
+ return $this->title;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getLink(): ?string
|
|
|
+ {
|
|
|
+ return $this->link;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getCve(): ?string
|
|
|
+ {
|
|
|
+ return $this->cve;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getAffectedVersions(): string
|
|
|
+ {
|
|
|
+ return $this->affectedVersions;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getSource(): string
|
|
|
+ {
|
|
|
+ return $this->source;
|
|
|
+ }
|
|
|
}
|