예제 #1
0
 def _report_exception(self, edata, eid, num, total):
     '''
     Report one or more bugs to w3af's Trac, submit data to server.
     '''
     sf = SourceforgeXMLRPC(DEFAULT_USER_NAME, DEFAULT_PASSWD)
     if not sf.login():
         om.out.console('Failed to contact Trac server. Please try again later.')
     else:
         traceback_str = edata.traceback_str
         desc = edata.get_summary()
         plugins = edata.enabled_plugins
         summary = str(edata.exception)
         
         ticket_id, ticket_url = sf.report_bug( summary, desc, tback=traceback_str,
                                                plugins=plugins)
         
         if ticket_id is None:
             msg = '    [%s/%s] Failed to report bug with id %s.' % (num, total, eid)
         else:
             msg = '    [%s/%s] Bug with id %s reported at %s' % (num, total, eid, ticket_url)
     
         om.out.console( str(msg) )
예제 #2
0
    def _login_sf(self, retry=3):
        '''
        Perform user login.
        '''
        invalid_login = False
        email = None
        
        while retry:
            # Decrement retry counter
            retry -= 1
            # Ask for user and password, or anonymous
            dlg_cred = dlg_ask_credentials(invalid_login)
            method, params = dlg_cred.run()
            dlg_cred.destroy()
            
            if method == dlg_ask_credentials.METHOD_SF:
                user, password = params
            
            elif method == dlg_ask_credentials.METHOD_EMAIL:
                # The user chose METHOD_ANON or METHOD_EMAIL with both these
                # methods the framework actually logs in using our default 
                # credentials
                user, password = (DEFAULT_USER_NAME, DEFAULT_PASSWD)
                email = params[0]

            else:
                # The user chose METHOD_ANON or METHOD_EMAIL with both these
                # methods the framework actually logs in using our default 
                # credentials
                user, password = (DEFAULT_USER_NAME, DEFAULT_PASSWD)
            
            sf = SourceforgeXMLRPC(user, password)
            login_result = sf.login()
            invalid_login = not login_result
            
            if login_result:
                break
            
        return (sf, email)