Tarsafe is a Python library that provides a safe subclass of the standard library's `tarfile.TarFile` class, primarily addressing a known security vulnerability in the `extractall()` method. It serves as a direct drop-in replacement to safely interact with tar archives. The current version is 0.0.5, and its release cadence appears sporadic, reflecting its nature as a security-focused enhancement.
pip install tarsafeVerified import paths — ran on the pinned version, not inferred.
Initialize a `TarSafe` object with your tar file and use `extractall()` as a direct, secure replacement for the standard library's method.
Replace `tarfile.open` with `tarsafe.TarSafe.open` and ensure `extractall()` is called on the `TarSafe` object. Python 3.11+ users can also use `tarfile.open(..., filter='data')`.
Ensure your tar archives are correctly formed and do not rely on implicit directory traversal for file placement. Review the contents of untrusted archives before extraction.
Replace `from tarfile import open` with `from tarsafe import TarSafe as open` or explicitly use `tarsafe.TarSafe.open()` for secure extraction.
Run `pip install tarsafe` to install the library.
Inspect the paths within your tar archive. Ensure all paths are relative to the archive's root and do not contain `..` or absolute path indicators. Re-create archives with clean paths if necessary.
No dependency data recorded yet.