Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI

on:
push:

env:
BASE_VERSION: '6.0.0'

jobs:
checks:
runs-on: ubuntu-latest
strategy:
max-parallel: 8
matrix:
check: [bluecheck, doc8, docs, flake8, isortcheck, mypy, pylint, rstcheck]

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install tox
run: pip install tox
- name: Run checks
run: tox -e ${{ matrix.check }}

tests:
needs: checks
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e py

publish:
needs: tests
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4

- name: Establish Versioning, Tags, and Labels
id: vtl
uses: mapped/action-vtl@latest
with:
baseVersion: ${{ env.BASE_VERSION }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Update package version
run: |
sed -i "s/__version__ = '.*'/__version__ = '${{ steps.vtl.outputs.ver_semVerNoMeta }}'/" diskcache/__init__.py

- name: Build package
run: |
pip install build
python -m build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
52 changes: 0 additions & 52 deletions .github/workflows/integration.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/release.yml

This file was deleted.

6 changes: 4 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ source-roots=

# When enabled, pylint would attempt to guess common misconfiguration and emit
# user-friendly hints instead of false-positive error messages.
suggestion-mode=yes
# suggestion-mode removed (pylint 4.x dropped this option)

# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
Expand Down Expand Up @@ -433,7 +433,9 @@ disable=raw-checker-failed,
no-member,
no-else-return,
no-else-raise,
inconsistent-return-statements
inconsistent-return-statements,
too-many-lines,
too-many-positional-arguments

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
52 changes: 52 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Changes
=======

6.0.0 (NEXT)
-------------

**Breaking Changes**

* Pickle deserialization is now restricted to safe built-in types only.
This mitigates CVE-2025-69872, which allowed arbitrary code execution
when an attacker with write access to the cache directory injected a
crafted pickle payload.

The following types are permitted during deserialization:

- Python builtins: ``int``, ``float``, ``str``, ``bytes``, ``bytearray``,
``list``, ``dict``, ``tuple``, ``set``, ``frozenset``, ``complex``,
``range``, ``slice``, ``object``, ``bool``, ``None``
- ``collections``: ``OrderedDict``, ``defaultdict``, ``deque``
- ``datetime``: ``date``, ``datetime``, ``time``, ``timedelta``,
``timezone``
- ``decimal.Decimal``
- ``fractions.Fraction``
- ``uuid.UUID``

All other types will raise ``UnpicklingError`` on read.

* There is no opt-out mechanism. Users who need to cache custom types have
two migration paths:

1. Use ``JSONDisk`` for JSON-serializable data::

cache = Cache('/tmp/my-cache', disk=JSONDisk)

2. Subclass ``Disk`` and override ``get()`` and ``fetch()`` with a custom
serialization strategy appropriate for your data.

**New Features**

* Added ``SafeUnpickler`` class for restricted pickle deserialization.
* Added ``UnpicklingError`` exception raised when a disallowed type is
encountered during deserialization.

**Internal**

* ``SAFE_PICKLE_CLASSES`` uses ``frozenset`` values to prevent runtime
modification.

5.6.3 (2023-08-31)
-------------------

* Previous release (see git history for details).
10 changes: 7 additions & 3 deletions diskcache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
Disk,
EmptyDirWarning,
JSONDisk,
SafeUnpickler,
Timeout,
UnknownFileWarning,
UnpicklingError,
)
from .fanout import FanoutCache
from .persistent import Deque, Index
Expand Down Expand Up @@ -44,9 +46,11 @@
'JSONDisk',
'Lock',
'RLock',
'SafeUnpickler',
'Timeout',
'UNKNOWN',
'UnknownFileWarning',
'UnpicklingError',
'barrier',
'memoize_stampede',
'throttle',
Expand All @@ -60,9 +64,9 @@
# Django not installed or not setup so ignore.
pass

__title__ = 'diskcache'
__version__ = '5.6.3'
__build__ = 0x050603
__title__ = 'mapped-diskcache'
__version__ = '6.0.0'
__build__ = 0x060000
__author__ = 'Grant Jenks'
__license__ = 'Apache 2.0'
__copyright__ = 'Copyright 2016-2023 Grant Jenks'
Loading
Loading