A tool for managing secrets in Git with AWS Parameter Store integration.
Project description
git-secret-protector
spartan-git-secret-protector
is a Python-based CLI tool designed to securely manage and protect sensitive files in your Git repositories. It integrates with AWS Parameter Store to encrypt and decrypt secrets, ensuring that your sensitive data remains secure throughout your development process.
Features
- AES Key Management: Securely create, manage, and rotate AES data keys using AWS Parameter Store.
- File Encryption/Decryption: Automatically encrypt and decrypt files in your repository based on patterns defined in the
.gitattributes
file. - Cache Management: Cache AES data keys locally to improve performance and reduce redundant calls to AWS Parameter Store.
- Git Hooks Integration: Integrates with Git hooks to automatically manage secrets during Git operations.
- Logging: Configurable logging for detailed tracking of operations and errors.
Install Guide
Requirements
You can install the git-secret-protector
module via pipx:
pipx install git-secret-protector
Usage
1. Initial Setup
Before using the tool, ensure you have the necessary AWS permissions to manage AWS MKS & SSM. Then, initialize your repository for secret protection by installing Git clean and smudge filter and setting up the module.
git-secret-protector install
2. Pull AES Key
Before encrypting or decrypting files, you need to pull the relevant AES keys from AWS Parameter Store for a specific filter:
git-secret-protector pull-aes-key <filter_name>
This command will pull the latest AES data key from AWS Parameter Store for the specified filter and cache it locally.
This command will decrypt the files in your working directory for the specified filter, making them available for editing.
3. Key Rotation
Command to Rotate Keys
git-secret-protector rotate-key <filter_name>
This command will generate a new AES data key in AWS Parameter Store, re-encrypt your files associated with the specified filter with the new key, and update the local cache.
Post-Rotation Code Reset
After rotating the keys, it is necessary to clear the Git cache and re-checkout all files. This step ensures that the smudge filters are triggered, allowing the files to be decrypted with the new key.
# Remove all files from the index to clear the Git cache
git rm --cached -r .
# Force Git to re-checkout all files, triggering smudge filters
git reset --hard
4. View Encryption Status
Command to obtain a comprehensive overview of the encryption status of files within the repository:
git-secret-protector status
Configuration
All configurations are managed through a config.ini
file located in the .git-secret-protector
directory. You can customize the following settings:
- AWS Configuration: Set your AWS region, profile, and other credentials.
- Logging: Configure the log file path and rotation settings.
- Module Name: Specify a custom module name for organizing keys in AWS Parameter Store.
Example .gitattributes
File
Define which files to encrypt in your .gitattributes
file:
secrets/*.tfstate filter=git-crypt-app diff=git-crypt-app
config/**/credentials/* filter=git-crypt-shared diff=git-crypt-shared
Logging
Logs are stored in the logs/
directory by default, and you can configure the log level and file rotation in the config.ini
file.
Development
Running Tests
- Unit Tests: Located in the
tests/unit
directory, run them usingpytest
. - Integration Tests: Located in the
tests/integration
directory, these tests interact with AWS Parameter Store and should be run manually.
poetry run pytest tests/unit
Changelog
See CHANGELOG.md for a history of changes and updates.
Support
If you encounter any issues or have any questions, please open an issue on the GitHub repository or reach out to our support team.
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
File details
Details for the file git_secret_protector-0.2.0.tar.gz
.
File metadata
- Download URL: git_secret_protector-0.2.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60687b86ca18046dbbba541b449bdd169c02b4f0606c3319684cea31b6a1b2c1 |
|
MD5 | b743a71cc5bf8a89c2dbbc88089c0b59 |
|
BLAKE2b-256 | a0744d7dc5961c995a7cb5d8a1da34c10a5ca299e66789b2f71000433b35e4d2 |
File details
Details for the file git_secret_protector-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: git_secret_protector-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26f520b83ed2c1212d6a37bcbef404cf83f72c482e3d6c869eee845eb294ef60 |
|
MD5 | 8a0b1961f5cb85c57ac324ddc94054bf |
|
BLAKE2b-256 | 452f96f687bed4563fdefa920a3794dae5c8ab6ab404ea0e046c97a07845c9dd |