Skip to main content

Safe path handling for VCollab applications

Project description

Path Utilities

Purpose

Safe path handling for VCollab applications -- filename validation, file identity (POSIX-style relative paths as stable IDs), and path resolution with access validation.

This package has zero external dependencies.


Installation

pip install vcti-path

In requirements.txt

vcti-path>=1.0.3

In pyproject.toml dependencies

dependencies = [
    "vcti-path>=1.0.3",
]

Quick Start

Validate filenames

from vcti.path import FileNameValidator

FileNameValidator.is_valid("report.pdf")     # True
FileNameValidator.is_valid("bad|name")       # False
FileNameValidator.is_valid("..")             # False

FileNameValidator.validate("data.json")      # OK
FileNameValidator.validate("bad/name")       # Raises ValueError

File IDs -- stable POSIX-style identifiers

A file ID is a POSIX-format relative path that uniquely identifies a file or directory within a base directory. No leading /, ./, or ../.

from pathlib import Path
from vcti.path import FileId

# Validate
FileId.is_valid("scripts/setup.sh")     # True
FileId.is_valid("/absolute/path")       # False
FileId.is_valid("../escape")            # False

# Resolve to filesystem path
base = Path("/project")
FileId.resolve_path("src/main.py", base)
# -> Path("/project/src/main.py")

# Extract file ID from a path
src = Path("/project/src/main.py")
FileId.get_file_id(src, base)
# -> "src/main.py"

Path resolution and access validation

from vcti.path import abs_path, validate_file_access, resolve_path

# Absolute path resolution
abs_path("relative/file.txt")
# -> Path("<cwd>/relative/file.txt")

# Validate that a file exists and is readable
validate_file_access("config.yaml")
# Raises FileNotFoundError, IsADirectoryError, or PermissionError

# Resolve relative to a base directory
resolve_path("data/input.csv", "/project")
# -> Path("/project/data/input.csv")

Public API

Symbol Type Purpose
FileNameValidator.is_valid(name) classmethod Check if a filename is valid
FileNameValidator.validate(name) classmethod Validate filename, raise ValueError if invalid
FileId.is_valid(file_id) staticmethod Check if a POSIX file ID is valid
FileId.validate(file_id) staticmethod Validate file ID, raise ValueError if invalid
FileId.resolve_path(file_id, base_dir) staticmethod Resolve file ID to absolute path
FileId.get_file_id(file_path, base_dir) staticmethod Extract file ID from absolute path
abs_path(fp) function Convert to absolute resolved Path
validate_file_access(fp) function Validate file exists and is readable
validate_folder_access(fp) function Validate directory exists
resolve_path(path, base_dir) function Resolve path relative to base directory

Documentation

  • Design -- Concepts, architecture decisions, and rationale
  • Source Guide -- File descriptions and execution flow traces
  • API Reference -- Autodoc for all modules

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcti_path-1.0.3.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcti_path-1.0.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file vcti_path-1.0.3.tar.gz.

File metadata

  • Download URL: vcti_path-1.0.3.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vcti_path-1.0.3.tar.gz
Algorithm Hash digest
SHA256 d02e21d8c46a39d39b6991d5e524e1438afc7e78e19a78ed948d41505f08539d
MD5 5fb9eca4655d0b474cb48a19de8b1aad
BLAKE2b-256 f3891192c466430be14e5cd76ae60dceda5003e907584a190c5857cc50046713

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_path-1.0.3.tar.gz:

Publisher: publish.yml on vcollab/vcti-python-path

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vcti_path-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: vcti_path-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vcti_path-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 46c893437042fb613cc7bfb91cbd331dcb887e97b091e7ad8e0c33f6b92d41a4
MD5 e4084ce7334b61086c49b92a7a17a65e
BLAKE2b-256 33fe51f2cf929f5386d6cda1b2e4791c0d517a056cb8de7c277e3c193e6a1009

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_path-1.0.3-py3-none-any.whl:

Publisher: publish.yml on vcollab/vcti-python-path

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page