シークレット(APIキー、パスワード、トークン、暗号化キー)は、コードにハードコードしたり、バージョン管理にコミットしたりせず、安全に保存してアクセスする必要があります。不適切なシークレット管理は、よくある深刻な侵害の原因です。
鉄則:シークレットを決してハードコードしたりコミットしない
❌ NEVER hardcode secrets in source code or commit them to Git:
→ committed secrets are in the repo HISTORY (exposed even if "removed" later)
→ public repos / leaks expose them to attackers (bots scan GitHub for keys constantly)
→ a TOP cause of breaches (leaked AWS keys, database passwords, API tokens)
⚠️ If a secret IS committed/leaked → ROTATE it immediately (it's compromised)
シークレットを正しく管理する方法
✓ ENVIRONMENT VARIABLES → inject secrets at runtime (not in code); keep .env OUT of Git
(.gitignore) — basic approach
✓ SECRETS MANAGERS → HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, etc.:
→ centralized, encrypted, access-controlled, audited, rotatable secret storage
→ the robust approach for production (fetch secrets at runtime)
✓ Cloud/platform secret stores; CI/CD secret stores (for pipeline secrets)
