コード例 #1
0
ファイル: test_git_client.py プロジェクト: 0x554simon/w3af
 def test_get_remote_head_id(self):
     # For some strange reason jenkins creates a branch called
     # jenkins-<job name> during the build, which makes this test FAIL
     # if we don't take that into account
     if get_current_branch().startswith('jenkins-'):
         raise SkipTest('Workaround for Jenkins Git plugin wierdness.')
     
     client = GitClient(W3AF_LOCAL_PATH)
     # I don't really want to wait for the local repo to update itself
     # using "git fetch", so I simply put this as a mock
     client.fetch = MagicMock()
     
     remote_head = client.get_remote_head_id()
     client.fetch.assert_called_once_with()
             
     self.assertEqual(len(remote_head), 40)
     self.assertIsInstance(remote_head, basestring)
     
     # Get the ID using an alternative way for double checking
     branch = 'refs/remotes/origin/%s' % get_current_branch()
     proc = subprocess.Popen(['git', 'for-each-ref', branch], stdout=subprocess.PIPE)
     commit_id_line = proc.stdout.readline()
     commit_id_line = commit_id_line.strip()
     commit_id, _ = commit_id_line.split(' ')
     
     self.assertEqual(remote_head, commit_id)
コード例 #2
0
    def test_get_remote_head_id(self):
        # For some strange reason jenkins creates a branch called
        # jenkins-<job name> during the build, which makes this test FAIL
        # if we don't take that into account
        if get_current_branch().startswith('jenkins-'):
            raise SkipTest('Workaround for Jenkins Git plugin wierdness.')

        client = GitClient(W3AF_LOCAL_PATH)
        # I don't really want to wait for the local repo to update itself
        # using "git fetch", so I simply put this as a mock
        client.fetch = MagicMock()

        remote_head = client.get_remote_head_id()
        client.fetch.assert_called_once_with()

        self.assertEqual(len(remote_head), 40)
        self.assertIsInstance(remote_head, basestring)

        # Get the ID using an alternative way for double checking
        branch = 'refs/remotes/origin/%s' % get_current_branch()
        proc = subprocess.Popen(['git', 'for-each-ref', branch],
                                stdout=subprocess.PIPE)
        commit_id_line = proc.stdout.readline()
        commit_id_line = commit_id_line.strip()
        commit_id, _ = commit_id_line.split(' ')

        self.assertEqual(remote_head, commit_id)
コード例 #3
0
ファイル: git_client.py プロジェクト: 0x554simon/w3af
 def get_local_head_id(self):
     """
     :return: The ID for the latest commit in the LOCAL repo.
     """
     branch_name = get_current_branch()
     repo_refs = self._repo.refs
     origin_master = [ref for ref in repo_refs if ref.name == branch_name][0]
     
     return origin_master.commit.hexsha
コード例 #4
0
ファイル: git_client.py プロジェクト: webvul/webfuzzer
    def get_local_head_id(self):
        """
        :return: The ID for the latest commit in the LOCAL repo.
        """
        branch_name = get_current_branch()
        repo_refs = self._repo.refs
        origin_master = [ref for ref in repo_refs
                         if ref.name == branch_name][0]

        return origin_master.commit.hexsha
コード例 #5
0
ファイル: test_update_utils.py プロジェクト: 0x554simon/w3af
 def test_get_current_branch(self):
     # For some strange reason jenkins creates a branch called
     # jenkins-<job name> during the build, which makes this test FAIL
     # if we don't take that into account
     
     current_branch = get_current_branch()
     
     branches = subprocess.check_output(['git', 'branch']).splitlines()
     parsed_branch = [l.strip()[2:] for l in branches if l.startswith('*')][0]
     
     self.assertEqual(current_branch, parsed_branch)
コード例 #6
0
    def test_get_current_branch(self):
        # For some strange reason jenkins creates a branch called
        # jenkins-<job name> during the build, which makes this test FAIL
        # if we don't take that into account

        current_branch = get_current_branch()

        branches = subprocess.check_output(['git', 'branch']).splitlines()
        parsed_branch = [l.strip()[2:] for l in branches if l.startswith('*')][0]

        self.assertEqual(current_branch, parsed_branch)
コード例 #7
0
ファイル: git_client.py プロジェクト: 0x554simon/w3af
 def get_remote_head_id(self):
     """
     :return: The ID for the latest commit in the REMOTE repo.
     """
     # Get the latest changes from the remote end
     self.fetch()
     
     branch_origin = 'origin/%s' % get_current_branch()
     all_refs = self._repo.remotes.origin.refs
     origin_master = [ref for ref in all_refs if ref.name == branch_origin][0]
     
     return origin_master.commit.hexsha
コード例 #8
0
def get_w3af_version_as_dict():
    """
    :return: All the version information in a dict
    """
    commit = to_short_id(get_latest_commit()) if is_git_repo() else 'unknown'
    cdate = ' - %s' % get_latest_commit_date() if is_git_repo() else ''
    branch = get_current_branch() if is_git_repo() else 'unknown'
    dirty = 'Yes' if is_dirty_repo() else 'No'

    return {'version': get_minimalistic_version(),
            'revision': commit + cdate,
            'branch': branch,
            'dirty': dirty}
コード例 #9
0
ファイル: git_client.py プロジェクト: webvul/webfuzzer
    def get_remote_head_id(self):
        """
        :return: The ID for the latest commit in the REMOTE repo.
        """
        # Get the latest changes from the remote end
        self.fetch()

        branch_origin = 'origin/%s' % get_current_branch()
        all_refs = self._repo.remotes.origin.refs
        origin_master = [ref for ref in all_refs
                         if ref.name == branch_origin][0]

        return origin_master.commit.hexsha
コード例 #10
0
def get_w3af_version():
    """
    :return: A string with the w3af version.
    """
    commit = to_short_id(get_latest_commit()) if is_git_repo() else 'unknown'
    cdate = ' - %s' % get_latest_commit_date() if is_git_repo() else ''
    branch = get_current_branch() if is_git_repo() else 'unknown'
    dirty = 'Yes' if is_dirty_repo() else 'No'

    vnumber = get_minimalistic_version()
    
    return ('w3af - Web Application Attack and Audit Framework\n'
            'Version: %s\n'
            'Distribution: Kali Linux\n'
            'Author: Andres Riancho and the w3af team.') % (vnumber)
コード例 #11
0
def open_help(chapter=''):
    """Opens the help in user's preferred browser.

    :param chapter: the chapter of the help, optional.
    """
    current_branch = get_current_branch()

    if current_branch in (DETACHED_HEAD, 'master'):
        current_branch = 'latest'

    help_url = DOC_ROOT_FMT % current_branch

    if chapter:
        help_url += DOC_ROUTER.get(chapter.lower(), '')

    webbrowser.open(help_url)
コード例 #12
0
def open_help(chapter=""):
    """Opens the help in user's preferred browser.

    :param chapter: the chapter of the help, optional.
    """
    current_branch = get_current_branch()

    if current_branch in (DETACHED_HEAD, "master"):
        current_branch = "latest"

    help_url = DOC_ROOT_FMT % current_branch

    if chapter:
        help_url += DOC_ROUTER.get(chapter.lower(), "")

    webbrowser.open(help_url)
コード例 #13
0
ファイル: get_w3af_version.py プロジェクト: johnjohnsp1/w3af
def get_w3af_version():
    """
    :return: A string with the w3af version.
    """
    commit = to_short_id(get_latest_commit()) if is_git_repo() else 'unknown'
    cdate = ' - %s' % get_latest_commit_date() if is_git_repo() else ''
    branch = get_current_branch() if is_git_repo() else 'unknown'
    dirty = 'Yes' if is_dirty_repo() else 'No'

    vnumber = get_minimalistic_version()

    return ('w3af - Web Application Attack and Audit Framework\n'
            'Version: %s\n'
            'Revision: %s%s\n'
            'Branch: %s\n'
            'Local changes: %s\n'
            'Author: Andres Riancho and the w3af team.') % (
                vnumber, commit, cdate, branch, dirty)
コード例 #14
0
ファイル: open_help.py プロジェクト: 0x554simon/w3af
def open_help(chapter=''):
    """Opens the help in user's preferred browser.

    :param chapter: the chapter of the help, optional.
    """
    try:
        current_branch = get_current_branch()
    except git.exc.InvalidGitRepositoryError:
        current_branch = 'latest'
    else:
        if current_branch in (DETACHED_HEAD, 'master'):
            current_branch = 'latest'

    help_url = DOC_ROOT_FMT % current_branch

    if chapter:
        help_url += DOC_ROUTER.get(chapter.lower(), '')

    webbrowser.open(help_url)
コード例 #15
0
ファイル: open_help.py プロジェクト: webvul/webfuzzer
def open_help(chapter=''):
    """Opens the help in user's preferred browser.

    :param chapter: the chapter of the help, optional.
    """
    try:
        current_branch = get_current_branch()
    except git.exc.InvalidGitRepositoryError:
        current_branch = 'latest'
    else:
        if current_branch in (DETACHED_HEAD, 'master'):
            current_branch = 'latest'

    help_url = DOC_ROOT_FMT % current_branch

    if chapter:
        help_url += DOC_ROUTER.get(chapter.lower(), '')

    webbrowser.open(help_url)
コード例 #16
0
def get_w3af_version_as_dict():
    """
    This method seems to take considerable time to run when w3af is run from
    a git installation (.git directory is present). All of the time it takes
    to solve this function comes from get_w3af_version_as_dict(), which
    reads the Git meta-data.

    Some plugins, such as xml_file, call get_w3af_version every N seconds to
    write that information to the output file. I added @memoized in order to
    reduce the time it takes to run the output plugin.

    :return: All the version information in a dict
    """
    commit = to_short_id(get_latest_commit()) if is_git_repo() else 'unknown'
    cdate = ' - %s' % get_latest_commit_date() if is_git_repo() else ''
    branch = get_current_branch() if is_git_repo() else 'unknown'
    dirty = 'Yes' if is_dirty_repo() else 'No'

    return {'version': get_minimalistic_version(),
            'revision': commit + cdate,
            'branch': branch,
            'dirty': dirty}
コード例 #17
0
ファイル: get_w3af_version.py プロジェクト: chenbremer/w3af-1
def get_w3af_version_as_dict():
    """
    This method seems to take considerable time to run when w3af is run from
    a git installation (.git directory is present). All of the time it takes
    to solve this function comes from get_w3af_version_as_dict(), which
    reads the Git meta-data.

    Some plugins, such as xml_file, call get_w3af_version every N seconds to
    write that information to the output file. I added @memoized in order to
    reduce the time it takes to run the output plugin.

    :return: All the version information in a dict
    """
    commit = to_short_id(get_latest_commit()) if is_git_repo() else 'unknown'
    cdate = ' - %s' % get_latest_commit_date() if is_git_repo() else ''
    branch = get_current_branch() if is_git_repo() else 'unknown'
    dirty = 'Yes' if is_dirty_repo() else 'No'

    return {
        'version': get_minimalistic_version(),
        'revision': commit + cdate,
        'branch': branch,
        'dirty': dirty
    }