Contributing
We welcome contributions to package-scan! This guide will help you get started.
Development Setup
Fork the repository on GitHub
Clone your fork:
git clone https://github.com/YOUR_USERNAME/package-scan.git cd package-scan
Create a virtual environment:
python3 -m venv venv source venv/bin/activate
Install in development mode:
pip install -e ".[dev]"
This installs all dependencies including testing and documentation tools.
Running Tests
Run all tests:
pytest
Run specific test file:
pytest tests/test_npm_adapter.py
Run with coverage:
pytest --cov=package_scan --cov-report=html
View coverage report:
open htmlcov/index.html
Code Style
We follow standard Python conventions:
PEP 8 for code style
Type hints where appropriate
Docstrings for public APIs
Clear, descriptive variable names
Testing Guidelines
All new features and bug fixes should include tests:
- Unit Tests
Test individual functions and classes in isolation
- Integration Tests
Test adapter scanning with real file fixtures
- Test Fixtures
Use
pytestfixtures for reusable test data
Example Test:
def test_scan_package_json(temp_project_dir, threat_db):
"""Test scanning package.json with vulnerable package."""
adapter = NpmAdapter(threat_db)
# Create test file
package_json = os.path.join(temp_project_dir, 'package.json')
with open(package_json, 'w') as f:
json.dump({'dependencies': {'left-pad': '1.3.0'}}, f)
# Run scan
findings = adapter.scan_project(temp_project_dir)
# Assert results
assert len(findings) == 1
assert findings[0].package_name == 'left-pad'
Adding New Adapters
To add support for a new ecosystem:
Create Adapter File
src/package_scan/adapters/new_adapter.pyImplement Interface
Inherit from
EcosystemAdapterand implement required methodsRegister Adapter
Add to
ADAPTER_REGISTRYinadapters/__init__.pyAdd Tests
Create
tests/test_new_adapter.pywith comprehensive testsAdd Fixtures
Create
examples/test-new/with sample project filesUpdate Documentation
Add to ecosystem list and architecture docs
See Architecture for detailed implementation guide.
Adding New Threats
To add a new threat database:
Create CSV File
threats/my-threat.csvUse Standard Format:
ecosystem,name,version npm,package-name,1.0.0 maven,group.id:artifact-id,2.0.0 pip,python-package,3.0.0
Test Loading:
package-scan --threat my-threat --list-affected-packages
Document Threat
Add description to README or threat-specific documentation
Documentation
Building Documentation
Build HTML documentation:
cd docs
make html
open build/html/index.html
Build for other formats:
make latexpdf # PDF via LaTeX
make epub # EPUB format
Documentation is written in reStructuredText (RST) and built with Sphinx.
Writing Documentation
Use clear, concise language
Include code examples
Add cross-references to related sections
Update API docs when changing function signatures
Pull Request Process
Create Feature Branch:
git checkout -b feature/my-new-feature
Make Changes
Write code
Add tests
Update documentation
Run Tests:
pytestCommit Changes:
git add . git commit -m "Add feature: description"
Push to Fork:
git push origin feature/my-new-feature
Open Pull Request
Go to GitHub repository
Click “New Pull Request”
Describe changes and motivation
Reference any related issues
Code Review
Address reviewer feedback
Update PR as needed
Ensure CI passes
Merge
Once approved, maintainers will merge your PR
Commit Message Guidelines
Use present tense (“Add feature” not “Added feature”)
Use imperative mood (“Move cursor to…” not “Moves cursor to…”)
Limit first line to 72 characters
Reference issues and PRs liberally
Examples:
fix: Handle empty package.json filesfeat: Add support for Cargo/Rust ecosystemdocs: Update installation instructionstest: Add tests for version range matching
Bug Reports
When reporting bugs, please include:
Package-scan version (
package-scan --version)Python version (
python --version)Operating system
Steps to reproduce
Expected vs actual behavior
Relevant error messages or logs
Sample files if possible
Feature Requests
When requesting features:
Describe the use case
Explain why existing features don’t solve the problem
Provide examples of how it would work
Consider implementation complexity
Code of Conduct
This project follows the Contributor Covenant Code of Conduct. Be respectful and inclusive in all interactions.
See CODE_OF_CONDUCT.md for full details.
Getting Help
Check documentation at https://package-scan.readthedocs.io
Search existing issues on GitHub
Open a new issue with the “question” label
Join discussions in GitHub Discussions
License
By contributing, you agree that your contributions will be licensed under the MIT License.