예제 #1
0
 def _generate_report(self, changelog, local_commit_id, remote_commit_id):
     '''
     :return: A string with a report of the latest update from local commit
              to remote commit which changes stuff in changelog.
     '''
     lshort = to_short_id(local_commit_id)
     rshort = to_short_id(remote_commit_id)
     ldate = get_commit_id_date(local_commit_id)
     rdate = get_commit_id_date(remote_commit_id)
     
     report = 'The following changes were applied to the local w3af'\
              ' installation during the last update from %s (%s) to'\
              ' %s (%s):\n\n%s'
     
     return report % (lshort, ldate, rshort, rdate, changelog)
예제 #2
0
    def update(self, force=False):
        '''
        Perform code update if necessary. Return three elems tuple with the
        ChangeLog of the changed files, the local and the final commit id.

        :param force: Force update ignoring the startup config.
        :return: (changelog: A ChangeLog instance,
                  local_head_id: The local id before the update,
                  commit_id: The commit id after the update)
                  
        '''
        if not force and not self._has_to_update():
            # No need to update based on user preferences
            return
        
        # Save the latest update date, always, even when the update had errors
        # or there was no update available
        self._start_cfg.last_upd = date.today()
        self._start_cfg.save()
        
        local_head_id = self._client.get_local_head_id()
        short_local_head_id = to_short_id(local_head_id)
        
        # Lets update!
        self._notify(VersionMgr.ON_UPDATE_CHECK)
        
        # This performs a fetch() which takes time
        remote_head_id = self._client.get_remote_head_id()
        short_remote_head_id = to_short_id(remote_head_id)
        
        if local_head_id == remote_head_id:
            # If local and repo's rev are the same => Nothing to do.
            self._notify(VersionMgr.ON_ALREADY_LATEST)
            return
        
        if self._user_confirmed_update(short_local_head_id, local_head_id,
                                       short_remote_head_id, remote_head_id):
            return self.__update_impl()
예제 #3
0
    def update(self, force=False):
        '''
        Perform code update if necessary. Return three elems tuple with the
        ChangeLog of the changed files, the local and the final commit id.

        :param force: Force update ignoring the startup config.
        :return: (changelog: A ChangeLog instance,
                  local_head_id: The local id before the update,
                  commit_id: The commit id after the update)
                  
        '''
        if not force and not self._has_to_update():
            # No need to update based on user preferences
            return

        # Save the latest update date, always, even when the update had errors
        # or there was no update available
        self._start_cfg.last_upd = date.today()
        self._start_cfg.save()

        local_head_id = self._client.get_local_head_id()
        short_local_head_id = to_short_id(local_head_id)

        # Lets update!
        self._notify(VersionMgr.ON_UPDATE_CHECK)

        # This performs a fetch() which takes time
        remote_head_id = self._client.get_remote_head_id()
        short_remote_head_id = to_short_id(remote_head_id)

        if local_head_id == remote_head_id:
            # If local and repo's rev are the same => Nothing to do.
            self._notify(VersionMgr.ON_ALREADY_LATEST)
            return

        if self._user_confirmed_update(short_local_head_id, local_head_id,
                                       short_remote_head_id, remote_head_id):
            return self.__update_impl()
예제 #4
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 ''
    
    vnumber = file(VERSION_FILE).read().strip()
    
    return ('w3af - Web Application Attack and Audit Framework\n'
            'Version: %s\n'
            'Revision: %s%s\n'
            'Author: Andres Riancho and the w3af team.') % (vnumber, commit,
                                                            cdate)