@@ -128,12 +128,16 @@ def test_edit_finding(self):
128
128
self .assertTrue (self .is_text_present_on_page (text = "REF-4" ))
129
129
self .assertTrue (self .is_text_present_on_page (text = "Additional Vulnerability Ids" ))
130
130
131
- def _edit_finding_cvssv3_and_assert (
131
+ def _edit_finding_cvss_and_assert (
132
132
self ,
133
- cvssv3_value ,
134
- cvssv3_score ,
135
- expected_cvssv3_value ,
136
- expected_cvssv3_score ,
133
+ cvssv3_value = None ,
134
+ cvssv3_score = None ,
135
+ cvssv4_value = None ,
136
+ cvssv4_score = None ,
137
+ expected_cvssv3_value = None ,
138
+ expected_cvssv3_score = None ,
139
+ expected_cvssv4_value = None ,
140
+ expected_cvssv4_score = None ,
137
141
expect_success = True , # noqa: FBT002
138
142
success_message = "Finding saved successfully" ,
139
143
error_message = None ,
@@ -147,12 +151,21 @@ def _edit_finding_cvssv3_and_assert(
147
151
driver .find_element (By .ID , "dropdownMenu1" ).click ()
148
152
# Click on `Edit Finding`
149
153
driver .find_element (By .LINK_TEXT , "Edit Finding" ).click ()
150
- # Set cvssv3 value and score
151
154
driver .find_element (By .ID , "id_cvssv3" ).clear ()
152
- driver .find_element (By .ID , "id_cvssv3" ).send_keys (cvssv3_value )
155
+ driver .find_element (By .ID , "id_cvssv3_score" ).clear ()
156
+ driver .find_element (By .ID , "id_cvssv4" ).clear ()
157
+ driver .find_element (By .ID , "id_cvssv4_score" ).clear ()
158
+ if cvssv3_value :
159
+ # Set cvssv3 value and score
160
+ driver .find_element (By .ID , "id_cvssv3" ).send_keys (cvssv3_value )
153
161
if cvssv3_score :
154
- driver .find_element (By .ID , "id_cvssv3_score" ).clear ()
155
162
driver .find_element (By .ID , "id_cvssv3_score" ).send_keys (str (cvssv3_score ))
163
+ if cvssv4_value :
164
+ # Set cvssv3 value and score
165
+ driver .find_element (By .ID , "id_cvssv4" ).send_keys (cvssv4_value )
166
+ if cvssv4_score :
167
+ driver .find_element (By .ID , "id_cvssv4_score" ).send_keys (str (cvssv4_score ))
168
+
156
169
# Submit the form
157
170
driver .find_element (By .XPATH , "//input[@name='_Finished']" ).click ()
158
171
@@ -161,18 +174,21 @@ def _edit_finding_cvssv3_and_assert(
161
174
# Go into edit mode again to check stored values
162
175
driver .find_element (By .ID , "dropdownMenu1" ).click ()
163
176
driver .find_element (By .LINK_TEXT , "Edit Finding" ).click ()
164
- self .assertEqual (expected_cvssv3_value , driver .find_element (By .ID , "id_cvssv3" ).get_attribute ("value" ))
165
- self .assertEqual (str (expected_cvssv3_score ), driver .find_element (By .ID , "id_cvssv3_score" ).get_attribute ("value" ))
166
177
else :
167
178
self .assertTrue (self .is_error_message_present (text = error_message ))
179
+
180
+ if expected_cvssv3_value :
168
181
self .assertEqual (expected_cvssv3_value , driver .find_element (By .ID , "id_cvssv3" ).get_attribute ("value" ))
182
+ if expected_cvssv3_score :
169
183
self .assertEqual (str (expected_cvssv3_score ), driver .find_element (By .ID , "id_cvssv3_score" ).get_attribute ("value" ))
184
+ if expected_cvssv4_value :
185
+ self .assertEqual (expected_cvssv4_value , driver .find_element (By .ID , "id_cvssv4" ).get_attribute ("value" ))
186
+ if expected_cvssv4_score :
187
+ self .assertEqual (str (expected_cvssv4_score ), driver .find_element (By .ID , "id_cvssv4_score" ).get_attribute ("value" ))
170
188
171
- # See https://github.com/DefectDojo/django-DefectDojo/issues/8264
172
- # Capturing current behavior which might not be the desired one yet
173
189
@on_exception_html_source_logger
174
190
def test_edit_finding_cvssv3_valid_vector (self ):
175
- self ._edit_finding_cvssv3_and_assert (
191
+ self ._edit_finding_cvss_and_assert (
176
192
cvssv3_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
177
193
cvssv3_score = "1" ,
178
194
expected_cvssv3_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
@@ -182,7 +198,7 @@ def test_edit_finding_cvssv3_valid_vector(self):
182
198
183
199
@on_exception_html_source_logger
184
200
def test_edit_finding_cvssv3_valid_vector_no_score (self ):
185
- self ._edit_finding_cvssv3_and_assert (
201
+ self ._edit_finding_cvss_and_assert (
186
202
cvssv3_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
187
203
cvssv3_score = None ,
188
204
expected_cvssv3_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
@@ -192,7 +208,7 @@ def test_edit_finding_cvssv3_valid_vector_no_score(self):
192
208
193
209
@on_exception_html_source_logger
194
210
def test_edit_finding_cvssv3_valid_vector_no_prefix (self ):
195
- self ._edit_finding_cvssv3_and_assert (
211
+ self ._edit_finding_cvss_and_assert (
196
212
cvssv3_value = "AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
197
213
cvssv3_score = "2" ,
198
214
expected_cvssv3_value = "AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
@@ -203,7 +219,7 @@ def test_edit_finding_cvssv3_valid_vector_no_prefix(self):
203
219
204
220
@on_exception_html_source_logger
205
221
def test_edit_finding_cvssv3_valid_vector_with_trailing_slash (self ):
206
- self ._edit_finding_cvssv3_and_assert (
222
+ self ._edit_finding_cvss_and_assert (
207
223
cvssv3_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H/" ,
208
224
cvssv3_score = "3" ,
209
225
expected_cvssv3_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H/" ,
@@ -214,7 +230,7 @@ def test_edit_finding_cvssv3_valid_vector_with_trailing_slash(self):
214
230
215
231
@on_exception_html_source_logger
216
232
def test_edit_finding_cvssv3_with_v2_vector_invalid_due_to_prefix (self ):
217
- self ._edit_finding_cvssv3_and_assert (
233
+ self ._edit_finding_cvss_and_assert (
218
234
cvssv3_value = "CVSS:2.0/AV:N/AC:L/Au:N/C:P/I:P/A:P" ,
219
235
cvssv3_score = "4" ,
220
236
expected_cvssv3_value = "CVSS:2.0/AV:N/AC:L/Au:N/C:P/I:P/A:P" ,
@@ -225,7 +241,7 @@ def test_edit_finding_cvssv3_with_v2_vector_invalid_due_to_prefix(self):
225
241
226
242
@on_exception_html_source_logger
227
243
def test_edit_finding_cvssv3_with_v2_vector (self ):
228
- self ._edit_finding_cvssv3_and_assert (
244
+ self ._edit_finding_cvss_and_assert (
229
245
cvssv3_value = "AV:N/AC:L/Au:N/C:P/I:P/A:P" ,
230
246
cvssv3_score = "4" ,
231
247
expected_cvssv3_value = "AV:N/AC:L/Au:N/C:P/I:P/A:P" ,
@@ -236,24 +252,111 @@ def test_edit_finding_cvssv3_with_v2_vector(self):
236
252
237
253
@on_exception_html_source_logger
238
254
def test_edit_finding_cvssv3_with_v4_vector (self ):
239
- self ._edit_finding_cvssv3_and_assert (
240
- cvssv3_value = "CVSS:4.0/AV:N /AC:L/AT:N /PR:L/UI:N/S:U/C :H/I :H/A:H " ,
255
+ self ._edit_finding_cvss_and_assert (
256
+ cvssv3_value = "CVSS:4.0/AV:L /AC:L/AT:P /PR:L/UI:N/VC:H/VI :H/VA :H/SC:N/SI:N/SA:N " ,
241
257
cvssv3_score = "5" ,
242
- expected_cvssv3_value = "CVSS:4.0/AV:N /AC:L/AT:N /PR:L/UI:N/S:U/C :H/I :H/A:H " ,
258
+ expected_cvssv3_value = "CVSS:4.0/AV:L /AC:L/AT:P /PR:L/UI:N/VC:H/VI :H/VA :H/SC:N/SI:N/SA:N " ,
243
259
expected_cvssv3_score = "5" ,
244
260
expect_success = False ,
245
- error_message = "No valid CVSS vectors found by cvss.parse_cvss_from_text()" ,
261
+ error_message = "No valid CVSS3 vectors found by cvss.parse_cvss_from_text()" ,
246
262
)
247
263
248
264
@on_exception_html_source_logger
249
265
def test_edit_finding_cvssv3_with_rubbish (self ):
250
- self ._edit_finding_cvssv3_and_assert (
266
+ self ._edit_finding_cvss_and_assert (
251
267
cvssv3_value = "happy little vector" ,
252
268
cvssv3_score = "5" ,
253
269
expected_cvssv3_value = "happy little vector" ,
254
270
expected_cvssv3_score = "5" ,
255
271
expect_success = False ,
256
- error_message = "No valid CVSS vectors found by cvss.parse_cvss_from_text()" ,
272
+ error_message = "No valid CVSS3 vectors found by cvss.parse_cvss_from_text()" ,
273
+ )
274
+
275
+ """"CVSS4 Test"""
276
+ @on_exception_html_source_logger
277
+ def test_edit_finding_cvssv4_valid_vector (self ):
278
+ self ._edit_finding_cvss_and_assert (
279
+ cvssv4_value = "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N" ,
280
+ cvssv4_score = "1" ,
281
+ expected_cvssv4_value = "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N" ,
282
+ expected_cvssv4_score = "1.0" ,
283
+ expect_success = True ,
284
+ )
285
+
286
+ @on_exception_html_source_logger
287
+ def test_edit_finding_cvssv4_valid_vector_no_score (self ):
288
+ self ._edit_finding_cvss_and_assert (
289
+ cvssv4_value = "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N" ,
290
+ cvssv4_score = None ,
291
+ expected_cvssv4_value = "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N" ,
292
+ expected_cvssv4_score = "7.3" ,
293
+ expect_success = True ,
294
+ )
295
+
296
+ @on_exception_html_source_logger
297
+ def test_edit_finding_cvssv4_valid_vector_no_prefix (self ):
298
+ self ._edit_finding_cvss_and_assert (
299
+ cvssv4_value = "AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N" ,
300
+ cvssv4_score = "2" ,
301
+ expected_cvssv4_value = "AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N" ,
302
+ expected_cvssv4_score = "2" ,
303
+ expect_success = False ,
304
+ error_message = "No valid CVSS4 vectors found by cvss.parse_cvss_from_text()" ,
305
+ )
306
+
307
+ @on_exception_html_source_logger
308
+ def test_edit_finding_cvssv4_valid_vector_with_trailing_slash (self ):
309
+ self ._edit_finding_cvss_and_assert (
310
+ cvssv4_value = "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/" ,
311
+ cvssv4_score = "3" ,
312
+ expected_cvssv4_value = "CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/" ,
313
+ expected_cvssv4_score = "3" ,
314
+ expect_success = False ,
315
+ error_message = "No valid CVSS4 vectors found by cvss.parse_cvss_from_text()" ,
316
+ )
317
+
318
+ @on_exception_html_source_logger
319
+ def test_edit_finding_cvssv4_with_v2_vector_invalid_due_to_prefix (self ):
320
+ self ._edit_finding_cvss_and_assert (
321
+ cvssv4_value = "CVSS:2.0/AV:N/AC:L/Au:N/C:P/I:P/A:P" ,
322
+ cvssv4_score = "4" ,
323
+ expected_cvssv4_value = "CVSS:2.0/AV:N/AC:L/Au:N/C:P/I:P/A:P" ,
324
+ expected_cvssv4_score = "4" ,
325
+ expect_success = False ,
326
+ error_message = "No valid CVSS4 vectors found by cvss.parse_cvss_from_text()" ,
327
+ )
328
+
329
+ @on_exception_html_source_logger
330
+ def test_edit_finding_cvssv4_with_v2_vector (self ):
331
+ self ._edit_finding_cvss_and_assert (
332
+ cvssv4_value = "AV:N/AC:L/Au:N/C:P/I:P/A:P" ,
333
+ cvssv4_score = "4" ,
334
+ expected_cvssv4_value = "AV:N/AC:L/Au:N/C:P/I:P/A:P" ,
335
+ expected_cvssv4_score = "4" ,
336
+ expect_success = False ,
337
+ error_message = "Unsupported CVSS(2) version detected." ,
338
+ )
339
+
340
+ @on_exception_html_source_logger
341
+ def test_edit_finding_cvssv4_with_v3_vector (self ):
342
+ self ._edit_finding_cvss_and_assert (
343
+ cvssv4_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
344
+ cvssv4_score = "5" ,
345
+ expected_cvssv4_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
346
+ expected_cvssv4_score = "5" ,
347
+ expect_success = False ,
348
+ error_message = "CVSS(3) vector vannot be stored in the cvss3 field. Use the cvss3 fields." ,
349
+ )
350
+
351
+ @on_exception_html_source_logger
352
+ def test_edit_finding_cvssv4_with_rubbish (self ):
353
+ self ._edit_finding_cvss_and_assert (
354
+ cvssv4_value = "happy little vector" ,
355
+ cvssv4_score = "5" ,
356
+ expected_cvssv4_value = "happy little vector" ,
357
+ expected_cvssv4_score = "5" ,
358
+ expect_success = False ,
359
+ error_message = "No valid CVSS4 vectors found by cvss.parse_cvss_from_text()" ,
257
360
)
258
361
259
362
def test_add_image (self ):
@@ -688,12 +791,21 @@ def add_finding_tests_to_suite(suite, *, jira=False, github=False, block_executi
688
791
suite .addTest (FindingTest ("test_list_components" ))
689
792
suite .addTest (FindingTest ("test_edit_finding" ))
690
793
suite .addTest (FindingTest ("test_edit_finding_cvssv3_valid_vector" ))
794
+ suite .addTest (FindingTest ("test_edit_finding_cvssv3_valid_vector_no_score" ))
691
795
suite .addTest (FindingTest ("test_edit_finding_cvssv3_valid_vector_no_prefix" ))
692
796
suite .addTest (FindingTest ("test_edit_finding_cvssv3_valid_vector_with_trailing_slash" ))
693
- suite .addTest (FindingTest ("test_edit_finding_cvssv3_with_v2_vector" ))
694
797
suite .addTest (FindingTest ("test_edit_finding_cvssv3_with_v2_vector_invalid_due_to_prefix" ))
798
+ suite .addTest (FindingTest ("test_edit_finding_cvssv3_with_v2_vector" ))
695
799
suite .addTest (FindingTest ("test_edit_finding_cvssv3_with_v4_vector" ))
696
800
suite .addTest (FindingTest ("test_edit_finding_cvssv3_with_rubbish" ))
801
+ suite .addTest (FindingTest ("test_edit_finding_cvssv4_valid_vector" ))
802
+ suite .addTest (FindingTest ("test_edit_finding_cvssv4_valid_vector_no_score" ))
803
+ suite .addTest (FindingTest ("test_edit_finding_cvssv4_valid_vector_no_prefix" ))
804
+ suite .addTest (FindingTest ("test_edit_finding_cvssv4_valid_vector_with_trailing_slash" ))
805
+ suite .addTest (FindingTest ("test_edit_finding_cvssv4_with_v2_vector_invalid_due_to_prefix" ))
806
+ suite .addTest (FindingTest ("test_edit_finding_cvssv4_with_v2_vector" ))
807
+ suite .addTest (FindingTest ("test_edit_finding_cvssv4_with_v3_vector" ))
808
+ suite .addTest (FindingTest ("test_edit_finding_cvssv4_with_rubbish" ))
697
809
suite .addTest (FindingTest ("test_add_note_to_finding" ))
698
810
suite .addTest (FindingTest ("test_add_image" ))
699
811
suite .addTest (FindingTest ("test_delete_image" ))
0 commit comments