Skip to content

v5.8.3

Choose a tag to compare

@github-actions github-actions released this 03 Nov 18:04
· 8 commits to master since this release
ac57330

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_types refuses the classes of scipy, torch, bitstruct and pyahocorasick, by class, by module name and through DISKCACHE_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.get works again in subclasses that override _con to 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 to cache.db, so every read raised OperationalError: no such table: Cache (PR #42).
  • SafeDisk stores the classes in its allowlist, such as int and str, so memoize(typed=True) works with it (PR #42).
  • SafeDisk.with_numpy() stores datetime64 and timedelta64 arrays, which raised ValueError from pickle.PickleBuffer (PR #42).
  • Every SafeDisk checks a key or value outside the standard-library types against the names its pickle looks up, as the disks from with_types already did. A plain SafeDisk therefore stores a dict subclass that pickles as a dict, such as DRF's ReturnDict, and reads back a dict (PR #42).
  • Refusal messages say what to do: a refused function no longer points to with_types(), which allows only classes; numpy objects point to with_numpy(); an array of objects mentions pandas DataFrames and what to store instead; and a class from a package with_types refuses says so (PR #42).
  • incr and decr on Cache and FanoutCache type-check with default=None, which makes a missing key raise KeyError: the stubs typed default as int, so type checkers rejected the call. tox -e mypy now also checks tests/typecheck_stubs.py, a file of calls that must type-check against the stubs (PR #41).
  • The modules argument of SafeDisk.with_types type-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 JSONDisk does not protect reads, because it reads each row as its mode column says, and point to SafeJSONDisk. The migration guide explains that Dash's DiskcacheManager takes 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 default Disk (PR #42).