Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
openSUSE:Leap:15.4:Update
python-suds-jurko
suds-insecure-cache-tempdir.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File suds-insecure-cache-tempdir.patch of Package python-suds-jurko
--- suds/cache.py.orig 2014-01-21 20:06:03.000000000 +0100 +++ suds/cache.py 2014-02-11 13:22:39.047914048 +0100 @@ -26,7 +26,7 @@ from datetime import datetime as dt from datetime import timedelta import os -from tempfile import gettempdir as tmp +import tempfile try: import cPickle as pickle except Exception: @@ -93,6 +93,9 @@ A file-based URL cache. @cvar fnprefix: The file name prefix. @type fnsuffix: str + @cvar remove_default_location_on_exit: Whether to remove the default cache + location on process exit (default=True). + @type remove_default_location_on_exit: bool @ivar duration: The cached file duration which defines how long the file will be cached. @type duration: (unit, value) @@ -100,10 +103,21 @@ @type location: str """ fnprefix = 'suds' + __default_location = None + remove_default_location_on_exit = True units = ('months', 'weeks', 'days', 'hours', 'minutes', 'seconds') def __init__(self, location=None, **duration): """ + Initialized a new FileCache instance. + + If no cache location is specified, a temporary default location will be + used. Such default cache location will be shared by all FileCache + instances with no explicitly specified location within the same + process. The default cache location will be removed automatically on + process exit unless user sets the remove_default_location_on_exit + FileCache class attribute to False. + @param location: The directory for the cached files. @type location: str @param duration: The cached file duration which defines how @@ -112,7 +126,7 @@ @type duration: {unit:value} """ if location is None: - location = os.path.join(tmp(), 'suds') + location = self.__get_default_location() self.location = location self.duration = (None, 0) self.setduration(**duration) @@ -250,6 +264,34 @@ fn = '%s-%s.%s' % (self.fnprefix, name, suffix) return os.path.join(self.location, fn) + @staticmethod + def __get_default_location(): + """ + Returns the current process's default cache location folder. + + The folder is determined lazily on first call. + + """ + if not FileCache.__default_location: + tmp = tempfile.mkdtemp("suds-default-cache") + FileCache.__default_location = tmp + import atexit + atexit.register(FileCache.__remove_default_location) + return FileCache.__default_location + + @staticmethod + def __remove_default_location(): + """ + Removes the default cache location folder. + + This removal may be disabled by setting the + remove_default_location_on_exit FileCache class attribute to False. + + """ + if FileCache.remove_default_location_on_exit: + import shutil + shutil.rmtree(FileCache.__default_location, ignore_errors=True) + class DocumentCache(FileCache): """ --- tests/test_cache.py.orig 2014-01-21 20:06:03.000000000 +0100 +++ tests/test_cache.py 2014-02-11 13:32:00.713225646 +0100 @@ -133,14 +133,7 @@ assert cache2.get("unga2") == value_p22 -def test_FileCache_location(tmpdir): - defaultLocation = os.path.join(tempfile.gettempdir(), "suds") - cache = suds.cache.FileCache() - assert os.path.isdir(cache.location) - assert cache.location == defaultLocation - assert suds.cache.FileCache().location == defaultLocation - assert cache.location == defaultLocation - +def test_FileCache_non_default_location(tmpdir): cacheFolder1 = tmpdir.join("flip-flop1").strpath assert not os.path.isdir(cacheFolder1) assert suds.cache.FileCache(location=cacheFolder1).location == cacheFolder1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor