Contributing to Protocol Reverse Engineering¶
Thank you for your interest in contributing! This document provides guidelines for contributing to the project.
Getting Started¶
- Fork the repository
- Clone your fork:
git clone <your-fork-url> - Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Run tests (when available)
- Commit with clear messages
- Push and create a pull request
Code Style¶
- Follow PEP 8 style guidelines
- Use type hints where appropriate
- Write docstrings for public functions and classes
- Keep functions focused and modular
- Use meaningful variable names
Adding New Features¶
Adding a New Pipeline Stage¶
- Create script in
scripts/XX_stage_name.py - Implement logic in appropriate
src/protocol_re/module - Update
main.pyto call the new stage - Add output artifact documentation
- Update schemas if needed
- Add tests
- Update documentation
Adding a New Feature Mode¶
- Implement feature extractor in
src/protocol_re/clustering/ - Add mode to
scripts/04_discover_families.py - Update documentation
- Add tests
- Update README with usage examples
Adding a New Semantic Role¶
- Update taxonomy in
src/protocol_re/inference/semantic_labeling.py - Add detection logic
- Update
schema/protocol_model.schema.json - Update exporters to handle new role
- Add tests
Testing¶
Running Tests¶
# Set Python path
export PYTHONPATH=src
# Run all tests
pytest tests/
# Run specific test file
pytest tests/test_logging.py
# Run with coverage
pytest --cov=src/protocol_re tests/
Writing Tests¶
- Place tests in
tests/directory - Name test files
test_*.py - Use descriptive test function names
- Include docstrings explaining what is tested
- Use fixtures for common setup
Example:
def test_boundary_detection_basic():
"""Test basic boundary detection on simple messages."""
messages = create_test_messages()
boundaries = detect_boundaries(messages)
assert len(boundaries) > 0
assert boundaries[0].offset == 0
Updating Documentation¶
- Update relevant
.mdfiles indocs/ - Keep README.md in sync with major changes
- Update docstrings in code
- Add examples for new features
- Update architecture diagrams if needed
Pull Request Process¶
- Update documentation - Document new features or changes
- Add tests - Include tests for new functionality
- Update CHANGELOG - Add entry describing changes
- Check code style - Ensure PEP 8 compliance
- Run tests - Verify all tests pass
- Update README - If adding major features
- Create Pull Request - With clear description and examples
Reporting Bugs¶
Before Reporting¶
- Check existing issues
- Verify with latest version
- Collect diagnostic information
Bug Report Template¶
## Description
Clear description of the bug
## Steps to Reproduce
1. Step one
2. Step two
3. ...
## Expected Behavior
What should happen
## Actual Behavior
What actually happens
## Environment
- OS: [e.g., Ubuntu 22.04]
- Python version: [e.g., 3.10.5]
- TShark version: [e.g., 4.2.2]
- Package version: [e.g., 1.0.0]
## Additional Context
- Error messages
- Log files
- PCAP characteristics
- Configuration used
License¶
By contributing, you agree that your contributions will be licensed under the MIT License.
Questions?¶
- Open an issue for questions
Recognition¶
Contributors will be recognized in: - CONTRIBUTORS.md file - Release notes - Project documentation
Thank you for contributing!