コード例 #1
0
    def _report_exception(self, edata, eid, num, total):
        '''
        Report one or more bugs to w3af's Github, submit data to server.
        '''
        gh = GithubIssues(OAUTH_TOKEN)
        if not gh.login():
            msg = 'Failed to contact github.com. Please try again later.'
            om.out.console(msg)
        else:
            traceback_str = edata.traceback_str
            desc = edata.get_summary()
            plugins = edata.enabled_plugins
            summary = str(edata.exception)

            ticket_id, ticket_url = gh.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
ファイル: bug_report.py プロジェクト: Adastra-thw/w3af
    def _report_exception(self, edata, eid, num, total):
        '''
        Report one or more bugs to w3af's Github, submit data to server.
        '''
        gh = GithubIssues(OAUTH_TOKEN)
        if not gh.login():
            msg = 'Failed to contact github.com. Please try again later.'
            om.out.console(msg)
        else:
            traceback_str = edata.traceback_str
            desc = edata.get_summary()
            plugins = edata.enabled_plugins
            summary = str(edata.exception)

            ticket_id, ticket_url = gh.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))
コード例 #3
0
ファイル: common_windows.py プロジェクト: Adastra-thw/w3af
    def _login_github(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)
            user_exit, method, params = dlg_cred.run()
            dlg_cred.destroy()

            # The user closed the dialog and wants to exit
            if user_exit:
                return user_exit, None, None

            if method == dlg_ask_credentials.METHOD_GH:
                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 = (OAUTH_TOKEN, None)
                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 = (OAUTH_TOKEN, None)

            gh = GithubIssues(user, password)
            login_result = gh.login()
            invalid_login = not login_result

            if login_result:
                break

        return (False, gh, email)
コード例 #4
0
    def _login_github(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)
            user_exit, method, params = dlg_cred.run()
            dlg_cred.destroy()

            # The user closed the dialog and wants to exit
            if user_exit:
                return user_exit, None, None

            if method == dlg_ask_credentials.METHOD_GH:
                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 = (OAUTH_TOKEN, None)
                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 = (OAUTH_TOKEN, None)

            gh = GithubIssues(user, password)
            login_result = gh.login()
            invalid_login = not login_result

            if login_result:
                break

        return (False, gh, email)
コード例 #5
0
ファイル: test_github_issues.py プロジェクト: weisst/w3af
    def test_report(self):
        gh = GithubIssues(OAUTH_TOKEN)
        gh.login()

        summary = 'Unittest bug report'
        userdesc = 'Please remove this ticket'

        ticket_id, ticket_url = gh.report_bug(summary, userdesc)
        self.assertIsInstance(ticket_id, int)
        self.assertTrue(
            ticket_url.startswith(
                'https://github.com/andresriancho/w3af/issues/'))

        # Remove the ticket I've just created
        gh = Github(OAUTH_TOKEN)
        repo = gh.get_user('andresriancho').get_repo('w3af')
        issue = repo.get_issue(ticket_id)
        issue.edit(state='closed')
コード例 #6
0
    def test_report(self):
        gh = GithubIssues(OAUTH_TOKEN)
        gh.login()
        
        summary = 'Unittest bug report'
        userdesc = 'Please remove this ticket'

        ticket_id, ticket_url = gh.report_bug(summary, userdesc)
        self.assertIsInstance(ticket_id, int)
        self.assertTrue(ticket_url.startswith(
            'https://github.com/andresriancho/w3af/issues/'))
        
        # Remove the ticket I've just created
        gh = Github(OAUTH_TOKEN)
        repo = gh.get_user('andresriancho').get_repo('w3af')
        issue = repo.get_issue(ticket_id)
        issue.edit(state='closed')
コード例 #7
0
 def test_login_failed_user_pass(self):
     gh = GithubIssues('foobar', 'testbar')
     self.assertFalse(gh.login())
     
コード例 #8
0
 def test_login_success_token(self):
     gh = GithubIssues(OAUTH_TOKEN)
     self.assertTrue(gh.login())
コード例 #9
0
 def test_login_failed_token(self):
     gh = GithubIssues(OAUTH_TOKEN + 'foobar')
     self.assertFalse(gh.login())
コード例 #10
0
ファイル: test_github_issues.py プロジェクト: weisst/w3af
 def test_login_failed_user_pass(self):
     gh = GithubIssues('foobar', 'testbar')
     self.assertFalse(gh.login())
コード例 #11
0
ファイル: test_github_issues.py プロジェクト: weisst/w3af
 def test_login_success_token(self):
     gh = GithubIssues(OAUTH_TOKEN)
     self.assertTrue(gh.login())
コード例 #12
0
ファイル: test_github_issues.py プロジェクト: weisst/w3af
 def test_login_failed_token(self):
     gh = GithubIssues(OAUTH_TOKEN + 'foobar')
     self.assertFalse(gh.login())