-
Notifications
You must be signed in to change notification settings - Fork 0
Disable cache backend using pickle #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,6 +111,7 @@ def __init__(self, directory, min_file_size=0, pickle_protocol=0): | |
| :param int pickle_protocol: pickle protocol for serialization | ||
|
|
||
| """ | ||
| raise RuntimeError("Disk has been disabled as a mitigation for CVE-2025-69872. Please use JSONDisk instead.") | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also considered raising other errors - |
||
| self._directory = directory | ||
| self.min_file_size = min_file_size | ||
| self.pickle_protocol = pickle_protocol | ||
|
|
@@ -232,7 +233,7 @@ def _write(self, full_path, iterator, mode, encoding=None): | |
|
|
||
| for count in range(1, 11): | ||
| with cl.suppress(OSError): | ||
| os.makedirs(full_dir) | ||
| os.makedirs(full_dir, 0o700) | ||
|
|
||
| try: | ||
| # Another cache may have deleted the directory before | ||
|
|
@@ -348,7 +349,7 @@ def __init__(self, directory, compress_level=1, **kwargs): | |
|
|
||
| """ | ||
| self.compress_level = compress_level | ||
| super().__init__(directory, **kwargs) | ||
| self._directory = directory | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This still keeps the relationship between |
||
|
|
||
| def put(self, key): | ||
| json_bytes = json.dumps(key).encode('utf-8') | ||
|
|
@@ -417,7 +418,7 @@ def args_to_key(base, args, kwargs, typed, ignore): | |
| class Cache: | ||
| """Disk and file backed cache.""" | ||
|
|
||
| def __init__(self, directory=None, timeout=60, disk=Disk, **settings): | ||
| def __init__(self, directory=None, timeout=60, disk=JSONDisk, **settings): | ||
| """Initialize cache instance. | ||
|
|
||
| :param str directory: cache directory | ||
|
|
@@ -444,7 +445,7 @@ def __init__(self, directory=None, timeout=60, disk=Disk, **settings): | |
|
|
||
| if not op.isdir(directory): | ||
| try: | ||
| os.makedirs(directory, 0o755) | ||
| os.makedirs(directory, 0o700) | ||
| except OSError as error: | ||
| if error.errno != errno.EEXIST: | ||
| raise EnvironmentError( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes
diskcache.Disknot importable. For example: