Skip to content

[DE-7720] Bump minimum Python to 3.10 and patch all dependency CVEs#458

Open
edwinpav wants to merge 19 commits intomasterfrom
edwinpav/de-7720-resolve-trivy-vulns
Open

[DE-7720] Bump minimum Python to 3.10 and patch all dependency CVEs#458
edwinpav wants to merge 19 commits intomasterfrom
edwinpav/de-7720-resolve-trivy-vulns

Conversation

@edwinpav
Copy link
Copy Markdown
Contributor

@edwinpav edwinpav commented Apr 29, 2026

Summary

Bumps the minimum supported Python version from 3.7 to 3.10 (now supports 3.10–3.14) so we can adopt patched versions of our locked dependencies. The patched releases of aiohttp, urllib3, requests, Pillow, numpy, setuptools, and others now require Python ≥ 3.10, so we couldn't pull them in while still supporting 3.7–3.9.

This is the headline reason for the bump: it unblocks the dependency upgrades that resolve all current Trivy findings for this repo.

Why

Local Trivy scan before this PR: 48 vulnerabilities (1 CRITICAL, 11 HIGH, 22 MEDIUM, 14 LOW), including:

(See https://linear.app/scale-epd/issue/DE-7720 for file of all vulns)

  • Pillow CVE-2023-50447 (CRITICAL — RCE)
  • aiohttp CVE-2024-23334 (HIGH — path traversal) and a long tail of HTTP-smuggling/DoS CVEs
  • urllib3 CVE-2025-66418 (HIGH — decompression DoS)
  • setuptools CVE-2024-6345 (HIGH — RCE)
  • plus issues in requests, numpy, idna, certifi, marshmallow, pygments, tqdm, zipp, scikit-learn

Local Trivy scan after this PR: 0 vulnerabilities. See .trivy/fs.txt for the clean run (.trivy/fs-strict.txt shows the original findings).

Python 3.7, 3.8, and 3.9 are all past upstream end-of-life (2023-06-27, 2024-10-07, and 2025-10-31 respectively) and no longer receive security patches even from CPython itself.

What's in this PR

  • Drop Python 3.7/3.8/3.9 support. pyproject.toml now requires python = ">=3.10,<4.0".
  • Refresh locked dependencies to versions that resolve the Trivy findings (regenerated poetry.lock).
  • Expand CI installation matrix from [3.10, 3.11] to [3.10, 3.11, 3.12, 3.13, 3.14] so every supported Python version is exercised on every PR. The matrix builds the sdist, installs it (no extras, [metrics], [launch], and [metrics, launch]), and smoke-tests import nucleus on each Python version.
  • Fix pytest 9 collection errors. pytest 9 turns @pytest.mark.* decorators on fixtures into hard errors. Removed/converted no-op fixture marks across tests/cli/conftest.py, tests/validate/conftest.py, tests/test_scene.py, and tests/test_video_scene.py.
  • NumPy 2.x compatibility. Replaced np.float_ and np.float (both removed in modern NumPy) with np.float64 in nucleus/metrics/segmentation_utils.py and nucleus/metrics/segmentation_metrics.py.
  • Lint cleanup to keep CI green on the new dependency versions: pylint findings (E0606, W3101, R1737, R1728, C3001, C3002, W0719), pylint disables updated (+R0913, -R0201), black re-applied. One exception was made more specific.
  • Mypy clean. poetry run mypy --ignore-missing-imports nucleus now reports Success: no issues found in 76 source files. Notable user-visible adjustments:
    • DatasetItem.reference_id is now typed Optional[str] (still required at runtime via __post_init__ assertion); the internal "DUMMY_VALUE" sentinel is gone.
    • nucleus/async_utils.py wraps timeouts in aiohttp.ClientTimeout(total=...).
    • NucleusClient.list_autotags always returns a list regardless of response shape.
  • Release 0.18.0 with a CHANGELOG entry.

Impact / risk

  • Anyone still on Python 3.7/3.8/3.9 will see pip install scale-nucleus==0.18.0 fail with a clear version-requirement error (no silent breakage).
  • All other changes are either internal lint/typing cleanup or backwards-compatible. The one observable Python-side change is DatasetItem.reference_id's type — the previous docstring already declared it Optional[str], so this aligns the type with the documented contract.

Verification

  • make scan — 0 Trivy findings (.trivy/fs.txt).
  • poetry run mypy --ignore-missing-imports nucleusSuccess: no issues found in 76 source files.
  • poetry run ruff . / poetry run pylint nucleus / poetry run isort --check-only . — clean.
  • poetry run pytest --collect-only tests/ — collects cleanly under pytest 9 with no fixture-mark errors.
  • CircleCI installation matrix runs against Python 3.10, 3.11, 3.12, 3.13, and 3.14.

Linear

DE-7720

Greptile Summary

This PR bumps the minimum Python version from 3.7 to 3.10 and refreshes all locked dependencies to resolve 48 Trivy CVEs (including a critical Pillow RCE and high-severity aiohttp/urllib3/setuptools findings). Alongside the version bump, it fixes NumPy 2.x compatibility (np.float_np.float64), wraps aiohttp timeouts in ClientTimeout, resolves pytest 9 fixture-mark collection errors, and applies mypy/pylint/black cleanup throughout.

Confidence Score: 5/5

Safe to merge — all changes are correct compatibility and security fixes with no functional regressions.

No P0 or P1 issues found. All changes are either formatting-only, legitimate security/compatibility upgrades, or well-understood type-annotation corrections. The aiohttp timeout fix, NumPy dtype replacements, pytest 9 fixture adjustments, and cuboid_utils NameError pre-init are all correct. CI matrix expansion exercises 3.10–3.14. Trivy reports 0 findings post-merge.

No files require special attention.

Important Files Changed

Filename Overview
pyproject.toml Python constraint bumped to >=3.10, version to 0.18.0, and all security-relevant deps updated (aiohttp ^3.10, requests ^2.32, Pillow >=12.2.0,<13, boto3 ^1.42, numpy >=1.22.0).
nucleus/async_utils.py Fixes aiohttp timeout by wrapping scalar with aiohttp.ClientTimeout(total=…), and de-duplicates getattr call for api_key before each request — correct and clean.
nucleus/dataset_item.py reference_id sentinel DUMMY_VALUE replaced with Optional[str] = None; post_init assertion updated accordingly; Exception → ValueError for privacy-mode check.
nucleus/metrics/segmentation_utils.py np.float / np.float_ replaced with np.float64 for NumPy 2.x compatibility; shape[1] → shape[-1] (equivalent for 2-D arrays); setup_iou_thresholds updated similarly.
nucleus/metrics/cuboid_utils.py Pre-initialises distance_mask to an all-False array so the variable is always defined even when both input corner arrays are empty, preventing a NameError.
nucleus/init.py list_autotags now always returns a list; Exception → RuntimeError in two places; minor formatting and API-key logic simplification.
nucleus/annotation.py Segment.index made Optional[int] = None to match real JSON payloads (mypy fix); Exception → ValueError/FileNotFoundError; type_key default changed from None to empty string (both fall through to SegmentationAnnotation).
nucleus/dataset.py Multiple Exception → ValueError promotions, items default changed from None to [] to avoid None iteration, yield from refactors, and formatting cleanup.
.circleci/config.yml CI matrix updated from [3.7–3.11] to [3.10–3.14]; Docker images bumped to python:3.10-bullseye and cimg/python:3.10.
tests/validate/conftest.py @pytest.mark.usefixtures on fixture replaced with explicit annotations parameter to fix pytest 9 collection errors; intent preserved via comment.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Python >=3.10 requirement] --> B[Unlocks patched deps]
    B --> C1[aiohttp ^3.10 - path-traversal CVEs fixed]
    B --> C2[Pillow >=12.2.0 - RCE CVE-2023-50447 fixed]
    B --> C3[urllib3/requests/numpy - security patches]
    B --> C4[setuptools/boto3 - RCE / other CVEs fixed]
    A --> D[Code compatibility fixes]
    D --> D1[NumPy 2.x - np.float_ to np.float64]
    D --> D2[aiohttp ClientTimeout - wrap scalar timeout]
    D --> D3[pytest 9 - remove marks on fixtures]
    D --> D4[mypy/pylint/black - type and style cleanup]
Loading

Reviews (2): Last reviewed commit: "Update CHANGELOG.md to include recent co..." | Re-trigger Greptile

@edwinpav edwinpav self-assigned this Apr 29, 2026
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 29, 2026

@edwinpav edwinpav marked this pull request as ready for review April 29, 2026 21:19
@edwinpav edwinpav requested review from a team and vinay553 April 29, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant