Skip to content

Commit c622362

Browse files
committed
Don't "re-attach" CVEs to news articles on every post
If a CVE is already attached to the release article for the current release, avoid re-attaching it to the same one again.
1 parent d6d99f5 commit c622362

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

pgweb/release/migrate.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ def do_migrate():
7676
for cve in release.get('cve', []):
7777
try:
7878
patch = SecurityPatch.objects.get(cve=cve)
79-
patch.newspost = news
80-
patch.public = True
81-
patch.save(update_fields=['newspost', 'public'])
82-
print("Attached news article {} to CVE-{}".format(news.id, cve))
79+
if patch.newspost != news or not patch.public:
80+
patch.newspost = news
81+
patch.public = True
82+
patch.save(update_fields=['newspost', 'public'])
83+
print("Attached news article {} to CVE-{}".format(news.id, cve))
8384
except SecurityPatch.DoesNotExist:
8485
print("Could not find CVE {}, cannot connect to announcement")
8586

0 commit comments

Comments
 (0)