Skip to main content

pypi-version-bisect

Binary-search a PyPI package's release history to pin down exactly which versions a vulnerability affects — the first-affected release, the last-affected release, and the version that fixed it — using O(log n) tests instead of installing every version.

You supply an oracle (check_fn(version) -> bool) that decides whether a given release is vulnerable. This library handles fetching the release timeline from PyPI (in chronological upload order) and driving an efficient bisection over it.

Install

pip install pypi-version-bisect

Library usage

from pypi_version_bisect import find_affected_range, format_version_range

def check_fn(version: str) -> bool:
    # Install the version in a sandbox and probe for the vulnerability.
    # Return True if vulnerable, False if clean.
    ...

result = find_affected_range("pyyaml", check_fn)
print(result["first_affected"])   # e.g. "3.1"
print(result["last_affected"])    # e.g. "5.3.1"
print(result["fixed_in"])         # e.g. "5.4"
print(format_version_range(result))  # ">=3.1,<5.4"

find_affected_range returns a dict with package, all_versions, first_affected, last_affected, fixed_in, and checked_count. If nothing could be determined it also includes an error key.

Tuning knobs:

  • delay (default 0.5) — seconds between oracle calls, to be kind to install infrastructure.
  • max_checks (default 40) — hard cap on oracle calls. Binary search is logarithmic, so 40 covers thousands of releases.

CLI

List releases in upload order:

pypi-version-bisect list requests

Bisect using an external command as the oracle (exit code 0 = vulnerable):

pypi-version-bisect range examplepkg \
  --check-cmd "python probe.py examplepkg=={version}" \
  --delay 1.0

Notes

  • Only depends on requests.
  • Network failures are non-fatal: fetching returns an empty list and the run reports a clear error rather than raising.
  • Versions are ordered by earliest file upload time, which matches release chronology better than string sorting for pre-releases and hotfixes.

License

MIT

Metadata

Release files for pypi-version-bisect 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypi-version-bisect 0.1.0
File Size Uploaded Provenance Actions
pypi_version_bisect-0.1.0.tar.gz 6.5 kB Without provenance Details for pypi_version_bisect-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pypi-version-bisect 0.1.0
File Interpreter ABI Platform Actions
pypi_version_bisect-0.1.0-py3-none-any.whl Python 3 none any Details for pypi_version_bisect-0.1.0-py3-none-any.whl

Total release size: 14.9 kB

Release files / pypi_version_bisect-0.1.0.tar.gz

Download URL pypi_version_bisect-0.1.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fd564419558f67927e451ad8bac780df3deb5fe2f74ee2ed58b60673a01fe8a4
BLAKE2b-256 checksum
How to use checksums
edfb4f5b3505e47c9c3976259de453999301c596325530de257e096ecfbb783d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release files / pypi_version_bisect-0.1.0-py3-none-any.whl

Download URL pypi_version_bisect-0.1.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffc7b08f9d68bb570c99f97610db40ce2ef8ce79b71e072974dd3170d82cd0e3
BLAKE2b-256 checksum
How to use checksums
b9c5ce44778fbb527cc646b5e3d738a516a9523203bdbd2502122b2841156927
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Security for pypi-version-bisect 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page