def __init__(self, scroll_bar, active_filter, possible): ''' @param scroll_bar: Gtk Vertical Scrollbar object @param active_filter: the filter active at startup. @param possible: all filter keys ''' gtk.TextView.__init__(self) self.set_editable(False) self.set_cursor_visible(False) self.set_wrap_mode(gtk.WRAP_WORD) self.textbuffer = self.get_buffer() self.show() self.messages = getQueueDiverter() self.all_messages = disk_list() self.possible = set(possible) self.active_filter = active_filter self.text_position = 0 # scroll bar self.freeze_scrollbar = False scroll_bar.connect("value-changed", self.scroll_changed) # colors self.textbuffer.create_tag("red-fg", foreground="red") self.textbuffer.create_tag("blue-fg", foreground="blue") self.textbuffer.create_tag("brown-fg", foreground="brown") self.bg_colors = { "vulnerability": "red-fg", "information": "blue-fg", "error": "brown-fg", } gobject.timeout_add(500, self.addMessage().next)
def test_len(self): dl = disk_list() for i in xrange(0, 100): _ = dl.append(i) self.assertEqual( len(dl) == 100, True)
def test_urlobject(self): dl = disk_list() dl.append( url_object('http://w3af.org/?id=2') ) dl.append( url_object('http://w3af.org/?id=3') ) self.assertEqual( dl[0] , url_object('http://w3af.org/?id=2')) self.assertEqual( dl[1] , url_object('http://w3af.org/?id=3')) self.assertFalse( url_object('http://w3af.org/?id=4') in dl ) self.assertTrue( url_object('http://w3af.org/?id=2') in dl )
def test_unicode(self): dl = disk_list() dl.append( u'à' ) dl.append( u'המלצת השבוע' ) dl.append( [u'à',] ) self.assertEqual( dl[0] , u'à') self.assertEqual( dl[1] , u'המלצת השבוע') self.assertEqual( dl[2] , [u'à',])
def test_sorted(self): dl = disk_list() dl.append( 'abc' ) dl.append( 'def' ) dl.append( 'aaa' ) sorted_dl = sorted(dl) self.assertEqual( ['aaa','abc','def'], sorted_dl)
def test_getitem(self): dl = disk_list() dl.append( 'a' ) dl.append( 1 ) dl.append( [3,2,1] ) self.assertEqual( dl[0] == 'a', True) self.assertEqual( dl[1] == 1 , True) self.assertEqual( dl[2] == [3,2,1], True)
def test_reverse_iteration(self): dl = disk_list() dl.append(1) dl.append(2) dl.append(3) reverse_iter_res = [] for i in reversed(dl): reverse_iter_res.append(i) self.assertEqual( reverse_iter_res, [3,2,1])
def test_clear(self): dl = disk_list() dl.append( 'a' ) dl.append( 'b' ) self.assertEqual( len(dl), 2) dl.clear() self.assertEqual( len(dl), 0)
def test_extend(self): dl = disk_list() dl.append( 'a' ) dl.extend( [1,2,3] ) self.assertEqual( len(dl), 4) self.assertEqual( dl[0] , 'a') self.assertEqual( dl[1] , 1) self.assertEqual( dl[2] , 2) self.assertEqual( dl[3] , 3)
def test_ordered_iter(self): dl = disk_list() dl.append( 'abc' ) dl.append( 'def' ) dl.append( 'aaa' ) sorted_dl = [] for i in dl.ordered_iter(): sorted_dl.append(i) self.assertEqual( ['aaa','abc','def'], sorted_dl)
def test_string(self): dl = disk_list() for i in xrange(0, 1000): rnd = ''.join(random.choice(string.letters) for i in xrange(40)) _ = dl.append(rnd) self.assertEqual(rnd in dl, True) for i in string.letters: self.assertEqual(i in dl, False) self.assertEqual(rnd in dl, True)
def test_int(self): dl = disk_list() for i in xrange(0, 1000): _ = dl.append(i) for i in xrange(0, 1000 / 2 ): r = random.randint(0,1000-1) self.assertEqual(r in dl, True) for i in xrange(0, 1000 / 2 ): r = random.randint(1000,1000 * 2) self.assertEqual(r in dl, False)
def test_pickle(self): dl = disk_list() dl.append( 'a' ) dl.append( 1 ) dl.append( [3,2,1] ) values = [] for i in dl: values.append(i) self.assertEqual( values[0] == 'a', True) self.assertEqual( values[1] == 1, True) self.assertEqual( values[2] == [3,2,1], True)
def test_fuzzable_request(self): dl = disk_list() uri = url_object('http://w3af.org/?id=2') qsr1 = HTTPQSRequest(uri, method='GET', headers={'Referer': 'http://w3af.org/'}) uri = url_object('http://w3af.org/?id=3') qsr2 = HTTPQSRequest(uri, method='OPTIONS', headers={'Referer': 'http://w3af.com/'}) uri = url_object('http://w3af.org/?id=7') qsr3 = HTTPQSRequest(uri, method='FOO', headers={'Referer': 'http://w3af.com/'}) dl.append( qsr1 ) dl.append( qsr2 ) self.assertEqual( dl[0] , qsr1) self.assertEqual( dl[1] , qsr2) self.assertFalse( qsr3 in dl ) self.assertTrue( qsr2 in dl )
def test_not(self): dl = disk_list() self.assertFalse( dl )
def __init__(self): baseGrepPlugin.__init__(self) self._total_count = 0 self._vuln_count = 0 self._vulns = disk_list()