Skip to main content

Python File Audit

PythonCodeAudit Badge OpenSSF Best Practices PyPI - Version Documentation License

fileaudit_logo

File Audit – Simplify Python Security by adding one line! Build secure Python applications by default. Validate files before you use them.

A robust file-validation library designed to protect your Python applications and scripts against untrusted or malicious files.

Safety Checks

  • File size limit – Prevents oversized files from being processed
  • GZip decompression ratio – Guards against decompression bombs
  • Tar member count – Limits the number of entries inside tar archives
  • Total extracted size – Caps the overall size of extracted content
  • Individual file size – Enforces a maximum size per extracted file
  • Path traversal protection – Blocks ../ and absolute path tricks
  • Reject symlinks – Disallows symbolic links
  • Reject hardlinks – Disallows hard links
  • Reject device files – Blocks device nodes
  • Reject FIFOs – Blocks named pipes
  • Filename length – Enforces a maximum filename length
  • Directory depth – Limits how deeply nested directories can be

These checks can be used via a simple API or by adding a decorator — without changing your existing code.

Installation

pip install fileaudit

Usage

API / Decorator (CSV example)

Validate a local CSV file:

validate_csv("data.csv")

Validate a CSV file from a URL:

validate_csv("https://example.com/data.csv")

Use as a decorator (first function argument is treated as the CSV path):

@validate_csv
def process_csv(csv_path):
    ...

Use as a decorator with default validation options:

@validate_csv()
def process_csv(csv_path):
    ...

Specify the decorated function argument that contains the CSV path:

@validate_csv("input_file")
def process_csv(input_file):
    ...

Configure validation limits:

@validate_csv(
    max_file_size=10 * 1024 * 1024,
    max_rows=10_000,
    max_columns=50,
)
def process_csv(csv_path):
    ...

CLI

You can also inspect a file directly from the command line:

fileaudit path/to/file

Supported File Types

File types are auto-detected from the extension:

Extension Description
csv CSV files
gz GZIP files
json JSON files
py Python source files
tar TAR archives
tar-gz TAR.GZ archives
tgz TAR.GZ archives
xml XML files
zip ZIP archives

Python File Audit helps you validate files before they reach your application logic, reducing the risk of common file-based attacks.

Contributing

All contributions are welcome! Think of corrections on the documentation, code or more and better tests.

Simple Guidelines:

  • Questions, Feature Requests, Bug Reports please use on the Github Issue Tracker.

Pull Requests are welcome!

When you contribute to FileAudit, your contributions are made under the same license as the file you are working on.

We adopt the Collective Code Construction Contract(C4) to streamline collaboration.

License

fileaudit is distributed under the terms of the Mozilla Public License 2.0 license.

Metadata

Release files for fileaudit 0.2.6

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

Source distribution (sdist)

Source distribution for fileaudit 0.2.6
File Size Uploaded Provenance Actions
fileaudit-0.2.6.tar.gz 10.8 MB With provenance Details for fileaudit-0.2.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fileaudit 0.2.6
File Interpreter ABI Platform Actions
fileaudit-0.2.6-py3-none-any.whl Python 3 none any Details for fileaudit-0.2.6-py3-none-any.whl

Total release size: 10.8 MB

Release files / fileaudit-0.2.6.tar.gz

Download URL fileaudit-0.2.6.tar.gz
Size 10.8 MB
Tags Source
SHA-256 checksum
How to use checksums
8f503e63a557a4d8f5b3330e4ea31b0d4e84c3bce17dae055811bc390c024791
BLAKE2b-256 checksum
How to use checksums
a3eab2ae489c9ce3b1e9ae4f9e8ef1804baca6a102b1283092d1a8a9510a62c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / fileaudit-0.2.6-py3-none-any.whl

Download URL fileaudit-0.2.6-py3-none-any.whl
Size 55.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04563b126fd06de3bf4f3fcea94147ccb714d066015da6ed8d8ba5f6374e8730
BLAKE2b-256 checksum
How to use checksums
81880b1252d2207cfa20152adabd5b5df81dbbbea0e2c7f944da6c928bbacdea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for fileaudit 0.2.6

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fileaudit-0.2.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

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.

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