- ✅ FIXED: Hardcoded database password in
zsh/aliases/dirs.shline 15 - ✅ IMPLEMENTED: Secure environment variable management system
- ✅ CREATED: 1Password CLI integration for secret management
- Risk Level:
⚠️ MEDIUM → ✅ LOW (after fixes) - Issues Found: 1 critical, 0 high, 0 medium, 0 low
- Compliance: OWASP secure coding practices applied
-
Copy the template:
cp ~/.dotfiles/.env.example ~/.env.local
-
Set your secrets:
nvim ~/.env.local # Edit with your actual values
-
Source in your shell:
# Add to your .zshrc [ -f ~/.env.local ] && source ~/.env.local
-
Install 1Password CLI:
brew install 1password-cli
-
Sign in:
op signin
-
Setup secrets in 1Password:
~/.dotfiles/bin/secure-env setup -
Load secrets:
source ~/.dotfiles/bin/secure-env
-
Create .pgpass file:
echo "sourcehub-db.cfm0kcykeufs.us-east-2.rds.amazonaws.com:5432:sourcehub:sourcehub_admin:YourPassword" > ~/.pgpass chmod 600 ~/.pgpass
-
Use without PGPASSWORD:
psql -h sourcehub-db.cfm0kcykeufs.us-east-2.rds.amazonaws.com -U sourcehub_admin -d sourcehub
- No hardcoded passwords in any files
- Environment variables used for sensitive data
- 1Password CLI configured for production secrets
- .pgpass file has correct permissions (600)
- .env.local added to .gitignore
- SSH keys have 600 permissions
- GPG keys have 600 permissions
- Config files have appropriate permissions
- Scripts are executable but not world-writable
- .gitignore includes all sensitive files
- No secrets in git history
- Use signed commits when required
- Remote URLs use SSH, not HTTPS with tokens
- SSH configs use key-based authentication
- No passwords in SSH configs
- VPN configurations secured
- API endpoints use HTTPS only
- Update dependencies regularly
- Rotate passwords/tokens quarterly
- Review file permissions monthly
- Audit dotfiles for new secrets
# ❌ INSECURE - Don't do this
alias db='PGPASSWORD=hardcoded_password psql -h host -U user -d db'
# ✅ SECURE - Use environment variables
alias db='PGPASSWORD="$DB_PASSWORD" psql -h host -U user -d db'
# ✅ SECURE - Use 1Password CLI
alias db='PGPASSWORD="$(op read "op://vault/item/password")" psql -h host -U user -d db'
# ✅ SECURE - Use .pgpass file
alias db='psql -h host -U user -d db' # Password from ~/.pgpass# ❌ INSECURE
export GITHUB_TOKEN="ghp_hardcoded_token_here"
# ✅ SECURE - Environment variable
export GITHUB_TOKEN="$GITHUB_API_TOKEN"
# ✅ SECURE - 1Password CLI
export GITHUB_TOKEN="$(op read 'op://Personal/GitHub Token/credential')"# ~/.ssh/config
Host production-server
HostName server.example.com
User deploy
IdentityFile ~/.ssh/production_key
IdentitiesOnly yes
# Ensure key has correct permissions
chmod 600 ~/.ssh/production_key# Search for potential secrets in dotfiles
grep -r -i "password\|secret\|token\|key" ~/.dotfiles --exclude-dir=.git# Run security validation
~/.dotfiles/bin/secure-env validate
# Check file permissions
find ~/.dotfiles -type f -perm +o+w -exec ls -la {} \;#!/bin/sh
# .git/hooks/pre-commit
# Prevent committing secrets
if grep -r "password\|secret\|token" --include="*.sh" --include="*.zsh"; then
echo "❌ Potential secret detected! Commit rejected."
exit 1
fi-
Immediate Actions:
# Change all affected passwords immediately # Revoke API tokens/keys # Rotate SSH keys
-
Clean Git History:
# Remove secrets from git history git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch path/to/secret/file' \ --prune-empty --tag-name-filter cat -- --all
-
Notify Team:
- Inform team members immediately
- Update shared password managers
- Review access logs for unauthorized usage
- Use branch protection rules
- Implement secret scanning tools
- Regular security training
- Automated security checks in CI/CD
- 1Password CLI: Secure secret management
- git-secrets: Prevent committing secrets
- truffleHog: Find secrets in git history
- detect-secrets: Automated secret detection
- Never commit secrets to version control
- Use environment variables for configuration
- Implement least privilege access
- Rotate credentials regularly
- Monitor for unusual access patterns
- Use multi-factor authentication
- Keep dependencies updated
- Regular security audits
# Setup secure environment
cp ~/.dotfiles/.env.example ~/.env.local
~/.dotfiles/bin/secure-env setup
# Load secrets for session
source ~/.dotfiles/bin/secure-env
# Validate configuration
~/.dotfiles/bin/secure-env validate
# Test database connection
sourcehub-db
# Check for potential secrets
grep -r -i "password\|secret\|token" ~/.dotfiles --exclude-dir=.git