|
| 1 | +# Contributing to AppSecOne |
| 2 | + |
| 3 | +Thank you for your interest in contributing to AppSecOne! This guide will help you get started. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Python 3.12 or higher |
| 10 | +- Git |
| 11 | + |
| 12 | +### Installation |
| 13 | + |
| 14 | +```bash |
| 15 | +git clone https://github.com/polprog-tech/AppSecOne.git |
| 16 | +cd AppSecOne |
| 17 | +python3 -m venv .venv |
| 18 | +source .venv/bin/activate |
| 19 | +python3 -m pip install -e ".[dev]" |
| 20 | +``` |
| 21 | + |
| 22 | +### Running the development server |
| 23 | + |
| 24 | +```bash |
| 25 | +appsecone serve --config appsecone.json --port 8080 --verbose |
| 26 | +``` |
| 27 | + |
| 28 | +### Running tests |
| 29 | + |
| 30 | +```bash |
| 31 | +# Full suite (464 tests) |
| 32 | +python3 -m pytest tests/ -q |
| 33 | + |
| 34 | +# With coverage |
| 35 | +python3 -m pytest --cov=appsecone --cov-report=term-missing |
| 36 | +``` |
| 37 | + |
| 38 | +### Linting & Formatting |
| 39 | + |
| 40 | +```bash |
| 41 | +# Check |
| 42 | +python3 -m ruff check src/ tests/ |
| 43 | + |
| 44 | +# Auto-fix |
| 45 | +python3 -m ruff check --fix src/ tests/ |
| 46 | + |
| 47 | +# Format |
| 48 | +python3 -m ruff format src/ tests/ |
| 49 | +``` |
| 50 | + |
| 51 | +## Project Structure |
| 52 | + |
| 53 | +``` |
| 54 | +src/appsecone/ |
| 55 | +├── domain/ # Pure domain models and enums (zero I/O) |
| 56 | +├── config/ # Configuration loading and validation |
| 57 | +├── fortify/ # Fortify SSC integration client |
| 58 | +│ ├── client/ # HTTP client, auth, endpoints |
| 59 | +│ └── mappers/ # DTO → domain model mapping |
| 60 | +├── persistence/ # Database layer (SQLite) |
| 61 | +├── application/ # Sync and query services (async) |
| 62 | +├── analysis/ # Trend analytics & historical snapshots |
| 63 | +├── presentation/ # Jinja2 renderer, view models, templates |
| 64 | +│ └── templates/ # HTML templates with design system |
| 65 | +├── web/ # FastAPI server, middleware, routes |
| 66 | +├── cli/ # Typer CLI commands |
| 67 | +├── i18n/ # Internationalization catalogs (EN, PL) |
| 68 | +│ └── locales/ # JSON translation files |
| 69 | +└── shared/ # Logging, networking, type aliases |
| 70 | +``` |
| 71 | + |
| 72 | +## Code Style |
| 73 | + |
| 74 | +- **Python 3.12+** features encouraged (`StrEnum`, type unions, f-strings) |
| 75 | +- **Ruff** for linting and formatting (config in `pyproject.toml`) |
| 76 | +- **Frozen dataclasses** for domain models — immutability by default |
| 77 | +- **Type hints** everywhere — no untyped public APIs |
| 78 | +- **Async** for all I/O operations (database, network, file system) |
| 79 | +- **CSS custom properties** for all design tokens — no hardcoded colors or spacing in templates |
| 80 | +- **No inline styles** — all visual styling via CSS classes |
| 81 | +- **CSP-safe JavaScript** — all scripts use nonce attributes, no inline event handlers |
| 82 | + |
| 83 | +## Making Changes |
| 84 | + |
| 85 | +1. Create a feature branch: `git checkout -b feature/your-feature` |
| 86 | +2. Make your changes |
| 87 | +3. Run tests: `python3 -m pytest tests/ -q` |
| 88 | +4. Run linter: `python3 -m ruff check src/ tests/` |
| 89 | +5. Verify no regressions in UX/UI: `python3 -m pytest tests/unit/presentation/ -q` |
| 90 | +6. Commit with a descriptive message |
| 91 | +7. Open a pull request |
| 92 | + |
| 93 | +## Architecture Principles |
| 94 | + |
| 95 | +- **Domain layer has zero I/O** — pure functions and frozen dataclasses only |
| 96 | +- **Application layer is async** — all database and network calls are awaited |
| 97 | +- **Presentation layer builds view models** — no business logic in templates |
| 98 | +- **Web layer is thin** — routes delegate to services, never contain business logic |
| 99 | +- **Config-driven policy** — release readiness rules live in JSON, not code |
| 100 | +- **Security by default** — CSP headers, CSRF protection, rate limiting, API key auth |
| 101 | + |
| 102 | +## Internationalization |
| 103 | + |
| 104 | +AppSecOne supports multiple languages. Translation catalogs live in `src/appsecone/i18n/locales/`. |
| 105 | + |
| 106 | +- Use `t('key.name')` in Jinja2 templates |
| 107 | +- Use `t('key', count=N)` for pluralization (keys: `.one`, `.other`, `.few` for Polish) |
| 108 | +- Always add keys to **both** `en.json` and `pl.json` |
| 109 | + |
| 110 | +## Reporting Issues |
| 111 | + |
| 112 | +- Use GitHub Issues for bug reports and feature requests |
| 113 | +- Include reproduction steps for bugs |
| 114 | +- Include expected vs actual behavior |
| 115 | +- For UI issues, include the browser, theme, and language used |
0 commit comments