Secure tool signing system for automatically adding project-specific tools to PATH
Project description
Signed Binary Directory
A secure tool signing system that automatically adds project-specific tools to your PATH when you navigate into directories. This ensures that only cryptographically signed and verified tools are executed, providing security against malicious scripts while maintaining convenience.
Features
- ๐ Cryptographic Signing: Uses your SSH private key to sign executable files
- ๐ก๏ธ Automatic Verification: Verifies signatures before adding directories to PATH
- ๐ Shell Integration: Works with both Fish and Bash shells
- ๐ Hierarchical Discovery: Finds signed bin directories in current and parent directories
- โก Fast: Minimal overhead when changing directories
- ๐ Transparent: Optional notifications when signed tools are discovered
- ๐ ๏ธ Easy Setup: Automatic shell integration installer
Security Model
This tool uses your existing SSH key pair for signing and verification:
- Signing: Uses your SSH private key (
~/.ssh/id_rsaby default) to create cryptographic signatures - Verification: Uses the corresponding public key to verify signatures before trusting executables
- Manifest: Creates a
.signed-manifest.jsonfile containing hashes and signatures of all executables - Trust: Only directories with valid signatures from your key are added to PATH
Installation
Install from PyPI
# Install the latest version from PyPI
pip install signed-bin-dir
# Or install in development mode from source
git clone https://github.com/igutekunst/signed-bin-dir.git
cd signed-bin-dir
pip install -e .
Shell Integration (Automatic)
The easiest way to set up shell integration:
# Auto-detect and install for all available shells
sign-bin-dir install
# Install for a specific shell
sign-bin-dir install --shell fish
sign-bin-dir install --shell bash
# Check installation status
sign-bin-dir status
# Uninstall if needed
sign-bin-dir uninstall --all
The shell integration files are automatically included with the pip package, so no additional setup is required.
Shell Integration (Manual)
If you prefer manual setup, you can find the integration files in your Python environment after installation:
# Find the integration files
python3 -c "import signed_bin_dir; from pathlib import Path; print(Path(signed_bin_dir.__file__).parent.parent / 'share' / 'signed-bin-dir' / 'shell_integrations')"
Fish Shell
Add to your ~/.config/fish/config.fish:
# Source the signed-bin-dir integration (adjust path as needed)
source /path/to/shell_integrations/signed_bin_dir.fish
Bash Shell
Add to your ~/.bashrc:
# Source the signed-bin-dir integration (adjust path as needed)
source /path/to/shell_integrations/signed_bin_dir.bash
Usage
Basic Workflow
- Create a bin directory in your project with executable tools
- Sign the directory using
sign-bin-dir - Navigate into the project - tools are automatically added to PATH
- Navigate away - tools are automatically removed from PATH
Command Line Interface
Shell Integration Management
# Check which shells are available and integration status
sign-bin-dir status
# Install integration for all detected shells
sign-bin-dir install
# Install for specific shell
sign-bin-dir install --shell fish
# Uninstall integration
sign-bin-dir uninstall --shell fish
sign-bin-dir uninstall --all
Sign a bin directory
# Sign all executables in a bin directory
sign-bin-dir sign ./bin
# Use a specific private key
sign-bin-dir sign ./bin --private-key ~/.ssh/my_key
# Verbose output
sign-bin-dir sign ./bin --verbose
Verify signatures
# Verify all signatures in a bin directory
sign-bin-dir verify ./bin
# Verify with verbose output
sign-bin-dir verify ./bin --verbose
List signed files
# List all signed files in a bin directory
sign-bin-dir list-files ./bin
Convenience Functions
The shell integrations provide helpful functions:
# Sign the bin directory in current project
sign-current-bin
# Verify the bin directory in current project
verify-current-bin
Example Project Structure
my-project/
โโโ bin/
โ โโโ my-tool
โ โโโ deploy-script
โ โโโ .signed-manifest.json # Created by sign-bin-dir
โโโ src/
โโโ README.md
Quick Start
-
Install the package:
pip install signed-bin-dir
-
Set up shell integration:
sign-bin-dir install -
Restart your shell or source your config file
-
Try with a project:
mkdir my-project && cd my-project mkdir bin echo '#!/bin/bash\necho "Hello from my tool!"' > bin/my-tool chmod +x bin/my-tool sign-bin-dir sign bin my-tool # Works! cd .. my-tool # Command not found (removed from PATH)
How It Works
- Directory Change Detection: Shell hooks detect when you change directories
- Discovery: Searches current and parent directories for
bin/folders with.signed-manifest.json - Verification: Validates signatures against your SSH public key
- PATH Management: Adds verified directories to PATH, removes them when you leave
Security Considerations
- Key Security: Protect your SSH private key as it's used for signing
- Trust Model: Only trust signatures from keys you control
- Verification: Always verify signatures before executing tools
- Isolation: Each project's tools are isolated and only available in that context
Configuration
Custom SSH Key
By default, the tool uses ~/.ssh/id_rsa. To use a different key:
sign-bin-dir sign ./bin --private-key ~/.ssh/my_project_key
Shell Integration Options
You can customize the shell integration behavior:
# In your Fish config, uncomment this line to show notifications
__signed_bin_dir_check_current
Development
Setup Development Environment
# Clone and install in development mode
git clone https://github.com/igutekunst/signed-bin-dir.git
cd signed-bin-dir
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black signed_bin_dir/
isort signed_bin_dir/
# Type checking
mypy signed_bin_dir/
Project Structure
signed-bin-dir/
โโโ signed_bin_dir/
โ โโโ __init__.py
โ โโโ cli.py # Command-line interface
โ โโโ signer.py # Core signing/verification logic
โ โโโ path_manager.py # PATH management functionality
โ โโโ installer.py # Shell integration installer
โโโ shell_integrations/
โ โโโ signed_bin_dir.fish # Fish shell integration
โ โโโ signed_bin_dir.bash # Bash shell integration
โโโ tests/
โโโ pyproject.toml
โโโ README.md
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details.
Author
Isaac Harrison Gutekunst isaac@supercortex.io
Troubleshooting
Common Issues
"Private key not found"
- Ensure you have an SSH key pair generated:
ssh-keygen -t rsa - Check the key path:
ls -la ~/.ssh/
"Signature verification failed"
- Re-sign the directory:
sign-bin-dir sign ./bin - Check file permissions:
ls -la bin/
"Command not found: sign-bin-dir"
- Ensure the package is installed:
pip list | grep signed-bin-dir - Check your PATH includes pip's bin directory
Shell integration not working
- Check installation status:
sign-bin-dir status - Reinstall integration:
sign-bin-dir install - Restart your shell or source the config file
Integration installer issues
- Make sure you have write permissions to your shell config files
- Check if your shell config directory exists (e.g.,
~/.config/fish/) - Use manual installation if automatic installation fails
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
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 signed_bin_dir-0.1.4.tar.gz.
File metadata
- Download URL: signed_bin_dir-0.1.4.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4852097517e236ca6413ecf8be8938ddb0b9b5fcaabd7a1b078acf5ad78f2af0
|
|
| MD5 |
6e17dc172bf06b8a609200ed8654caab
|
|
| BLAKE2b-256 |
c6bb5590d5a8cb2a08cb07ce019b608e5d5fe8e8d5ac5a83873ef2498bedc1fe
|
File details
Details for the file signed_bin_dir-0.1.4-py3-none-any.whl.
File metadata
- Download URL: signed_bin_dir-0.1.4-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb0af10f1fdada0f54cf30e1b2ee19f6267e3faf804a20dcd6436691ae4e983a
|
|
| MD5 |
a5d75b4a8c94bbd825c806466f385ab6
|
|
| BLAKE2b-256 |
e33703ac286016b48e638f8fac5f8f4a9e1fce3fbe0095b3047aa1a6fcd09667
|