Thank you for considering contributing to Stackdog Security! We welcome contributions from the community.
- Code of Conduct
- Getting Started
- Development Workflow
- Pull Request Guidelines
- Coding Standards
- Testing
- Documentation
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code.
# Fork the repository
git clone https://github.com/YOUR_USERNAME/stackdog
cd stackdog
# Add upstream remote
git remote add upstream https://github.com/vsilent/stackdog# Install Rust (if not installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install system dependencies (Ubuntu/Debian)
apt-get install libsqlite3-dev libssl-dev clang llvm pkg-config
# Copy environment file
cp .env.sample .env# Build the project
cargo build
# Run tests
cargo test --lib
# Run examples
cargo run --example usage_examples# Sync with upstream
git checkout main
git pull upstream main
# Create feature branch
git checkout -b feature/your-feature-name- Follow the TDD approach
- Keep commits small and focused
- Write clear commit messages
# Run all tests
cargo test --lib
# Run specific module tests
cargo test --lib -- events::
cargo test --lib -- rules::
# Run with coverage (requires cargo-tarpaulin)
cargo tarpaulin --all --out Html# Format code
cargo fmt --all
# Run clippy
cargo clippy --all
# Check for security issues
cargo auditgit add .
git commit -m "feat: add your feature description"git push origin feature/your-feature-nameThen create a Pull Request on GitHub.
Use Conventional Commits:
feat: add new feature
fix: fix bug in module
docs: update documentation
test: add tests for feature
refactor: refactor code
chore: update dependencies
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Tests added
- [ ] Tests pass
- [ ] Code formatted
## Checklist
- [ ] Code follows project guidelines
- [ ] Self-review completed
- [ ] Comments added where needed
- [ ] Documentation updated- Automated Checks - CI/CD must pass
- Code Review - At least 1 maintainer approval
- Testing - All tests must pass
- Documentation - Update docs if needed
- Follow Rust API Guidelines
- Use
cargo fmtfor formatting - Avoid
unwrap()in production code - Use descriptive variable names
//! Module documentation
//!
//! Detailed description
use anyhow::Result;
/// Struct documentation
pub struct MyStruct {
/// Field documentation
field: String,
}
impl MyStruct {
/// Create new instance
pub fn new() -> Result<Self> {
Ok(Self {
field: String::new(),
})
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_my_function() {
// Test implementation
}
}// Use anyhow for application code
use anyhow::{Result, Context};
pub fn my_function() -> Result<()> {
some_operation()
.context("Failed to perform operation")?;
Ok(())
}
// Use thiserror for library errors
use thiserror::Error;
#[derive(Error, Debug)]
pub enum MyError {
#[error("Operation failed: {0}")]
OperationFailed(String),
}We follow TDD methodology:
- Write failing test
- Run test (verify failure)
- Implement minimal code to pass
- Run test (verify pass)
- Refactor (keep tests green)
| Type | Location | Command |
|---|---|---|
| Unit tests | In source files | cargo test --lib |
| Integration tests | tests/ |
cargo test --test integration |
| Examples | examples/ |
cargo run --example |
| Benchmarks | benches/ |
cargo bench |
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_feature_works() {
// Arrange
let input = create_test_input();
// Act
let result = function_under_test(input);
// Assert
assert!(result.is_ok());
assert_eq!(result.unwrap(), expected_value());
}
}- Document all public APIs with
///comments - Include examples for complex functions
- Keep comments up-to-date
/// Calculate threat score for event
///
/// # Arguments
///
/// * `event` - Security event to score
///
/// # Returns
///
/// * `ThreatScore` - Score between 0-100
///
/// # Example
///
/// ```
/// let scorer = ThreatScorer::new();
/// let score = scorer.calculate_score(&event);
/// ```
pub fn calculate_score(&self, event: &SecurityEvent) -> ThreatScore {
// Implementation
}Update relevant documentation:
README.md- Main project overviewDEVELOPMENT.md- Development guideTESTING.md- Testing guideCHANGELOG.md- Version changes
- 🚨 eBPF program implementation
- 🚨 ML anomaly detection
- 🚨 Web dashboard (React/TypeScript)
- 📝 Documentation improvements
- 🧪 More test coverage
- 🔧 Performance optimization
- 📊 Grafana dashboards
- 📦 Package builds (deb, rpm)
- 🌐 Translations
- General questions: Gitter
- Bug reports: GitHub Issues
- Feature requests: GitHub Discussions
Every contribution, no matter how small, helps make Stackdog Security better.
🐕 Happy Coding!