Repository navigation
v5.8.3
Fixes a regression from 5.8.2 and several SafeDisk issues found by testing downstream libraries, and updates the documentation. The cache.db schema and the file layout are unchanged.
Security
SafeDisk.with_typesrefuses the classes of scipy, torch, bitstruct and pyahocorasick, by class, by module name and throughDISKCACHE_SAFE_MODULES, as it refuses numpy, so a crafted scipy sparse matrix, pyahocorasick automaton or bitstruct compiled format cannot crash the reader and torch objects cannot run code through the cache (PR #42).
Fixes
Cache.getworks again in subclasses that override_conto keep their rows in another database file, as subclasses written for 5.6.3 do. Since 5.8.2 its fast path took its cursor from a connection tocache.db, so every read raisedOperationalError: no such table: Cache(PR #42).SafeDiskstores the classes in its allowlist, such asintandstr, somemoize(typed=True)works with it (PR #42).SafeDisk.with_numpy()storesdatetime64andtimedelta64arrays, which raisedValueErrorfrompickle.PickleBuffer(PR #42).- Every
SafeDiskchecks a key or value outside the standard-library types against the names its pickle looks up, as the disks fromwith_typesalready did. A plainSafeDisktherefore stores a dict subclass that pickles as adict, such as DRF'sReturnDict, and reads back adict(PR #42). - Refusal messages say what to do: a refused function no longer points to
with_types(), which allows only classes; numpy objects point towith_numpy(); an array of objects mentions pandas DataFrames and what to store instead; and a class from a packagewith_typesrefuses says so (PR #42). incranddecronCacheandFanoutCachetype-check withdefault=None, which makes a missing key raiseKeyError: the stubs typeddefaultasint, so type checkers rejected the call.tox -e mypynow also checkstests/typecheck_stubs.py, a file of calls that must type-check against the stubs (PR #41).- The
modulesargument ofSafeDisk.with_typestype-checks with a single string or any iterable of strings, as the code accepts (PR #42).
Docs
- The CVE page and the migration guide say up front that
JSONDiskdoes not protect reads, because it reads each row as itsmodecolumn says, and point toSafeJSONDisk. The migration guide explains that Dash'sDiskcacheManagertakes only an upstream cache and keeps its signing secret there, so its folder should be its own (PR #42). - The tutorial no longer says that
memoize(typed=True)needs the defaultDisk(PR #42).