Auditable text-only preparation and restoration for controlled file transfers
Project description
Controlled Text Transfer 0.2.0
Controlled Text Transfer (ctt) is a security-oriented CLI tool and Python library for transferring files across strict security boundaries—such as Cross-Domain Solutions (CDS), air-gapped networks, or restricted file transfer drops—that only permit plain text (.txt) files.
ctt validates source files against explicit compliance policies, packages allowed files into a .txt-only transfer format (preserving full original paths and metadata in a signed-ready JSON manifest), and restores exact byte-identical originals at the destination.
Python 3.12 or newer is required.
Core Transfer Workflow
[ Source Directory ]
│
▼
1. preflight ──────► Audit source directory files against compliance policy (Read-only)
│
▼
2. prepare ────────► Package allowlisted files into .txt transfer directory or archive
│
[ CDS / Restricted Boundary Transfer ]
│
▼
3. verify ─────────► Check package directory/archive integrity, hashes & signatures
│
▼
4. restore ────────► Recreate original files byte-for-byte in destination directory
preflight: Inspects a directory to test files against policy rules without making changes.prepare: Converts approved files to.txttransfer copies, adds transport BOMs where configured, generatesctt-manifest.json.txt, and publishes a signed-ready bundle.verify: Validates manifest hashes, path boundaries, package structure, and optional digital signatures before unpacking.restore: Strips.txttransfer extensions and BOMs, recreating exact original files atomically at the destination.
Quick Start
Install official releases directly from PyPI (controlled-text-transfer):
pip install controlled-text-transfer
Run the core 4-step workflow using zero-configuration defaults:
# 1. Inspect source directory against policy (prints concise summary)
ctt preflight ./source_dir
# 2. Package allowlisted files into a transfer directory
ctt prepare ./source_dir ./transfer_dir
# 3. Verify transfer package directory (or archive)
ctt verify ./transfer_dir
# 4. Restore original files into a new destination directory
ctt restore ./transfer_dir ./restored_dir
Path Roles & Optional Flags:
- Directory Arguments:
./source_diris the input folder containing files;./transfer_diris the output transfer folder (or archive path);./restored_diris the new output folder where original files are recreated.- Zero Required Flags:
cttworks out of the box with zero flags using built-in safe defaults (generic-text-v1profile, common text allowlists, SHA-256).--json(preflight): Optional flag to output complete machine-readable JSON details instead of a summary text report.--strict(prepare): Optional flag to fail closed and create nothing if any single candidate file is rejected.--policy PATH: Optional flag to load custom YAML rules (e.g.ctt.yaml) instead of built-in defaults.
For detailed quickstart guidance, see README-quickstart.md.
Command Reference
The ctt CLI cleanly separates end-user transfer operations from developer maintenance tools.
Primary Transfer Commands
| Command | Purpose | Default Usage | Expressive Usage with Options |
|---|---|---|---|
preflight |
Produce a read-only policy compatibility report | ctt preflight ./source_dir |
ctt preflight ./source_dir --policy ctt.yaml --json |
prepare |
Package allowlisted files into .txt transfer format |
ctt prepare ./source_dir ./transfer_dir |
ctt prepare ./source_dir ./dist/pkg.zip --policy ctt.yaml --strict --json-report report.json --log-json |
verify |
Verify package integrity, manifest, and signatures | ctt verify ./transfer_dir |
ctt verify ./transfer.zip --require-signature --log-json |
restore |
Restore original byte-identical files | ctt restore ./transfer_dir ./restored_dir |
ctt restore ./transfer.zip ./restored_dir --dry-run --log-json |
Secondary Utility Commands
| Command | Purpose | Default Usage | Expressive Usage with Options |
|---|---|---|---|
diff |
Compare transfer package against source directory | ctt diff ./transfer_dir ./source_dir |
ctt diff ./transfer.zip ./source_dir --policy ctt.yaml --json |
self-package |
Package CTT itself into a .txt-only self-bootstrapping bundle |
ctt self-package ./ctt-bootstrap.zip |
ctt self-package ./dist/ctt-bootstrap.tgz --source . --format tgz |
Practical Command Examples
Here are common operational scenarios showing how to combine additional CLI options:
1. Pre-Transfer Audit and Reporting
Evaluate a source directory before transfer:
# Summary stdout report using built-in policy defaults
ctt preflight ./source_dir
# Machine-readable JSON preflight report using custom policy
ctt preflight ./source_dir --policy ctt.yaml --json > preflight-audit.json
2. Strict Packaging with Manifest Audit & Audit Logging
Enforce strict validation (fail if any candidate file is rejected), save a preflight report, and output a JSON audit event to stderr:
# Package into a ZIP archive with strict policy enforcement and audit outputs
ctt prepare ./source_dir ./dist/transfer.zip \
--policy ctt.yaml \
--strict \
--json-report ./preflight.json \
--log-json
3. Signature Verification & Dry-Run Restoration
Verify digital signatures and test restoration without writing to disk:
# Verify transfer package requiring an authenticated digital signature
ctt verify ./transfer.zip --require-signature --log-json
# Dry-run restoration to inspect files without writing output
ctt restore ./transfer.zip ./restored_dir --dry-run
# Perform real atomic restoration with JSON audit logging
ctt restore ./transfer.zip ./restored_dir --require-signature --log-json
4. Package Comparison (diff)
Inspect changes between a transfer package and a live source directory:
ctt diff ./transfer_dir ./source_dir --policy ctt.yaml --json
5. Self-Bootstrapping Deployment Package
Package the ctt application itself into a standalone .txt-only transfer bundle with embedded zero-dependency bootstrapper:
ctt self-package ./dist/ctt-bootstrap.zip --format zip
For complete CLI flag documentation, see the CLI option reference.
Policy and Compliance
ctt uses an explicit policy-driven allowlist:
- Default Policy (No
--policyflag required): UTF-8 decoding, explicit extension/name allowlists, SHA-256 hashes, and a 10 MiB per-file limit. - Custom Policy (
--policy PATH): Load custom rules from a YAML file (e.g.ctt.yaml). - Ignored Files: Files matching
.cttignoreor failing allowlist criteria are safely omitted from transfer. generic-text-v1Profile: Enforces file count, aggregate size, path depth, character sets, line lengths, control character checks, and forbidden textual patterns.- Hash Support: SHA-256 (default), SHA-512 (
hash_algorithm: sha512), and optional BLAKE3 (uv sync --extra blake3).
See the policy reference and examples for full configuration details.
Security & Integrity
- Atomic Restoration: Destinations are staged and validated before publication to prevent partial writes.
- Traversal Prevention: Every manifest path is verified against a link-free package root.
- Digital Signatures: Detached signature hooks in
controlled_text_transfer.signingintegrate with host GPG/X.509 infrastructure.cttfails closed if a signature is missing when--require-signatureis specified.
See SECURITY.md for detailed security guidance.
Development & Maintenance
Developer workflow and project maintenance scripts are managed separately from user CLI commands:
# Environment setup
bash scripts/run.sh setup
uv sync --extra dev
# Run test suite and quality gates
bash scripts/run.sh check
uv run --extra dev pytest
# Generate test coverage and API documentation reports
bash scripts/run.sh report
# Clean generated build and test artifacts
bash scripts/run.sh clean --dry-run
bash scripts/run.sh clean
For full details on repository scripts and release workflows, see Development scripts and AGENTS.md.
GitHub automation
GitHub-specific automation enforces the same build, test, security, and release requirements documented for local development. It uses least-privilege permissions, immutable action references, and locked Python dependencies.
- Workflow definitions
dependabot.ymlmaintains pinned GitHub Actions dependencies.
Releases use PyPI Trusted Publishing through .github/workflows/release.yml. Configure a pending GitHub publisher for project controlled-text-transfer, owner dgomez407, repository ctt, workflow release.yml, and environment pypi. After quality gates pass, push a version tag such as v0.1.0 from a commit contained in main. The workflow verifies that the tagged commit belongs to origin/main, the tag, package version, README, and changelog agree; reruns the locked quality gates; validates the wheel and source distribution; and publishes them without a stored API token.
Documentation Index
- Documentation index
- Operations runbook
- Policy reference and examples
- Complete CLI option reference
- CLI and library API
- Security guidance
- Architecture Decision Records
- Changelog
- Contributor and agent guidelines
- Repository-specific agent guidance
- Gemini agent entry point
Repository Map
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file controlled_text_transfer-0.2.0.tar.gz.
File metadata
- Download URL: controlled_text_transfer-0.2.0.tar.gz
- Upload date:
- Size: 96.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07351b0d9e53f62d06a050c2aa3b9fb8166bae1ff63e3bed4369e1ced988825e
|
|
| MD5 |
5a37b2550e1401e35e4056a1e5120961
|
|
| BLAKE2b-256 |
c9138b48a2dfafa6c8caadcc341b809c2ec15c492499db276e540389ed1cca0e
|
Provenance
The following attestation bundles were made for controlled_text_transfer-0.2.0.tar.gz:
Publisher:
release.yml on dgomez407/ctt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
controlled_text_transfer-0.2.0.tar.gz -
Subject digest:
07351b0d9e53f62d06a050c2aa3b9fb8166bae1ff63e3bed4369e1ced988825e - Sigstore transparency entry: 2256768582
- Sigstore integration time:
-
Permalink:
dgomez407/ctt@61215065c798ab0b8ae24e02042d2e694752017e -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dgomez407
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@61215065c798ab0b8ae24e02042d2e694752017e -
Trigger Event:
push
-
Statement type:
File details
Details for the file controlled_text_transfer-0.2.0-py3-none-any.whl.
File metadata
- Download URL: controlled_text_transfer-0.2.0-py3-none-any.whl
- Upload date:
- Size: 27.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bffe80c198aa913d18e3851058f68b1486b03a95c210b4924256e86d5a98657d
|
|
| MD5 |
07d9bb6437356527e967a5c8a6094eb7
|
|
| BLAKE2b-256 |
bdaa3f3c7a4c8588e12b350aeb0b41b268cf021bdb0402d58eecdcfe1b241e9c
|
Provenance
The following attestation bundles were made for controlled_text_transfer-0.2.0-py3-none-any.whl:
Publisher:
release.yml on dgomez407/ctt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
controlled_text_transfer-0.2.0-py3-none-any.whl -
Subject digest:
bffe80c198aa913d18e3851058f68b1486b03a95c210b4924256e86d5a98657d - Sigstore transparency entry: 2256768593
- Sigstore integration time:
-
Permalink:
dgomez407/ctt@61215065c798ab0b8ae24e02042d2e694752017e -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dgomez407
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@61215065c798ab0b8ae24e02042d2e694752017e -
Trigger Event:
push
-
Statement type: