Contributing Guide¶
Thank you for your interest in contributing to opnDossier! This guide will help you get started with development and understand our contribution process.
Development Environment Setup¶
Prerequisites¶
- Go 1.26+
- Git with GPG signing configured
- Just - Task runner (required for CI-equivalent checks)
- golangci-lint - Go linter (latest version recommended)
- pre-commit - Git hook framework
Getting Started¶
-
Fork the repository on GitHub
-
Clone your fork locally:
- Install dependencies and set up pre-commit hooks:
- Run tests to ensure everything works:
- Run all quality checks (CI-equivalent):
Development Workflow¶
Code Organization¶
The project follows standard Go conventions:
cmd/- CLI commands (Cobra framework)internal/- Internal packagescfgparser/- XML parsing and validationconfig/- Configuration management (Viper)converter/- Data conversion and report generationcompliance/- Plugin interfacesplugins/- Compliance plugin implementations (stig, sans, firewall)audit/- Audit engine and plugin managementdisplay/- Terminal display formattingexport/- File export functionalitylogging/- Structured logging (wrapscharmbracelet/log)progress/- CLI progress indicatorsvalidator/- Configuration validationpkg/- Public API packagesmodel/- Platform-agnostic CommonDevice domain modelparser/- Factory + DeviceParser interfaceopnsense/- OPNsense parser + schema→CommonDevice converter
schema/opnsense/- Canonical OPNsense XML data model structsdocs/- Documentationtestdata/- Test fixtures and sample configuration files
Making Changes¶
- Create a feature branch:
-
Make your changes following our development standards and the coding standards in AGENTS.md
-
Add tests for new functionality:
- Run benchmarks if modifying parser performance:
- Run linting:
- Run all CI-equivalent checks before committing:
Parser Development¶
When modifying parsing or conversion logic:
pkg/parser/-- Factory andDeviceParserinterface (public API)pkg/parser/opnsense/-- OPNsense parser and schema-to-CommonDevice converterpkg/schema/opnsense/-- Canonical OPNsense XML schema structspkg/model/-- Platform-agnostic CommonDevice domain modelinternal/cfgparser/-- Low-level XML parsing and validation- Test with sample files in
testdata/ - Add benchmarks for performance-critical changes
- Preserve backward compatibility in the
DeviceParserinterface
Testing¶
We maintain several types of tests:
- Unit tests: Test individual functions and methods
- Integration tests: Test complete workflows end-to-end
- Golden file tests: Snapshot tests using
sebdah/goldie/v2 - Performance tests: Benchmarks for parser memory and speed
- Error handling tests: Verify proper error reporting
Run specific test suites:
# All tests
just test
# Specific package
go test ./internal/cfgparser/
# Benchmarks only
go test -run=^$ -bench=. ./internal/cfgparser/
# With coverage
go test -cover ./...
# Race detection
just test-race
Commit Standards¶
Commit Message Format¶
Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
Scopes: (parser), (converter), (audit), (cli), (model), (plugin), (builder), (schema)
DCO Sign-off¶
All commits must include a DCO sign-off:
Pull Request Process¶
-
Before submitting:
-
Ensure
just ci-checkpasses (pre-commit hooks + lint + tests) - Update documentation if needed
-
Include tests for new functionality
-
PR Description:
-
Clearly describe what changes were made
- Reference any related issues
- Include examples of new functionality
-
Note any breaking changes
-
Review process:
-
All PRs require at least one review (human or CodeRabbit)
- CI must pass (golangci-lint, gofumpt, tests, CodeQL, Grype)
- Documentation updates may be requested
Coding Standards¶
Please follow the coding standards documented in AGENTS.md, which covers:
- Go coding conventions and naming
- Error handling patterns
- Logging with
charmbracelet/log - Thread safety patterns
- XML element presence detection
- Testing standards
Performance Considerations¶
This project processes potentially large XML files, so performance matters:
- Add benchmarks for significant algorithmic changes
- Consider memory allocation patterns
- Test with sample files of varying sizes in
testdata/ - The parser limits input to 10MB by default (
DefaultMaxInputSize)
Getting Help¶
- Check existing issues and documentation first
- Open an issue for bugs or feature requests
- Review AGENTS.md for detailed development standards
- Review the architecture documentation in
docs/development/
License¶
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.
Thank you for contributing to opnDossier!