@@ -115,8 +115,6 @@ def test_edit_finding(self):
115
115
# Change: 'Severity' and 'cvssv3'
116
116
# finding Severity
117
117
Select (driver .find_element (By .ID , "id_severity" )).select_by_visible_text ("Critical" )
118
- # cvssv3
119
- driver .find_element (By .ID , "id_cvssv3" ).send_keys ("CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" )
120
118
# finding Vulnerability Ids
121
119
driver .find_element (By .ID , "id_vulnerability_ids" ).send_keys ("\n REF-3\n REF-4\n " )
122
120
# "Click" the Done button to Edit the finding
@@ -131,6 +129,96 @@ def test_edit_finding(self):
131
129
self .assertTrue (self .is_text_present_on_page (text = "REF-4" ))
132
130
self .assertTrue (self .is_text_present_on_page (text = "Additional Vulnerability Ids" ))
133
131
132
+ def _edit_finding_cvssv3_and_assert (
133
+ self ,
134
+ cvssv3_value ,
135
+ cvssv3_score ,
136
+ expected_cvssv3_value ,
137
+ expected_cvssv3_score ,
138
+ expect_success = True , # noqa: FBT002
139
+ success_message = "Finding saved successfully" ,
140
+ error_message = None ,
141
+ ):
142
+ driver = self .driver
143
+ # Navigate to All Finding page
144
+ self .goto_all_findings_list (driver )
145
+ # Select and click on the particular finding to edit
146
+ driver .find_element (By .LINK_TEXT , "App Vulnerable to XSS" ).click ()
147
+ # Click on the 'dropdownMenu1 button'
148
+ driver .find_element (By .ID , "dropdownMenu1" ).click ()
149
+ # Click on `Edit Finding`
150
+ driver .find_element (By .LINK_TEXT , "Edit Finding" ).click ()
151
+ # Set cvssv3 value and score
152
+ driver .find_element (By .ID , "id_cvssv3" ).clear ()
153
+ driver .find_element (By .ID , "id_cvssv3" ).send_keys (cvssv3_value )
154
+ driver .find_element (By .ID , "id_cvssv3_score" ).clear ()
155
+ driver .find_element (By .ID , "id_cvssv3_score" ).send_keys (str (cvssv3_score ))
156
+ # Submit the form
157
+ driver .find_element (By .XPATH , "//input[@name='_Finished']" ).click ()
158
+
159
+ if expect_success :
160
+ self .assertTrue (self .is_success_message_present (text = success_message ))
161
+ # Go into edit mode again to check stored values
162
+ driver .find_element (By .ID , "dropdownMenu1" ).click ()
163
+ 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
+ else :
167
+ self .assertTrue (self .is_error_message_present (text = error_message ))
168
+
169
+ # See https://github.com/DefectDojo/django-DefectDojo/issues/8264
170
+ # Capturing current behavior which might not be the desired one yet
171
+ @on_exception_html_source_logger
172
+ def test_edit_finding_cvssv3_valid_vector (self ):
173
+ self ._edit_finding_cvssv3_and_assert (
174
+ cvssv3_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
175
+ cvssv3_score = "1" ,
176
+ expected_cvssv3_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
177
+ expected_cvssv3_score = "8.8" ,
178
+ expect_success = True ,
179
+ )
180
+
181
+ @on_exception_html_source_logger
182
+ def test_edit_finding_cvssv3_valid_vector_no_prefix (self ):
183
+ self ._edit_finding_cvssv3_and_assert (
184
+ cvssv3_value = "AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
185
+ cvssv3_score = "2" ,
186
+ expected_cvssv3_value = "AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" ,
187
+ expected_cvssv3_score = "2.0" ,
188
+ expect_success = True ,
189
+ )
190
+
191
+ @on_exception_html_source_logger
192
+ def test_edit_finding_cvssv3_valid_vector_with_trailing_slash (self ):
193
+ self ._edit_finding_cvssv3_and_assert (
194
+ cvssv3_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H/" ,
195
+ cvssv3_score = "3" ,
196
+ expected_cvssv3_value = "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H/" ,
197
+ expected_cvssv3_score = "3.0" ,
198
+ expect_success = True ,
199
+ )
200
+
201
+ @on_exception_html_source_logger
202
+ def test_edit_finding_cvssv3_with_v2_vector (self ):
203
+ self ._edit_finding_cvssv3_and_assert (
204
+ cvssv3_value = "CVSS:2.0/AV:N/AC:L/Au:N/C:P/I:P/A:P" ,
205
+ cvssv3_score = "4" ,
206
+ expected_cvssv3_value = "CVSS:2.0/AV:N/AC:L/Au:N/C:P/I:P/A:P" ,
207
+ expected_cvssv3_score = "4.0" ,
208
+ expect_success = True ,
209
+ )
210
+
211
+ @on_exception_html_source_logger
212
+ def test_edit_finding_cvssv3_with_rubbish (self ):
213
+ self ._edit_finding_cvssv3_and_assert (
214
+ cvssv3_value = "happy little vector" ,
215
+ cvssv3_score = "4" ,
216
+ expected_cvssv3_value = None ,
217
+ expected_cvssv3_score = None ,
218
+ expect_success = False ,
219
+ error_message = "CVSS must be entered in format: 'AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H'" ,
220
+ )
221
+
134
222
def test_add_image (self ):
135
223
# The Name of the Finding created by test_add_product_finding => 'App Vulnerable to XSS'
136
224
# Test To Add Finding To product
@@ -519,6 +607,11 @@ def add_finding_tests_to_suite(suite, *, jira=False, github=False, block_executi
519
607
suite .addTest (FindingTest ("test_excel_export" ))
520
608
suite .addTest (FindingTest ("test_list_components" ))
521
609
suite .addTest (FindingTest ("test_edit_finding" ))
610
+ suite .addTest (FindingTest ("test_edit_finding_cvssv3_valid_vector" ))
611
+ suite .addTest (FindingTest ("test_edit_finding_cvssv3_valid_vector_no_prefix" ))
612
+ suite .addTest (FindingTest ("test_edit_finding_cvssv3_valid_vector_with_trailing_slash" ))
613
+ suite .addTest (FindingTest ("test_edit_finding_cvssv3_with_v2_vector" ))
614
+ suite .addTest (FindingTest ("test_edit_finding_cvssv3_with_rubbish" ))
522
615
suite .addTest (FindingTest ("test_add_note_to_finding" ))
523
616
suite .addTest (FindingTest ("test_add_image" ))
524
617
suite .addTest (FindingTest ("test_delete_image" ))
0 commit comments