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.5

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.5
File Size Uploaded Provenance Actions
fileaudit-0.2.5.tar.gz 10.9 MB Without provenance Details for fileaudit-0.2.5.tar.gz

Built distribution (wheel)

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

Total release size: 10.9 MB

Release files / fileaudit-0.2.5.tar.gz

Download URL fileaudit-0.2.5.tar.gz
Size 10.9 MB
Tags Source
SHA-256 checksum
How to use checksums
b074a4d3f9ebc416ce9fd71973cad83295c52eeb5b6f6893cf4ab5a8d8ae1691
BLAKE2b-256 checksum
How to use checksums
b274b33c42fc3c874c54bcdfa7f4c5b0ff1f1ec9362f81d5d7810cf50b1380f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.2 {"ci":null,"cpu":"x86_64","distro":{"id":"resolute","libc":{"lib":"glibc","version":"2.43"},"name":"Ubuntu","version":"26.04"},"implementation":{"name":"CPython","version":"3.15.2"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 3.5.9 29 Sep 2026","python":"3.15.2","system":{"name":"Linux","release":"7.0.0-42-generic"}} HTTPX2/2.16.0

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

Download URL fileaudit-0.2.5-py3-none-any.whl
Size 55.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d260872517163903a6640ac7c00b9b096f618c12a6bb329409aebef74c79680a
BLAKE2b-256 checksum
How to use checksums
cff27035ec02bb0a6d6e61ebff09593d44564a371544d6cd43b93068f9d8cf28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.2 {"ci":null,"cpu":"x86_64","distro":{"id":"resolute","libc":{"lib":"glibc","version":"2.43"},"name":"Ubuntu","version":"26.04"},"implementation":{"name":"CPython","version":"3.15.2"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 3.5.9 29 Sep 2026","python":"3.15.2","system":{"name":"Linux","release":"7.0.0-42-generic"}} HTTPX2/2.16.0

Security for fileaudit 0.2.5

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.

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