Skip to content

Commit 6ceb2ae

Browse files
Merge pull request #3 from GreenHacker420/feature/offline-secrets-manager
feat: Implement Offline Secrets Manager with AES-256 Encryption
2 parents 42941e7 + 8a130a2 commit 6ceb2ae

File tree

9 files changed

+1608
-15
lines changed

9 files changed

+1608
-15
lines changed

IMPLEMENTATION.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Offline Secrets Manager Implementation
2+
3+
## Overview
4+
5+
This implementation adds a fully functional offline secrets manager to ENV Storage Manager. The application securely stores API keys, database credentials, and other sensitive environment variables locally with AES-256 encryption.
6+
7+
## Features Implemented
8+
9+
### 🔐 Core Security
10+
- **AES-256 Encryption**: All secrets are encrypted using Fernet (symmetric encryption)
11+
- **PBKDF2 Key Derivation**: Master password is converted to encryption key using PBKDF2 with 480,000 iterations (OWASP recommended)
12+
- **Secure Password Hashing**: SHA-256 hashing for password verification
13+
- **Salt Management**: Unique salt per installation for additional security
14+
15+
### 📦 Storage Layer
16+
- **SQLite Database**: Local, file-based storage in `~/.env_storage/`
17+
- **SQLAlchemy ORM**: Robust database management with proper relationships
18+
- **Audit Logging**: All operations are logged for security tracking
19+
- **Cascade Deletion**: Deleting a project removes all associated secrets
20+
21+
### 🎨 CLI Interface
22+
- **Rich Terminal UI**: Beautiful tables and colored output using Rich library
23+
- **Secure Input**: Password masking for sensitive data entry
24+
- **Interactive Commands**: User-friendly prompts and confirmations
25+
- **Comprehensive Commands**:
26+
- `init` - Initialize storage with master password
27+
- `create-project` - Create a new project
28+
- `add` - Add/update environment variables
29+
- `list` - List projects or environment variables
30+
- `get` - Retrieve specific variable with full value
31+
- `search` - Search across all projects
32+
- `export` - Export to .env file
33+
- `delete` - Delete environment variables
34+
- `delete-project` - Delete entire projects
35+
36+
### 🧪 Testing
37+
- **Comprehensive Test Suite**: 40+ test cases covering:
38+
- Encryption/decryption functionality
39+
- Storage initialization and authentication
40+
- Project and environment variable management
41+
- Search and export features
42+
- Edge cases and error handling
43+
- Unicode and special character support
44+
45+
## Architecture
46+
47+
```
48+
src/
49+
├── crypto/
50+
│ └── encryption.py # Encryption/decryption logic
51+
├── core/
52+
│ ├── models.py # SQLAlchemy database models
53+
│ ├── database.py # Database connection management
54+
│ └── storage.py # Main storage interface
55+
└── cli/
56+
└── main.py # CLI commands and interface
57+
```
58+
59+
## Database Schema
60+
61+
### Config Table
62+
- Stores master password hash and encryption salt
63+
- Single row per installation
64+
65+
### Projects Table
66+
- Project name (unique)
67+
- Description
68+
- Timestamps
69+
70+
### EnvVars Table
71+
- Project reference (foreign key)
72+
- Key name
73+
- Encrypted value (binary)
74+
- Description
75+
- Timestamps
76+
77+
### AuditLog Table
78+
- Action type (CREATE, READ, UPDATE, DELETE)
79+
- Entity type (PROJECT, ENV_VAR)
80+
- Entity ID
81+
- Details
82+
- Timestamp
83+
84+
## Security Considerations
85+
86+
1. **Offline-First**: All data stored locally, no cloud dependencies
87+
2. **Encryption at Rest**: Secrets never stored in plaintext
88+
3. **Master Password**: Single password protects all secrets
89+
4. **No Password Recovery**: Master password cannot be recovered (by design)
90+
5. **Audit Trail**: All operations logged for security review
91+
6. **Secure Export**: Warning displayed when exporting to .env files
92+
93+
## Usage Examples
94+
95+
### Initialize
96+
```bash
97+
python main.py init
98+
```
99+
100+
### Create Project
101+
```bash
102+
python main.py create-project -n myapp -d "My awesome application"
103+
```
104+
105+
### Add Secrets
106+
```bash
107+
python main.py add -p myapp -k API_KEY -d "OpenAI API Key"
108+
# Will prompt for value securely
109+
```
110+
111+
### List Projects
112+
```bash
113+
python main.py list
114+
```
115+
116+
### List Project Variables
117+
```bash
118+
python main.py list -p myapp
119+
```
120+
121+
### Search
122+
```bash
123+
python main.py search API
124+
```
125+
126+
### Export to .env
127+
```bash
128+
python main.py export -p myapp -o .env
129+
```
130+
131+
### Get Specific Variable
132+
```bash
133+
python main.py get -p myapp -k API_KEY
134+
```
135+
136+
## Installation
137+
138+
```bash
139+
# Install dependencies
140+
pip install -r requirements.txt
141+
142+
# Run the application
143+
python main.py init
144+
```
145+
146+
## Testing
147+
148+
```bash
149+
# Install dev dependencies
150+
pip install -r requirements-dev.txt
151+
152+
# Run tests
153+
pytest tests/ -v
154+
155+
# Run with coverage
156+
pytest --cov=src --cov-report=html tests/
157+
```
158+
159+
## Why This Matters for Developers
160+
161+
As developers, we constantly juggle multiple projects, each with their own set of API keys, database credentials, and configuration secrets. This tool solves several pain points:
162+
163+
1. **Centralized Management**: All secrets in one secure location
164+
2. **No More Lost Keys**: Never forget where you stored that API key
165+
3. **Security by Default**: Encrypted storage prevents accidental exposure
166+
4. **Easy Context Switching**: Quickly access secrets for any project
167+
5. **Version Control Safe**: Keep secrets out of git repositories
168+
6. **Audit Trail**: Know when and how secrets were accessed
169+
170+
## Contribution Details
171+
172+
- **Type**: Feature Implementation
173+
- **Lines of Code**: ~1000+ lines
174+
- **Files Added**: 7 new files
175+
- **Test Coverage**: 40+ test cases
176+
- **Documentation**: Comprehensive inline documentation and docstrings
177+
178+
## Future Enhancements
179+
180+
Potential improvements for future contributions:
181+
- Import from existing .env files
182+
- Backup/restore functionality
183+
- Multi-user support with different access levels
184+
- Browser extension for auto-fill
185+
- IDE integration plugins
186+
- Cloud sync (optional, with end-to-end encryption)
187+
- Two-factor authentication
188+
- Secret rotation reminders
189+
- Secret sharing with team members
190+
191+
## License
192+
193+
MIT License - Same as parent project

main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Main entry point for ENV Storage Manager CLI."""
2+
3+
from src.cli.main import cli
4+
5+
if __name__ == "__main__":
6+
cli()

0 commit comments

Comments
 (0)