commit/galaxy-central: greg: Fix for determining the extraction directory for tool dependency tarballs when installing tool dependencies along with tool shed repositories.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/f156b9e14443/ changeset: f156b9e14443 user: greg date: 2012-10-25 20:46:57 summary: Fix for determining the extraction directory for tool dependency tarballs when installing tool dependencies along with tool shed repositories. affected #: 2 files diff -r 42eedc24fdd62034ce039bf56b2bbb0b382c63e0 -r f156b9e144437e541127009c2a32efc1019af5c7 lib/galaxy/tool_shed/tool_dependencies/common_util.py --- a/lib/galaxy/tool_shed/tool_dependencies/common_util.py +++ b/lib/galaxy/tool_shed/tool_dependencies/common_util.py @@ -1,18 +1,6 @@ import os, shutil, tarfile, urllib2, zipfile from galaxy.datatypes.checkers import * -def zipfile_ok( path_to_archive ): - """ - This function is a bit pedantic and not functionally necessary. It checks whether there is no file pointing outside of the extraction, - because ZipFile.extractall() has some potential security holes. See python zipfile documentation for more details. - """ - basename = os.path.realpath( os.path.dirname( path_to_archive ) ) - zip_archive = zipfile.ZipFile( path_to_archive ) - for member in zip_archive.namelist(): - member_path = os.path.realpath( os.path.join( basename, member ) ) - if not member_path.startswith( basename ): - return False - return True def create_env_var_dict( elem, tool_dependency_install_dir=None, tool_shed_repository_install_dir=None ): env_var_name = elem.get( 'name', 'PATH' ) env_var_action = elem.get( 'action', 'prepend_to' ) @@ -103,6 +91,7 @@ os.makedirs( destination_directory ) shutil.move( source_file, destination_directory ) def tar_extraction_directory( file_path, file_name ): + """Try to return the correct extraction directory.""" file_name = file_name.strip() extensions = [ '.tar.gz', '.tgz', '.tar.bz2', '.zip' ] for extension in extensions: @@ -111,8 +100,8 @@ if os.path.exists( os.path.abspath( os.path.join( file_path, dir_name ) ) ): return dir_name if os.path.exists( os.path.abspath( os.path.join( file_path, file_name ) ) ): - return os.path.abspath( os.path.join( file_path, file_name ) ) - raise ValueError( 'Could not find directory %s' % os.path.abspath( os.path.join( file_path, file_name[ :-len( extension ) ] ) ) ) + return os.path.abspath( file_path ) + raise ValueError( 'Could not find path to file %s' % os.path.abspath( os.path.join( file_path, file_name ) ) ) def url_download( install_dir, downloaded_file_name, download_url ): file_path = os.path.join( install_dir, downloaded_file_name ) src = None @@ -138,3 +127,15 @@ if os.path.isdir( os.path.join( file_path, files[ 0 ] ) ): return os.path.abspath( os.path.join( file_path, files[ 0 ] ) ) raise ValueError( 'Could not find directory for the extracted file %s' % os.path.abspath( os.path.join( file_path, file_name ) ) ) +def zipfile_ok( path_to_archive ): + """ + This function is a bit pedantic and not functionally necessary. It checks whether there is no file pointing outside of the extraction, + because ZipFile.extractall() has some potential security holes. See python zipfile documentation for more details. + """ + basename = os.path.realpath( os.path.dirname( path_to_archive ) ) + zip_archive = zipfile.ZipFile( path_to_archive ) + for member in zip_archive.namelist(): + member_path = os.path.realpath( os.path.join( basename, member ) ) + if not member_path.startswith( basename ): + return False + return True diff -r 42eedc24fdd62034ce039bf56b2bbb0b382c63e0 -r f156b9e144437e541127009c2a32efc1019af5c7 lib/galaxy/tool_shed/tool_dependencies/fabric_util.py --- a/lib/galaxy/tool_shed/tool_dependencies/fabric_util.py +++ b/lib/galaxy/tool_shed/tool_dependencies/fabric_util.py @@ -79,7 +79,7 @@ if not os.path.exists( dir ): os.makedirs( dir ) # The package has been down-loaded, so we can now perform all of the actions defined for building it. - with lcd( dir ): + with lcd( dir ): for action_tup in actions[ 1: ]: action_type, action_dict = action_tup current_dir = os.path.abspath( os.path.join( work_dir, dir ) ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket