Class: Watobo::Gui::StatisticsFrame

Inherits:
FXVerticalFrame
  • Object
show all
Defined in:
lib/watobo/gui/fuzzer_gui.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, opts) ⇒ StatisticsFrame

Returns a new instance of StatisticsFrame.



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# File 'lib/watobo/gui/fuzzer_gui.rb', line 430

def initialize(parent, opts)
  super(parent, opts)

  @log_queue = Queue.new

  @count_total = 0

  @count_text = FXLabel.new(self, "Total: 0")
  @count_text.setFont(FXFont.new(getApp(), "helvetica", 11, FONTWEIGHT_BOLD, FONTENCODING_DEFAULT))

  counter_frame = FXHorizontalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
  response_code_gb = FXGroupBox.new(counter_frame, "Response Codes", LAYOUT_SIDE_BOTTOM|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0)
  frame = FXVerticalFrame.new(response_code_gb, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
  sunken = FXVerticalFrame.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0)
  @response_code_tbl = FXTable.new(sunken, :opts => FRAME_SUNKEN|TABLE_COL_SIZABLE|TABLE_ROW_SIZABLE|LAYOUT_FILL_X|LAYOUT_FILL_Y|TABLE_READONLY|LAYOUT_SIDE_TOP, :padding => 2)
  @response_code_tbl.columnHeader.connect(SEL_COMMAND) {}
  clearResponseCodeTable()

  response_length_gb = FXGroupBox.new(counter_frame, "Response Length", LAYOUT_SIDE_BOTTOM|FRAME_GROOVE|LAYOUT_FILL_Y, 0, 0, 0, 0)
  frame = FXVerticalFrame.new(response_length_gb, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
  sunken = FXVerticalFrame.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0)
  @response_length_tbl = FXTable.new(sunken, :opts => FRAME_SUNKEN|TABLE_COL_SIZABLE|TABLE_ROW_SIZABLE|LAYOUT_FILL_X|LAYOUT_FILL_Y|TABLE_READONLY|LAYOUT_SIDE_TOP, :padding => 2)
  @response_length_tbl.columnHeader.connect(SEL_COMMAND) {}


  clearResponseLengthTable()

  start_update_timer
end

Instance Method Details

#addResponse(response) ⇒ Object



351
352
353
354
355
# File 'lib/watobo/gui/fuzzer_gui.rb', line 351

def addResponse(response)

  @log_queue << response

end

#clearResponseCodeTableObject



357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/watobo/gui/fuzzer_gui.rb', line 357

def clearResponseCodeTable()
  @response_code_tbl.clearItems()
  @response_code_tbl.setTableSize(0, 2)

  @response_code_tbl.setColumnText(0, "STATUS")
  @response_code_tbl.setColumnText(1, "COUNT")

  @response_code_tbl.rowHeader.width = 0
  @response_code_tbl.setColumnWidth(0, 70)

  @response_code_tbl.setColumnWidth(1, 70)


end

#clearResponseLengthTableObject



409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/watobo/gui/fuzzer_gui.rb', line 409

def clearResponseLengthTable()
  @response_length_tbl.clearItems()
  @response_length_tbl.setTableSize(0, 2)
  @response_length_tbl.columnHeader.height = 0
  @response_length_tbl.rowHeader.width = 0
  @response_length_tbl.setColumnWidth(0, 40)
  @response_length_tbl.setColumnWidth(1, 40)

  lastRowIndex = @response_length_tbl.getNumRows

  %w( MIN MAX AVRG ).each do |i|
    lastRowIndex = @response_length_tbl.getNumRows
    @response_length_tbl.appendRows(1)
    @response_length_tbl.setItemText(lastRowIndex, 0, i)
    @response_length_tbl.setItemText(lastRowIndex, 1, "0")
    @response_length_tbl.getItem(lastRowIndex, 0).justify = FXTableItem::LEFT
    @response_length_tbl.getItem(lastRowIndex, 1).justify = FXTableItem::LEFT
  end
end

#clearViewObject



345
346
347
348
349
# File 'lib/watobo/gui/fuzzer_gui.rb', line 345

def clearView()
  @count_total = 0
  clearResponseCodeTable()
  clearResponseLengthTable()
end

#start_update_timerObject



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/watobo/gui/fuzzer_gui.rb', line 372

def start_update_timer
  Watobo.save_thread {

    #print @log_queue.length
    while @log_queue.length > 0
      response = @log_queue.deq

      if response.respond_to? :status
        @count_total += 1
        @count_text.text = "Total: #{@count_total}"

        cstatus = response.status
        count_item = nil
        @response_code_tbl.getNumRows.times do |i|
          rc_item = @response_code_tbl.getItem(i, 0)
          count_item = @response_code_tbl.getItem(i, 1) if rc_item.text == response.status
          break unless count_item.nil?
        end

        if count_item.nil?
          lastRowIndex = @response_code_tbl.getNumRows
          @response_code_tbl.appendRows(1)
          @response_code_tbl.setItemText(lastRowIndex, 0, cstatus)
          @response_code_tbl.setItemText(lastRowIndex, 1, "1")
          count_item = @response_code_tbl.getItem(lastRowIndex, 1)
        else
          c = count_item.text.to_i
          count_item.text = (c + 1).to_s
        end
        @count_text.handle(self, FXSEL(SEL_UPDATE, 0), nil)
      end

    end
  }

end