|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +## Project Overview |
| 4 | +SecObserve is an open-source vulnerability management system designed for software development and cloud environments. It aggregates security findings from various tools and provides a centralized platform for managing, analyzing, and tracking vulnerabilities. |
| 5 | + |
| 6 | +## Backend |
| 7 | + |
| 8 | +### Tech stack |
| 9 | + |
| 10 | +- **Backend**: Python 3.12+, Django 6, Django REST Framework |
| 11 | +- **Database**: Supports MySQL (via `pymysql`) and PostgreSQL (via `psycopg`) |
| 12 | +- **Task Queue**: Huey |
| 13 | +- **API Documentation**: OpenAPI 3 (via `drf-spectacular`) |
| 14 | +- **Web Server**: Gunicorn |
| 15 | +- **Package Management**: Poetry |
| 16 | + |
| 17 | +### Structure |
| 18 | + |
| 19 | +- `backend.application`: |
| 20 | + - `access_control`: Manages users, API tokens and authorization. |
| 21 | + - `authorization`: Implements RBAC (roles and permissions). |
| 22 | + - `background_tasks`: Functionality for tasks running in the background. |
| 23 | + - `commons`: Cross-cutting functions and data, including settings. |
| 24 | + - `constance`: Unused, is needed for a transition. |
| 25 | + - `core`: Core functionality around products and their observations. |
| 26 | + - `epss`: Enrichment of observations with Exploit Prediction Scoring System (EPSS) and exploitation data. |
| 27 | + - `import_observations`: Handles importing security observations from various parsers (e.g., Trivy, Snyk, ZAP, etc.). |
| 28 | + - `issue_tracker`: Integrates with external issue trackers (e.g., Jira, GitHub, GitLab). |
| 29 | + - `licenses`: Manages and tracks software licenses. |
| 30 | + - `metrics`: Provides metrics about observations and licenses. |
| 31 | + - `notifications`: Sends notifications to Slack, MS Teams and email for various events. |
| 32 | + - `rules`: Implements rules to automatically amend status, severity and priority of observations. |
| 33 | + - `vex`: Import and export of Vulnerability Exploitability eXchange (VEX) information. |
| 34 | +- `backend.config`: Configurations |
| 35 | +- `backend.templates`: Fixed content |
| 36 | + |
| 37 | +### Unit tests |
| 38 | + |
| 39 | +- Stored under `backend.unittests` with same structure as `application` |
| 40 | +- Test classes derived from `unittests.base_test_case.BaseTestCase` |
| 41 | +- Use `@patch` annotation for mocks |
| 42 | + |
| 43 | +### Development Workflow |
| 44 | + |
| 45 | +### Prerequisites |
| 46 | + |
| 47 | +- Python 3.12+ |
| 48 | +- Poetry for dependency management |
| 49 | + |
| 50 | +#### Setup and Running |
| 51 | + |
| 52 | +- **Install dependencies**: |
| 53 | + |
| 54 | + ```bash |
| 55 | + poetry install |
| 56 | + ``` |
| 57 | +- **Start development server** (including frontend): |
| 58 | + |
| 59 | + ```bash |
| 60 | + ./bin/dev.sh |
| 61 | + ``` |
| 62 | + |
| 63 | +#### Testing |
| 64 | + |
| 65 | +- **Unit tests**: |
| 66 | + ```bash |
| 67 | + ./bin/unittests.sh |
| 68 | + ``` |
| 69 | +- **Code Quality**: |
| 70 | + ```bash |
| 71 | + cd backend |
| 72 | + |
| 73 | + # Formatting |
| 74 | + black . |
| 75 | + isort. |
| 76 | + |
| 77 | + # Linting |
| 78 | + flake8 |
| 79 | + ./bin/run_pylint.sh |
| 80 | + |
| 81 | + # Type Checking |
| 82 | + ./bin/run_mypy.sh |
| 83 | + ``` |
| 84 | + |
| 85 | +### Key Patterns |
| 86 | + |
| 87 | +- **Service Layer**: Business logic should reside in `application.<app_name>.services`. |
| 88 | +- **API Layer**: REST endpoints are defined in `application.<app_name>.api`. |
| 89 | +- **Query Layer**: Database queries are abstracted in `application.<app_name>.queries`. |
| 90 | +- **Parsers**: Import logic for external tools is located in `application.import_observations.parsers`. |
| 91 | + |
| 92 | +### Coding Standards |
| 93 | + |
| 94 | +- **Line Length**: 120 characters (configured via `black`). |
| 95 | +- **Type Hinting**: Strongly encouraged throughout the codebase. |
| 96 | +- **Documentation**: Use docstrings for complex logic; otherwise, keep code self-documenting with clear identifiers. |
| 97 | + |
| 98 | +## Frontend |
| 99 | + |
| 100 | +### Tech Stack |
| 101 | +- **Framework**: React 19 with TypeScript |
| 102 | +- **UI Library**: Material-UI 7 with ECharts integration |
| 103 | +- **Admin Panel**: react-admin 5 (CRUD interfaces for data management) |
| 104 | +- **Build Tool**: Vite |
| 105 | +- **Styling**: Emotion (CSS-in-JS) |
| 106 | +- **Charts**: Chart.js with react-chartjs-2 |
| 107 | +- **Markdown**: MDXEditor, marked, markdown-to-jsx |
| 108 | +- **Diagrams**: Mermaid |
| 109 | +- **Authentication**: OIDC (via `react-oidc-context` and `oidc-client-ts`) |
| 110 | +- **Package Management**: npm |
| 111 | + |
| 112 | +### Structure |
| 113 | +- `frontend/src/`: |
| 114 | + - `access_control`: Manages users, API tokens and authorization. |
| 115 | + - `background_tasks`: Functionality for tasks running in the background. |
| 116 | + - `commons/`: Shared components, layout, and utilities |
| 117 | + - `layout/`: Main Layout, SubMenu, ListHeader |
| 118 | + - `custom_fields/`: Reusable field components |
| 119 | + - `settings/`: Application settings UI |
| 120 | + - `core`: Core functionality around products and their observations. |
| 121 | + - `dashboard`: Dashboard showing different metrics. |
| 122 | + - `import_observations`: Handles importing security observations from various parsers (e.g., Trivy, Snyk, ZAP, etc.). |
| 123 | + - `licenses`: Manages and tracks software licenses. |
| 124 | + - `metrics`: Provides metrics about observations and licenses. |
| 125 | + - `notifications`: Sends notifications to Slack, MS Teams and email for various events. |
| 126 | + - `rules`: Implements rules to automatically amend status, severity and priority of observations. |
| 127 | + - `types`: Declaration of environment variables. |
| 128 | + - `vex`: Import and export of Vulnerability Exploitability eXchange (VEX) information. |
| 129 | + |
| 130 | +### Key Patterns |
| 131 | +- **Pages**: List, Show, Create, and Edit components for each entity (aligned with react-admin patterns). |
| 132 | +- **Runtime Config**: `runtime-env-cra` library injects environment variables at build time. |
| 133 | + |
| 134 | +### Development Workflow |
| 135 | + |
| 136 | +#### Prerequisites |
| 137 | +- Node.js (compatible with Vite 8) |
| 138 | + |
| 139 | +#### Setup and Running |
| 140 | +1. **Install dependencies**: |
| 141 | + ```bash |
| 142 | + cd frontend |
| 143 | + npm install |
| 144 | + ``` |
| 145 | +2. **Start development server**: |
| 146 | + ```bash |
| 147 | + npm start |
| 148 | + ``` |
| 149 | +3. **Build for production**: |
| 150 | + ```bash |
| 151 | + npm run build |
| 152 | + ``` |
| 153 | + |
| 154 | +#### Code Quality |
| 155 | +```bash |
| 156 | +# Linting |
| 157 | +npm run lint |
| 158 | + |
| 159 | +# Formatting and import sorting (Prettier) |
| 160 | +prettier -w src |
| 161 | +``` |
| 162 | + |
| 163 | +### Coding Standards |
| 164 | +- **Line Length**: 120 characters (configured via `.prettierrc.json`). |
| 165 | +- **TypeScript**: Strict mode enabled; all components should be fully typed. |
| 166 | +- **Component Style**: Functional components with hooks; no class components. |
0 commit comments