Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DiskCacheopens its index with diskcache's defaultDisk(cache.pyL170-L173), so a pickled entry goes throughpickle.loadwhoever wrote it: ingeton every cachedexecute()(L191-L200, fromquery.pyL282), input(L211) and ininvalidate(L229-L232). CVE-2025-69872 (GHSA-w8v5-vhqr-4h9v) covers diskcache through 5.6.3, its last release, from 2023. This moves thecacheextra to diskcache-community, a maintained, faster fork that keeps diskcache's license, API and on-disk format, and reads the index through itsSafeDisk, so a planted entry is dropped and the query goes back to Iceberg.Fixes #1
Changes
cacheextra asks fordiskcache-community>=5.8.4instead ofdiskcache>=5.6.0, and thedevextra gains it so CI runs the new test. TheImportErrornames the new package.SafeDisk.with_options(on_error="miss"). Its entries are dicts of strings, floats andNone, so entries written by 0.14.0 read back unchanged.tests/test_disk_cache.pyoverwrites the index entry with a pickle through a plainDiskwriter, then checks that the read is a miss and the pickle's function never ran.Before and after
The script builds a local SQLite catalog with a
file://warehouse, installs aDiskCacheand counts Iceberg scans. The planted pickle runsplanted()from the script, which prints a line and points the entry at a one-row parquet file it writes.On iceframe 0.14.0 with diskcache 5.6.3:
With this change:
Script
Testing
On macOS with Python 3.12:
pytest tests/test_disk_cache.py: the new test passes.ruff checkandruff format --checkon the changed files (ruff 0.17.3): clean.mypyas configured: nothing incache.py; its one error is the existingquery.py:308hint.Update
Every day new libraries getting updated, as example several libraries that were updated yesterday lithops and octotools.
improved performance
Measured over 20 rounds per build, each build in its own venv in random order, medians vs PyPI diskcache 5.6.3 — classic mix (100,000 ops/round, 90% gets / 9% sets / 1% deletes) plus size tiers (100 B to 1 MB) and Django backends, millions of ops total.
Cache.gethitCache.getmissDjangoCache.gethitCache.setCache.setwith expire / Django setP.S I created this pacakge myself after running into this issue, and I'm the one maintaining it.