Thank you for your interest in contributing to agent-audit! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- Making Changes
- Testing
- Submitting Changes
- Adding Rules
- Style Guide
This project follows the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.
Look for issues labeled good first issue — these are beginner-friendly tasks.
| Type | Description |
|---|---|
| Bug Fixes | Fix incorrect behavior or crashes |
| New Rules | Add detection rules for new vulnerability patterns |
| Documentation | Improve docs, fix typos, add examples |
| Tests | Add test coverage for existing features |
| Features | Add new capabilities (discuss first in an issue) |
- Python 3.9+
- Poetry 1.8+
- Git
# Clone the repository
git clone https://github.com/HeadyZhang/agent-audit.git
cd agent-audit
# Install dependencies
cd packages/audit
poetry install
# Verify installation
poetry run agent-audit --version# Run all tests
poetry run pytest ../../tests/ -v
# Run with coverage
poetry run pytest ../../tests/ -v --cov=agent_audit --cov-report=term-missing
# Run specific test file
poetry run pytest ../../tests/test_scanners/test_python_scanner.py -vpoetry run mypy agent_audit/poetry run ruff check .
poetry run black --check .- Fork the repository
- Create a branch from
master:git checkout -b feat/your-feature-name
- Make changes following the style guide
- Test your changes
- Commit with conventional commit messages
- Push to your fork
- Open a Pull Request
| Prefix | Use Case |
|---|---|
feat/ |
New features |
fix/ |
Bug fixes |
docs/ |
Documentation changes |
test/ |
Test additions |
refactor/ |
Code restructuring |
Follow Conventional Commits:
feat: add AGENT-054 rule for unsafe deserialization
fix: correct false positive in AGENT-004 for Pydantic fields
docs: update RULES.md with new CWE mappings
test: add fixtures for MCP config validation
tests/
├── fixtures/ # Test input files
│ ├── vulnerable_agents/ # Python files with known vulnerabilities
│ └── mcp_configs/ # MCP config test cases
├── test_scanners/ # Scanner unit tests
├── test_cli/ # CLI command tests
├── test_analysis/ # Semantic analysis tests
└── benchmark/ # Accuracy benchmarks
Every new rule or feature needs tests:
# tests/test_scanners/test_your_rule.py
import pytest
from agent_audit.scanners.python_scanner import PythonScanner
class TestYourRule:
def test_detects_vulnerability(self, tmp_path):
"""Rule should detect the vulnerable pattern."""
code = """
@tool
def vulnerable_function(input: str):
eval(input) # Should trigger AGENT-XXX
"""
test_file = tmp_path / "test.py"
test_file.write_text(code)
scanner = PythonScanner()
results = scanner.scan(test_file)
assert any(r.pattern_type == "your_pattern" for r in results)
def test_no_false_positive(self, tmp_path):
"""Rule should not flag safe code."""
code = """
@tool
def safe_function(input: str):
return input.upper() # Should NOT trigger
"""
test_file = tmp_path / "test.py"
test_file.write_text(code)
scanner = PythonScanner()
results = scanner.scan(test_file)
assert not any(r.pattern_type == "your_pattern" for r in results)- Tests pass (
poetry run pytest) - Type checks pass (
poetry run mypy agent_audit/) - Linting passes (
poetry run ruff check .) - Documentation updated (if applicable)
- CHANGELOG.md updated (for user-facing changes)
- Commit messages follow conventional commits
## Summary
Brief description of changes.
## Changes
- Added X
- Fixed Y
- Updated Z
## Testing
How did you test these changes?
## Related Issues
Fixes #123- Create YAML definition in
rules/builtin/ - Implement detection in the appropriate scanner
- Add test fixtures in
tests/fixtures/ - Write tests in
tests/test_scanners/ - Update documentation in
docs/RULES.md
- Use the next available AGENT-XXX number
- Check existing rules to avoid conflicts
- Rule IDs are permanent once assigned
- Formatter: Black (line length 100)
- Linter: Ruff
- Type hints: Required on all public functions
- Docstrings: Google style for public methods
- Use 2-space indentation
- Quote strings with special characters
- Include all required fields
- Use GitHub-flavored Markdown
- Include code examples
- Keep line length under 100 characters
- Open a Discussion
- Check existing Issues
- Read the Architecture docs
Thank you for contributing to agent-audit!