Exemple #1
0
    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)
Exemple #2
0
    def test_len(self):
        dl = disk_list()

        for i in xrange(0, 100):
            _ = dl.append(i)

        self.assertEqual( len(dl) == 100, True)
Exemple #3
0
    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 )
Exemple #4
0
    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'à',])
Exemple #5
0
    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)
Exemple #6
0
    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)
Exemple #7
0
 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])
Exemple #8
0
    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)
Exemple #9
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)
Exemple #10
0
    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)        
Exemple #11
0
    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)
Exemple #12
0
    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)
Exemple #13
0
    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)
Exemple #14
0
    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 )
Exemple #15
0
 def test_not(self):
     dl = disk_list()
     self.assertFalse( dl )
Exemple #16
0
 def __init__(self):
     baseGrepPlugin.__init__(self)
     self._total_count = 0
     self._vuln_count = 0
     self._vulns = disk_list()