This file summarizes recommended security practices for running and developing StudyBot.
- Secrets and
.env
- Never commit
.envor any file containingDISCORD_TOKEN, API keys, or other secrets to source control. - Use
.gitignoreto exclude.envandstudybot.dbif it contains sensitive data. - Locally, load environment variables using
python-dotenvonly in development. For production, inject secrets via your hosting provider or CI.
- GitHub and CI
- Use GitHub Secrets for
DISCORD_TOKENin Actions workflows. - Limit repository collaborators and enforce branch protection rules.
- Permissions and roles
- When inviting the bot, grant least privilege required. Avoid
Administratorunless necessary. - For operations that modify nicknames or manage roles, ensure the bot's role is above the targets.
- Dependency safety
- Pin dependencies and review
requirements.txtfor unexpected packages. - Regularly run
pip-auditor dependabot to detect vulnerable packages.
- Running in production
- Run the bot in a dedicated service account and a small VM/container.
- If using SQLite, protect the file and backup securely. For higher scale, migrate to a managed DB.
- Logging and PII
- Avoid logging user private data. Sanitize logs before sharing.
- Keep logs rotated and access-restricted.
- Rate limits & abuse
- The bot uses Discord rate limits; avoid large bulk operations on startup.
- Use cooldowns on commands that could be abused.
- Safe code contributions
- Review PRs for dangerous functionality (remote code execution, shell calls).
- Use automated tests for critical flows where possible.
If you want, I can generate a sample GitHub Actions workflow that uses GitHub Secrets to start an ephemeral bot or run unit tests. Let me know if you want that.