12
12
13
13
14
14
class FuzzingDialog (QDialog ):
15
- def __init__ (self , protocol : ProtocolAnalyzerContainer , label_index : int , msg_index : int , proto_view : int , parent = None ):
15
+ def __init__ (self , protocol : ProtocolAnalyzerContainer , label_index : int , msg_index : int , proto_view : int ,
16
+ parent = None ):
16
17
super ().__init__ (parent )
17
18
self .ui = Ui_FuzzingDialog ()
18
19
self .ui .setupUi (self )
@@ -113,9 +114,7 @@ def create_connects(self):
113
114
self .ui .spinBoxRandomMinimum .valueChanged .connect (self .on_random_range_min_changed )
114
115
self .ui .spinBoxRandomMaximum .valueChanged .connect (self .on_random_range_max_changed )
115
116
self .ui .spinBoxFuzzMessage .valueChanged .connect (self .on_fuzz_msg_changed )
116
- self .ui .btnAddRange .clicked .connect (self .on_btn_add_range_clicked )
117
- self .ui .btnAddBoundaries .clicked .connect (self .on_btn_add_boundaries_clicked )
118
- self .ui .btnAddRandom .clicked .connect (self .on_btn_add_random_clicked )
117
+ self .ui .btnAddFuzzingValues .clicked .connect (self .on_btn_add_fuzzing_values_clicked )
119
118
self .ui .comboBoxFuzzingLabel .editTextChanged .connect (self .set_current_label_name )
120
119
121
120
def update_message_data_string (self ):
@@ -245,11 +244,9 @@ def on_fuzzing_range_end_changed(self, value: int):
245
244
def on_lower_bound_checked_changed (self ):
246
245
if self .ui .checkBoxLowerBound .isChecked ():
247
246
self .ui .spinBoxLowerBound .setEnabled (True )
248
- self .ui .btnAddBoundaries .setEnabled (True )
249
247
self .ui .spinBoxBoundaryNumber .setEnabled (True )
250
248
elif not self .ui .checkBoxUpperBound .isChecked ():
251
249
self .ui .spinBoxLowerBound .setEnabled (False )
252
- self .ui .btnAddBoundaries .setEnabled (False )
253
250
self .ui .spinBoxBoundaryNumber .setEnabled (False )
254
251
else :
255
252
self .ui .spinBoxLowerBound .setEnabled (False )
@@ -258,11 +255,9 @@ def on_lower_bound_checked_changed(self):
258
255
def on_upper_bound_checked_changed (self ):
259
256
if self .ui .checkBoxUpperBound .isChecked ():
260
257
self .ui .spinBoxUpperBound .setEnabled (True )
261
- self .ui .btnAddBoundaries .setEnabled (True )
262
258
self .ui .spinBoxBoundaryNumber .setEnabled (True )
263
259
elif not self .ui .checkBoxLowerBound .isChecked ():
264
260
self .ui .spinBoxUpperBound .setEnabled (False )
265
- self .ui .btnAddBoundaries .setEnabled (False )
266
261
self .ui .spinBoxBoundaryNumber .setEnabled (False )
267
262
else :
268
263
self .ui .spinBoxUpperBound .setEnabled (False )
@@ -288,14 +283,21 @@ def on_random_range_max_changed(self):
288
283
self .ui .spinBoxRandomMinimum .setMaximum (self .ui .spinBoxRandomMaximum .value () - 1 )
289
284
290
285
@pyqtSlot ()
291
- def on_btn_add_range_clicked (self ):
286
+ def on_btn_add_fuzzing_values_clicked (self ):
287
+ if self .ui .comboBoxStrategy .currentIndex () == 0 :
288
+ self .__add_fuzzing_range ()
289
+ elif self .ui .comboBoxStrategy .currentIndex () == 1 :
290
+ self .__add_fuzzing_boundaries ()
291
+ elif self .ui .comboBoxStrategy .currentIndex () == 2 :
292
+ self .__add_random_fuzzing_values ()
293
+
294
+ def __add_fuzzing_range (self ):
292
295
start = self .ui .sBAddRangeStart .value ()
293
296
end = self .ui .sBAddRangeEnd .value ()
294
297
step = self .ui .sBAddRangeStep .value ()
295
298
self .fuzz_table_model .add_range (start , end + 1 , step )
296
299
297
- @pyqtSlot ()
298
- def on_btn_add_boundaries_clicked (self ):
300
+ def __add_fuzzing_boundaries (self ):
299
301
lower_bound = - 1
300
302
if self .ui .spinBoxLowerBound .isEnabled ():
301
303
lower_bound = self .ui .spinBoxLowerBound .value ()
@@ -307,8 +309,7 @@ def on_btn_add_boundaries_clicked(self):
307
309
num_vals = self .ui .spinBoxBoundaryNumber .value ()
308
310
self .fuzz_table_model .add_boundaries (lower_bound , upper_bound , num_vals )
309
311
310
- @pyqtSlot ()
311
- def on_btn_add_random_clicked (self ):
312
+ def __add_random_fuzzing_values (self ):
312
313
n = self .ui .spinBoxNumberRandom .value ()
313
314
minimum = self .ui .spinBoxRandomMinimum .value ()
314
315
maximum = self .ui .spinBoxRandomMaximum .value ()
@@ -354,7 +355,7 @@ def on_fuzz_msg_changed(self, index: int):
354
355
@pyqtSlot ()
355
356
def on_btn_repeat_values_clicked (self ):
356
357
num_repeats , ok = QInputDialog .getInt (self , self .tr ("How many times shall values be repeated?" ),
357
- self .tr ("Number of repeats:" ), 1 , 1 )
358
+ self .tr ("Number of repeats:" ), 1 , 1 )
358
359
if ok :
359
360
self .ui .chkBRemoveDuplicates .setChecked (False )
360
361
min_row , max_row , _ , _ = self .ui .tblFuzzingValues .selection_range ()
0 commit comments