This project uses multiple security scanning tools to ensure code quality and security. Below is information about the setup and how to use these tools.
The following security checks are automatically run on each push to main and on each pull request:
Bandit is a tool designed to find common security issues in Python code.
- Results are available as GitHub workflow artifacts
- Configuration is in the
.github/workflows/security-scan.yml
file
Pylint is a static code analysis tool that looks for programming errors, helps enforce coding standards, and can detect some security issues.
- Configuration is stored in
.pylintrc
- Results are available as GitHub workflow artifacts
SonarCloud provides a comprehensive code quality and security analysis for cloud repositories.
- Results are available in the SonarCloud dashboard after signing in
- Configuration is stored in
sonar-project.properties
- Go to SonarCloud and log in with your GitHub account
- Create a new organization or use an existing one
- Add your repository to SonarCloud
- Generate a token in SonarCloud: Account > Security > Generate Token
- Add the token as a secret named
SONAR_TOKEN
in your GitHub repository settings - The GitHub workflows are already configured to use SonarCloud with your organization
To ensure code quality and security before committing, you can use the pre-commit hooks:
- Install pre-commit:
pip install pre-commit
- Install the git hooks:
pre-commit install
- The hooks will now run automatically on each commit
You can also run the security tools manually:
pip install bandit
bandit -r src/
pip install pylint
pylint src/
When contributing to this project, please follow these security best practices:
- Input Validation: Always validate and sanitize user inputs
- Avoid Hardcoded Secrets: Never commit secrets, API keys, or credentials
- Use Parameterized Queries: Prevent SQL injection by using parameterized queries
- Secure Dependencies: Regularly update dependencies to mitigate security vulnerabilities
- Error Handling: Implement proper error handling to avoid exposing sensitive information
- Secure HTTP Headers: Set appropriate security headers for web applications
- Use HTTPS: Always use HTTPS for API requests
- Authentication and Authorization: Implement proper authentication and authorization checks
If you discover a security vulnerability, please do NOT open an issue. Email [security contact email] instead.