-
-
Notifications
You must be signed in to change notification settings - Fork 0
Development Guide
Ryan edited this page Jul 18, 2026
·
1 revision
Standards, workflow, and tooling for contributing to Apotropaios.
Every commit must pass:
make typecheck # mypy --strict: 0 errors / 35 files
make test # pytest: 322/322 passing
make security-scan # 6 static pattern checks passinggit clone https://github.com/Sandler73/Apotropaios-Firewall-Manager-Python-Variant.git
cd Apotropaios-Firewall-Manager-Python
make dev-setup && source .venv/bin/activate
make check # Full CI verification- Type annotations: Full annotations on every function (params + return type)
-
from __future__ import annotations: At top of every module - Docstrings: Google-style on all public functions/classes with Args/Returns/Raises
- Module headers: File, Project, Synopsis, Description, Notes, Version
-
No
shell=True: All subprocess calls use list-form arguments -
Capture stderr:
capture_output=Trueon all subprocess calls -
Validate input: Through
core/validation.pybefore any use -
Atomic writes: temp →
os.replace()→os.chmod(0o600)for persistent data -
Thread safety:
threading.Lockon shared mutable state - Layer ordering: No upward imports (core → detection → backends → engine → UI)
- No stubs: Every function fully implemented when committed (Lesson PY-003)
# CORRECT -- full annotations, list-form subprocess
def validate_port(value: str) -> int:
"""Validate a TCP/UDP port number.
Args:
value: String representation of port number.
Returns:
Validated port as integer.
Raises:
ValidationError: If port is invalid.
"""
port = int(value)
if not (1 <= port <= 65535):
raise ValidationError(f"Port out of range: {port}")
return port
# WRONG -- missing types, shell=True
def validate_port(value):
return int(value)| Type | Convention | Example |
|---|---|---|
| Modules | snake_case.py | os_detect.py |
| Classes | PascalCase | IptablesBackend |
| Functions | snake_case | validate_port |
| Constants | UPPER_SNAKE | TERMINAL_ACTIONS |
| Private | _leading | _build_match_args |
| Singletons | lower_snake | rule_index |
make test # Full: lint + unit + integration + security
make test-quick # Unit only (fast loop)
make test-validation # Individual module
make test-report # Per-file breakdown
make test-coverage # HTML coverage reportRequirements for PRs:
- New feature → unit tests (normal + error paths)
- Bug fix → regression test
- New validator → valid + invalid input tests
- New CLI command → subprocess integration test
- Create
firewall/newbackend.py, subclassFirewallBackend - Implement all 12 abstract methods
- Register:
register_backend(_instance)at module level - Add to
SUPPORTED_FIREWALLSin constants.py - Add detection in fw_detect.py
- Import in cli.py
_initialize() - Add tests, update docs
-
make checkmust pass
feat(scope): description
fix(scope): description
docs(scope): description
test(scope): description
Apotropaios Firewall Manager -- Python Variant · Home · Quick Start · Architecture · Security · Bash Variant
Apotropaios -- Python Variant
Getting Started
Architecture
Operations
Project
35 files · 14,545 lines · 322 tests