Thank you for your interest in contributing to the XARF Python library! We welcome contributions from the community and appreciate your help in making this project better.
This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to admin@xarf.org.
If you find a bug, please create an issue on GitHub with the following information:
- Clear title and description of the issue
- Steps to reproduce the problem
- Expected behavior vs. actual behavior
- Code samples or test cases that demonstrate the issue
- Version of the library you're using
- Python version and operating system
We welcome feature requests! Please create an issue with:
- Clear description of the feature
- Use case explaining why this feature would be useful
- Example code showing how the feature might work
- Compatibility considerations with the XARF specification
We actively welcome pull requests! Here's how to contribute:
- Fork the repository and create your branch from
main - Make your changes following our coding standards
- Add tests for any new functionality
- Ensure all tests pass and coverage remains >80%
- Update documentation as needed
- Submit a pull request with a clear description of changes
- Python: 3.10 or higher
- Git: Latest stable version
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/xarf-python.git cd xarf-python -
Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -e ".[dev]"
-
Install pre-commit hooks:
pre-commit install
-
Run tests:
pytest
pytest— Run the test suitepytest --cov=xarf— Generate code coverage reportruff check xarf/— Lintruff check --fix xarf/— Auto-fix lint issuesruff format xarf/— Format coderuff format --check xarf/— Check code formattingmypy --strict xarf/— Run type checkingbandit -r xarf/— Security scanning
All contributions must maintain or improve test coverage:
- Coverage threshold: 80% overall — enforced by
pytest-cov - Unit tests: Required for all new functions and classes
- Integration tests: Required for parser and generator functionality
- Test file location: Tests should be in the
tests/directory - No schema mocking: tests must use real schemas loaded from the bundle
pytest # Run all tests
pytest -v # Verbose output
pytest --cov=xarf # With coverage report
pytest tests/test_parse.py # Run a specific fileWe use pytest. Example test structure:
from xarf import parse
def test_parse_valid_report() -> None:
result = parse({
# ... valid XARF data
})
assert not result.errors
assert result.report is not None
assert result.report.category == "connection"
assert result.report.type == "ddos"
def test_parse_returns_errors_for_invalid_data() -> None:
result = parse({})
assert len(result.errors) > 0- Language version: Python 3.10+
- Type annotations: required on all public functions and methods
- Docstrings: Google style for all public APIs (
Args:,Returns:,Raises:,Example:) - Strict mypy: all code must pass
mypy --strict xarf/
See pyproject.toml for the full ruff and mypy configuration.
- Functions / methods:
snake_case(e.g.,parse,create_report,create_evidence) - Constants:
UPPER_SNAKE_CASE(e.g.,SPEC_VERSION) - Classes:
PascalCase(e.g.,ParseResult,XARFReport,SchemaRegistry) - Type aliases:
PascalCase(e.g.,AnyXARFReport,ConnectionReport)
- One module per file for main components
- Related types grouped in category-specific files (
types_messaging.py, etc.) - Export from
__init__.pyfor public API — usexarf-javascript/src/index.tsas the reference for which names to expose
We use ruff for both formatting and linting. Configuration lives in pyproject.toml.
ruff format xarf/ # Auto-format
ruff format --check xarf/ # Check formatting
ruff check xarf/ # Lint
ruff check --fix xarf/ # Auto-fix linting issuesA pre-commit hook runs both automatically on staged files.
- Google-style docstrings for all public APIs
- Type annotations on all parameters and return values
- Inline comments for non-obvious logic
- README updates for new features
We follow the Conventional Commits specification:
<type>(<scope>): <subject>
<body>
<footer>
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoring without feature changestest: Adding or updating testschore: Maintenance tasks, dependency updates
feat(parser): add support for reputation/threat_intelligence reports
Implement Pydantic model and schema-driven validation for the
threat_intelligence report type. Includes shared test samples.
Closes #123
fix(schema_validator): deduplicate errors from master and core schemas
Errors reported by both the master schema and the core schema for the
same field were appearing twice in ValidationError lists.
Fixes #456
docs(readme): update schema management section
- Update documentation for any changed functionality
- Add tests covering your changes
- Ensure all tests pass:
pytest - Verify coverage:
pytest --cov=xarf - Check linting:
ruff check xarf/ - Verify formatting:
ruff format --check xarf/ - Run type checking:
mypy --strict xarf/ - Update CHANGELOG.md if applicable
- Create pull request with clear description
Your PR description should include:
- What: Brief description of changes
- Why: Motivation and context
- How: Implementation approach
- Testing: How you tested the changes
- Breaking changes: Any breaking changes (if applicable)
- Related issues: Link to related issues
All pull requests require review before merging:
- At least one approval from a maintainer
- All CI checks must pass
- No unresolved discussions
- Merge conflicts resolved
All implementations must conform to the XARF specification:
- Parse all required fields
- Validate data types correctly
- Support all standard report types
- Handle optional fields appropriately
- Implement proper error handling
- Maintain backward compatibility when possible
Releases are managed by maintainers:
- Version bumped following Semantic Versioning
- CHANGELOG.md updated with changes
- Git tag created for the version
- Package published to PyPI
- Documentation: Check the README and code comments
- Issues: Search existing issues or create a new one
- Discussions: Use GitHub Discussions for questions
- Email: Contact the maintainers at contact@xarf.org
By contributing to XARF Python Library, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to XARF! Your efforts help make abuse reporting more effective and standardized across the internet.