Skip to content

Commit d9d465b

Browse files
Flamehavenclaude
andcommitted
Add comprehensive security configuration for Pro license management
- Add .env.example template for safe license configuration - Enhance .gitignore with security patterns (.env.*, *.license, secrets.txt) - Create SECURITY.md with Pro license management guidelines - Update CLI to auto-load .env files for Pro feature activation - Ensure .env files are completely excluded from Git tracking Security improvements: - Safe Pro license key storage without Git exposure - Multiple .env file patterns protection - Comprehensive security documentation - Automatic environment loading for seamless Pro experience 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8bda600 commit d9d465b

File tree

4 files changed

+130
-1
lines changed

4 files changed

+130
-1
lines changed

.env.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Dir2md Environment Configuration Template
2+
# Copy this file to .env and fill in your actual values
3+
4+
# License Configuration
5+
DIR2MD_LICENSE=PRO-your_license_key_here
6+
7+
# Optional: API Keys for enhanced features
8+
GITHUB_TOKEN=ghp_your_github_token_here
9+
OPENAI_API_KEY=sk-your_openai_key_here
10+
11+
# Performance Settings
12+
DIR2MD_MAX_WORKERS=4
13+
DIR2MD_CACHE_DIR=~/.dir2md/cache

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ __pycache__/
33
*.py[cod]
44
*.egg-info/
55
.env
6+
.env.*
7+
!.env.example
68
.venv/
79
venv/
810
.idea/
@@ -13,6 +15,13 @@ venv/
1315
.coverage
1416
.pytest_cache/
1517

18+
# License and API Keys (Security)
19+
license.key
20+
*.license
21+
api_keys.txt
22+
secrets.txt
23+
config.local.*
24+
1625
# OS
1726
.DS_Store
1827
Thumbs.db

SECURITY.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Security Guidelines for Dir2md
2+
3+
## 🔐 License Key Management
4+
5+
### Safe Practices
6+
7+
#### ✅ DO:
8+
- Use environment variables: `export DIR2MD_LICENSE="PRO-your_key"`
9+
- Create `.env` file locally (already in .gitignore)
10+
- Use different keys for development/production
11+
- Rotate keys periodically
12+
13+
#### ❌ DON'T:
14+
- Never commit license keys to Git
15+
- Don't hardcode keys in scripts
16+
- Avoid sharing keys in plain text
17+
- Don't use production keys in testing
18+
19+
### Setting Up Pro License
20+
21+
1. **Create local environment file:**
22+
```bash
23+
cp .env.example .env
24+
# Edit .env with your actual license key
25+
```
26+
27+
2. **Or use environment variable:**
28+
```bash
29+
export DIR2MD_LICENSE="PRO-your_license_key_here"
30+
```
31+
32+
3. **Verify activation:**
33+
```bash
34+
dir2md --version --verbose
35+
```
36+
37+
### Development vs Production
38+
39+
#### Development Environment:
40+
```bash
41+
# .env.development
42+
DIR2MD_LICENSE=PRO-dev_key_123456789
43+
DIR2MD_LOG_LEVEL=DEBUG
44+
```
45+
46+
#### Production Environment:
47+
```bash
48+
# Use secure secret management
49+
export DIR2MD_LICENSE="${PROD_LICENSE_KEY}"
50+
```
51+
52+
### Git Safety Checks
53+
54+
Before committing, always run:
55+
```bash
56+
# Check for accidentally committed secrets
57+
git diff --cached | grep -i "PRO-\|license\|key\|secret"
58+
59+
# Use git-secrets if available
60+
git secrets --scan
61+
```
62+
63+
### License Key Format
64+
65+
Valid Pro keys must:
66+
- Start with `PRO-`
67+
- Be at least 11 characters total
68+
- Example: `PRO-abc123def456`
69+
70+
### Troubleshooting
71+
72+
#### Key Not Working:
73+
1. Check format: `PRO-` prefix + sufficient length
74+
2. Verify environment variable is set
75+
3. Restart application after setting key
76+
4. Check for typos or extra spaces
77+
78+
#### Accidental Exposure:
79+
1. Immediately rotate the key
80+
2. Remove from Git history if committed
81+
3. Check GitHub/GitLab secret scanning alerts
82+
4. Update all environments with new key
83+
84+
### Contact
85+
86+
For license issues: https://dir2md.com/support
87+
For security concerns: security@dir2md.com

src/dir2md/cli.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
from __future__ import annotations
2-
import argparse, zipfile, hashlib
2+
import argparse, zipfile, hashlib, os
33
from pathlib import Path
44
from .core import Config, generate_markdown_report
55
from . import __version__
66

7+
# Load .env file if it exists (for Pro license and configuration)
8+
def load_env_file():
9+
# Try current directory first, then parent directories
10+
current = Path.cwd()
11+
for parent in [current] + list(current.parents):
12+
env_file = parent / '.env'
13+
if env_file.exists():
14+
try:
15+
for line in env_file.read_text(encoding='utf-8').splitlines():
16+
line = line.strip()
17+
if line and not line.startswith('#') and '=' in line:
18+
key, value = line.split('=', 1)
19+
os.environ[key.strip()] = value.strip()
20+
break # Stop after first .env file found
21+
except Exception:
22+
pass # Silently ignore .env file errors
23+
24+
# Load environment configuration on import
25+
load_env_file()
26+
727
DEFAULT_EXCLUDES = [
828
".git", "__pycache__", "node_modules", ".venv",
929
"build", "dist", "*.pyc", ".DS_Store",

0 commit comments

Comments
 (0)