Skip to content

Commit

Permalink
SecurityAdvisories: changing the remote ID for the same remote adviso…
Browse files Browse the repository at this point in the history
…ry should update the source remote ID (#1449)
  • Loading branch information
glaubinix authored May 17, 2024
1 parent 9ae85d8 commit 61a032c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Entity/SecurityAdvisorySource.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function getSeverity(): ?Severity

public function update(RemoteSecurityAdvisory $advisory): void
{
$this->remoteId = $advisory->id;
$this->severity = $advisory->severity;
}
}
12 changes: 12 additions & 0 deletions tests/SecurityAdvisory/SecurityAdvisoryResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ public function testResolveAddSourceToMatchingAdvisory(): void
$this->assertNotNull($advisory->getSourceRemoteId('other'));
}

public function testResolveRemoteIdChangedSameCve(): void
{
$remoteAdvisory = $this->createRemoteAdvisory('test', cve: 'CVE-2024-9999999999');
$advisory = new SecurityAdvisory($this->createRemoteAdvisory('test', cve: 'CVE-2024-9999999999'), 'test');
[$new, $removed] = $this->resolver->resolve([$advisory], new RemoteSecurityAdvisoryCollection([$remoteAdvisory]), 'test');

$this->assertSame([], $new);
$this->assertSame([], $removed);

$this->assertSame($remoteAdvisory->id, $advisory->getSourceRemoteId('test'));
}

public function testResolveEmpty(): void
{
[$new, $removed] = $this->resolver->resolve([], new RemoteSecurityAdvisoryCollection([]), 'test');
Expand Down

0 comments on commit 61a032c

Please sign in to comment.