Security Scanning Setup
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.
Automated Security Scans
The following security checks are automatically run on each push to main and on each pull request:
1. Bandit
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.ymlfile
2. Pylint
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
3. SonarCloud
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
Setting up SonarCloud
- 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_TOKENin your GitHub repository settings - The GitHub workflows are already configured to use SonarCloud with your organization
Local Development Setup
Pre-commit Hooks
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
Manual Security Scanning
You can also run the security tools manually:
Bandit
pip install bandit
bandit -r src/
Pylint
pip install pylint
pylint src/
Security Best Practices
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
Reporting Security Issues
If you discover a security vulnerability, please do NOT open an issue. Email [security contact email] instead.