Skip to content

Commit 0956910

Browse files
committed
Use advisory JSONField to compute missing fix and affected
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 3683f2c commit 0956910

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

vulnerabilities/pipelines/compute_advisory_todo.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def steps(cls):
3232
)
3333

3434
def compute_individual_advisory_todo(self):
35-
advisories = Advisory.objects.all().iterator(chunk_size=2000)
35+
advisories = Advisory.objects.all().iterator(chunk_size=5000)
3636
advisories_count = Advisory.objects.all().count()
3737

3838
self.log(
@@ -50,6 +50,7 @@ def compute_individual_advisory_todo(self):
5050
todo_id=advisory_todo_id,
5151
logger=self.log,
5252
)
53+
5354
check_missing_affected_and_fixed_by_packages(
5455
advisory=advisory,
5556
todo_id=advisory_todo_id,
@@ -100,15 +101,15 @@ def check_missing_affected_and_fixed_by_packages(advisory, todo_id, logger=None)
100101
"""
101102
has_affected_package = False
102103
has_fixed_package = False
103-
for affected in advisory.to_advisory_data().affected_packages or []:
104+
for affected in advisory.affected_packages or []:
104105
if not affected:
105106
continue
106107

107108
if has_affected_package and has_fixed_package:
108109
break
109-
if not has_affected_package and affected.affected_version_range:
110+
if not has_affected_package and affected["affected_version_range"]:
110111
has_affected_package = True
111-
if not has_fixed_package and affected.fixed_version:
112+
if not has_fixed_package and affected["fixed_version"]:
112113
has_fixed_package = True
113114

114115
if has_affected_package and has_fixed_package:
@@ -236,12 +237,8 @@ def initialize_sub_matrix(matrix, affected_purl, advisory):
236237
advisory_id = advisory.unique_content_id
237238
if affected_purl not in matrix:
238239
matrix[affected_purl] = {
239-
"affected": {
240-
advisory_id: set(),
241-
},
242-
"fixed": {
243-
advisory_id: set(),
244-
},
240+
"affected": {advisory_id: set()},
241+
"fixed": {advisory_id: set()},
245242
}
246243
else:
247244
if advisory not in matrix[affected_purl]["affected"]:

0 commit comments

Comments
 (0)