@@ -38,16 +38,17 @@ def test_fill_missing_summaries_from_nvd(self):
38
38
alias = Alias .objects .create (alias = "CVE-2024-1234" , vulnerability = vulnerability )
39
39
40
40
# Create an NVD advisory with a summary
41
- Advisory .objects .create (
41
+ adv = Advisory .objects .create (
42
42
summary = "Test vulnerability summary" ,
43
43
created_by = "nvd_importer" ,
44
44
date_collected = datetime .datetime (2024 , 1 , 1 , tzinfo = pytz .UTC ),
45
- aliases = [ "CVE-2024-1234" ] ,
45
+ unique_content_id = "Test" ,
46
46
)
47
+ adv .aliases .add (alias )
47
48
48
49
# Run the pipeline
49
50
pipeline = PopulateVulnerabilitySummariesPipeline ()
50
- pipeline .fill_missing_summaries ()
51
+ pipeline .populate_missing_summaries ()
51
52
52
53
# Check that the vulnerability now has a summary
53
54
vulnerability .refresh_from_db ()
@@ -66,7 +67,7 @@ def test_no_matching_advisory(self):
66
67
67
68
# Run the pipeline
68
69
pipeline = PopulateVulnerabilitySummariesPipeline ()
69
- pipeline .fill_missing_summaries ()
70
+ pipeline .populate_missing_summaries ()
70
71
71
72
# Check that the vulnerability still has no summary
72
73
vulnerability .refresh_from_db ()
@@ -85,7 +86,7 @@ def test_vulnerability_without_alias(self):
85
86
86
87
# Run the pipeline
87
88
pipeline = PopulateVulnerabilitySummariesPipeline ()
88
- pipeline .fill_missing_summaries ()
89
+ pipeline .populate_missing_summaries ()
89
90
90
91
# Check that the vulnerability still has no summary
91
92
vulnerability .refresh_from_db ()
@@ -104,16 +105,18 @@ def test_non_nvd_advisory_ignored(self):
104
105
alias = Alias .objects .create (alias = "CVE-2024-1234" , vulnerability = vulnerability )
105
106
106
107
# Create a non-NVD advisory with a summary
107
- Advisory .objects .create (
108
+ adv = Advisory .objects .create (
108
109
summary = "Test vulnerability summary" ,
109
110
created_by = "other_importer" ,
110
111
date_collected = datetime .datetime (2024 , 1 , 1 , tzinfo = pytz .UTC ),
111
- aliases = [ "CVE-2024-1234" ] ,
112
+ unique_content_id = "Test" ,
112
113
)
113
114
115
+ adv .aliases .add (alias )
116
+
114
117
# Run the pipeline
115
118
pipeline = PopulateVulnerabilitySummariesPipeline ()
116
- pipeline .fill_missing_summaries ()
119
+ pipeline .populate_missing_summaries ()
117
120
118
121
# Check that the vulnerability still has no summary
119
122
vulnerability .refresh_from_db ()
@@ -130,23 +133,27 @@ def test_multiple_matching_advisories(self):
130
133
alias = Alias .objects .create (alias = "CVE-2024-1234" , vulnerability = vulnerability )
131
134
132
135
# Create two NVD advisories with the same alias
133
- Advisory .objects .create (
136
+ adv1 = Advisory .objects .create (
134
137
summary = "First matching advisory" ,
135
138
created_by = "nvd_importer" ,
136
139
date_collected = datetime .datetime (2024 , 1 , 1 , tzinfo = pytz .UTC ),
137
- aliases = [ "CVE-2024-1234" ] ,
140
+ unique_content_id = "Test" ,
138
141
)
139
142
140
- Advisory .objects .create (
143
+ adv1 .aliases .add (alias )
144
+
145
+ adv2 = Advisory .objects .create (
141
146
summary = "Second matching advisory" ,
142
147
created_by = "nvd_importer" ,
143
148
date_collected = datetime .datetime (2024 , 1 , 2 , tzinfo = pytz .UTC ),
144
- aliases = [ "CVE-2024-1234" ] ,
149
+ unique_content_id = "Test-1" ,
145
150
)
146
151
152
+ adv2 .aliases .add (alias )
153
+
147
154
# Run the pipeline
148
155
pipeline = PopulateVulnerabilitySummariesPipeline ()
149
- pipeline .fill_missing_summaries ()
156
+ pipeline .populate_missing_summaries ()
150
157
151
158
# Check that the vulnerability now has the most recent summary
152
159
vulnerability .refresh_from_db ()
0 commit comments