Thank you for your interest in contributing to the DevSecOps Policy Scanner! This document provides guidelines and information for contributors.
- Getting Started
- Development Setup
- Code Standards
- Testing Guidelines
- Documentation
- Security
- Pull Request Process
- Release Process
- Community
- Python 3.9+ (3.11 recommended)
- Git
- Docker (optional, for containerized development)
- Make (optional, for using Makefile commands)
-
Fork the repository
git clone https://github.com/ByteEngr/devsecops-policy-scanner cd devsecops-policy-scanner -
Set up development environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt pip install -r requirements-dev.txt pip install -e .
-
Run tests
pytest tests/ -v
-
Clone your fork
git clone https://github.com/ByteEngr/devsecops-policy-scanner cd devsecops-policy-scanner -
Add upstream remote
git remote add upstream https://github.com/ByteEngr/devsecops-policy-scanner
-
Create a feature branch
git checkout -b feature/your-feature-name
-
Install dependencies
pip install -r requirements.txt pip install -r requirements-dev.txt pip install -e .
-
Build development image
docker build -t devsecops-policy-scanner:dev --target development . -
Run development container
docker run -it --rm -v $(pwd):/app devsecops-policy-scanner:dev -
Use Docker Compose
docker-compose up dsp-scanner-dev
We follow PEP 8 with some modifications:
- Line length: 120 characters maximum
- Import order: Standard library, third-party, local imports
- Docstrings: Google style docstrings
- Type hints: Required for all public functions
We use automated tools for code formatting:
# Format code with Black
black src/ tests/
# Sort imports with isort
isort src/ tests/
# Check code style with flake8
flake8 src/ tests/ --max-line-length=120
# Type checking with MyPy
mypy src/ --ignore-missing-importsInstall pre-commit hooks for automatic formatting:
pip install pre-commit
pre-commit install- Black: Code formatting
- isort: Import sorting
- flake8: Linting
- MyPy: Type checking
- Pylint: Additional linting
- Bandit: Security linting
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ -v --cov=src --cov-report=html
# Run specific test file
pytest tests/test_scanner.py -v
# Run specific test function
pytest tests/test_scanner.py::test_scan_policy -vtests/
├── unit/ # Unit tests
├── integration/ # Integration tests
├── performance/ # Performance tests
├── security/ # Security tests
└── conftest.py # Test configuration
- Test naming:
test_<function_name>_<scenario> - Use fixtures: Reuse common test data
- Mock external dependencies: Don't rely on external services
- Test edge cases: Include error conditions
- Maintain test isolation: Each test should be independent
import pytest
from src.dsp_scanner.core.scanner import PolicyScanner
def test_scan_policy_valid_input():
"""Test scanning a valid policy file."""
scanner = PolicyScanner()
result = scanner.scan("tests/fixtures/valid_policy.yaml")
assert result.is_valid
assert len(result.violations) == 0
assert result.score >= 0.8
def test_scan_policy_invalid_input():
"""Test scanning an invalid policy file."""
scanner = PolicyScanner()
with pytest.raises(ValueError):
scanner.scan("tests/fixtures/invalid_policy.yaml")- README.md: Project overview and quick start
- docs/: Detailed documentation
- Inline comments: Explain complex logic
- Docstrings: Google style for all public functions
- Type hints: Required for all public APIs
# Install documentation dependencies
pip install sphinx sphinx-rtd-theme
# Build documentation
sphinx-build -b html docs/ docs/_build/html
# Serve documentation locally
python -m http.server 8000 -d docs/_build/htmldocs/
├── api/ # API documentation
├── guides/ # User guides
├── development/ # Developer documentation
├── security/ # Security documentation
└── index.rst # Main documentation index
- Never commit secrets: Use environment variables or secure storage
- Validate inputs: Always validate and sanitize user inputs
- Use secure defaults: Implement secure-by-default configurations
- Follow OWASP guidelines: Adhere to OWASP security best practices
- Report vulnerabilities: Use our security policy for vulnerability reports
# Run security scans
bandit -r src/ -f json -o bandit-report.json
safety check --json --output safety-report.json
# Run vulnerability scans
pip-audit --json --output pip-audit-report.json- Code review: All code changes require security review
- Dependency review: Automated dependency vulnerability scanning
- Security testing: Automated security tests in CI/CD
- Penetration testing: Regular security assessments
- Update documentation: Ensure documentation is up to date
- Add tests: Include tests for new functionality
- Run tests: Ensure all tests pass locally
- Check formatting: Run code formatting tools
- Security review: Ensure no security issues
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] All tests pass locally
## Documentation
- [ ] README updated
- [ ] API documentation updated
- [ ] Code comments added
## Security
- [ ] Security implications considered
- [ ] No security vulnerabilities introduced
- [ ] Security tests added if applicable
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] Tests added/updated
- [ ] Security review completed- Automated checks: CI/CD pipeline runs automatically
- Code review: At least one maintainer review required
- Security review: Security team review for sensitive changes
- Documentation review: Ensure documentation is complete
- Final approval: Maintainer approval for merge
We follow Semantic Versioning:
- MAJOR: Incompatible API changes
- MINOR: Backward-compatible features
- PATCH: Backward-compatible bug fixes
- All tests passing
- Documentation updated
- Security scan clean
- Performance benchmarks acceptable
- Release notes prepared
- Docker images built and tested
- GitHub release created
- Update version: Update version in setup.py and init.py
- Update changelog: Add release notes to CHANGELOG.md
- Create release branch:
git checkout -b release/vX.Y.Z - Run full test suite: Ensure all tests pass
- Create GitHub release: Tag and release on GitHub
- Deploy: Deploy to PyPI and Docker Hub
- GitHub Issues: Bug reports and feature requests
- GitHub Discussions: General questions and discussions
- Security: chimadurugoodness@gmail.com for security issues
- Email: chimadurugoodness@gmail.com for general inquiries
- Be respectful: Follow our Code of Conduct
- Be helpful: Help others learn and grow
- Be patient: Understand different experience levels
- Be constructive: Provide helpful feedback
- Be collaborative: Work together toward common goals
We recognize contributors in several ways:
- Contributor profiles: Featured on our website
- Release notes: Acknowledged in release announcements
- Hall of Fame: Listed in project documentation
- Special thanks: Recognized for significant contributions
- Installation problems: Check Python version and dependencies
- Test failures: Ensure all dependencies are installed
- Documentation issues: Check if documentation is up to date
- Security concerns: Follow our security policy
- Documentation: Project Documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Security: Security Policy
- General: chimadurugoodness@gmail.com
- Security: chimadurugoodness@gmail.com
- Maintainer: Goziechukwu Chima-Duru (chimadurugoodness@gmail.com)
Thank you for contributing to DevSecOps Policy Scanner!
Last Updated: January 2025
Maintainer: Goziechukwu Chima-Duru (chimadurugoodness@gmail.com)