Skip to content

Harden archive scanning, add loads(), migrate packaging to uv, and add tests - #50

Open
vijaypanchal wants to merge 5 commits into
google:mainfrom
vijaypanchal:main
Open

vijaypanchal wants to merge 5 commits into
google:mainfrom
vijaypanchal:main

Conversation

@vijaypanchal

Copy link
Copy Markdown

Summary

Harden SaferPickle's handling of untrusted archives, add the missing
loads() API, migrate packaging to uv, and introduce a test suite.

Changes

Security hardening

  • Add archive-slip (path-traversal) detection for archive member names.
  • Propagate check_magic_bytes into nested bz2/lzma/gzip streams so inner
    payloads are scanned, not just the outer container.
  • Treat unsupported archive types as unsafe (previously they could fall
    through to safe).

New API

  • Add saferpickle.loads() as the string-based counterpart to load()
    (this was already documented in the README but missing from the module).

CLI

  • Scan all members of a zip archive (previously only the first member
    was inspected).
  • Broaden exception handling so the CLI never crashes on malformed input.
  • Add a run() entry point and wire it to the safer_pickle_cli console
    script.

Packaging

  • Migrate from setup.py/requirements.txt to pyproject.toml +
    uv.lock.
  • Add lib/__init__.py and third_party/__init__.py package markers.
  • Configure black, isort, and pytest in pyproject.toml.

Tests

  • Add a test suite (conftest.py, test_saferpickle.py, test_load.py,
    test_cli.py) — 22 tests pass.

Docs

  • Fix the incorrect import name in README.md.

Notes

  • First-party code was reformatted with black/isort; vendored
    third_party/ files are excluded and untouched.
  • Verified: pytest -q → 22 passed; uv build succeeds.

Vijay Panchal and others added 5 commits August 26, 2026 00:27
- Replace requirements.txt and setup.py with Poetry configuration
- Rename safer_pickle to saferpickle in README and code
- Update CLI dependencies and type imports
Update all imports from safer_pickle to saferpickle for consistent naming.
Replace absl-based CLI with click and add new dependencies (click, colorama).
@google-cla

google-cla Bot commented Aug 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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