Tremendous refactoring leap from legacy 2.8/10. Production-hardened with specific residual technical debt.
Every custom module inspected across PHP classes, services, templates, routing, and Docker configs.
Cache-backed job volatility, sequential blocking I/O, SSRF surface in RSS image fetching, and plaintext secrets in key-value.
Exemplary resource cleanup (finally killSession), masked loggers, and typed dependency injection.
pleiade_global_config • Core Architectural Foundation (Socle)
Provides multi-tenant context (PleiadeContext), tenant repository (TenantManager), unified HTTP client proxy options (ProxyHelper), log masking (LogSanitizer), and automatic client-side CSRF tokens (pleiade.js).
- Centralized multi-tenancy: connectors no longer read raw cookies or CAS sessions manually.
LogSanitizerscrubbers protect against token leakage into watchdog logs.SecretFieldTraitprevents passwords/keys from re-rendering in admin HTML forms.pleiade.jsinjects mandatoryX-CSRF-Tokenheaders into every non-GET fetch/ajax request.
- Secrets stored unencrypted at rest: All tenant Zimbra keys, Oracle credentials, and Maarch tokens are stored in plain serialized format in the
key_valuetable (globalkey). Should be encrypted withsodium_crypto_secretbox. - Tenant save race condition:
TenantManager::save()reads all tenants into memory, updates, and writes all back. Simultaneous admin saves can overwrite changes.
api_glpi_pleiade • GLPI ITSM Connector
Communicates with GLPI REST API (GlpiService) to display assigned and group tickets. Best engineered integration module in the entire codebase.
- Guaranteed Session Termination: Uses
finally { $this->request('GET', $this->api('killSession')); }ensuring GLPI session limits are never exhausted. - Cached ticket results per user with configurable short TTL (60s default).
- Profile switching preference list (
super, technicien, self) is configurable without code changes. - Log outputs pass through
LogSanitizerto scrub tokens.
- 5 HTTP round trips per uncached poll: initSession → getFullSession → changeActiveProfile → search → killSession.
- Recommendation: Persist the GLPI session token in Redis/Tempstore across user requests within its TTL to avoid re-authenticating on every page load.
api_zimbra_pleiade • Zimbra SOAP Mail & Agenda Connector
Orchestrates Zimbra SOAP requests (ZimbraService) for inbox summaries, 30-day agenda views, full calendar views, and smart email replies.
- Replaced fragile Guzzle debug stdout scraping with official SOAP
AuthRequestXML envelopes. - Auth tokens cached in memory/APCu with 300s TTL. Reusable preauth URLs with
expires=0eradicated. - Calendar event titles, attendee names, and mail subjects sanitized with
Html::escape()preventing stored XSS.
- Legacy demoCalendar fallback:
demoCalendar()still fetches an external unauthenticated JSON URL if configured. Should be deleted from production code. - No batching on folder unread counts: Recursively walks the folder tree and computes mail counts in PHP memory instead of querying Zimbra folder counters directly.
pleiade_ai_selector • n8n AI Agent Orchestration
Connects municipal agents to asynchronous n8n AI workflows: folder/document summarization ("prismes"), conversational chat agent, and automatic email drafting.
- Database table for prismes with administrative UI (
PromptForm) replaces hardcoded prompt IDs. - Hardcoded prompt token removed; dynamic token validation via
X-Pleiade-Tokenheader. - n8n receives scoped transient tokens rather than master domain keys by default.
- CRITICAL RESILIENCE FLAW: Job states are saved in
cache.default! If an admin or deployment executesdrush crwhile an AI job is running in n8n, the job state is erased. When n8n completes and calls the webhook, Drupal throws a 404/403. Jobs MUST be stored in a persistent database table. - Backward-compatibility leak toggle: Settings form still includes checkboxes
send_zimbra_preauth_keyandsend_sso_cookiewhich restore credential leakage to n8n if activated.
api_user_pleiade • User Preferences & Directory Lookup
Manages favorites CRUD, layout ordering, application toggles, and FusionDirectory LDAP profile attribute lookup (PleiadeUserService).
- Privilege escalation eliminated: strict whitelist on
PREFERENCE_LISTSandPREFERENCE_FLAGS. user_preprocess_pageno longer serializes password hashes or token fields to client HTML.- Admin-only protection (
administer users) onuser_list_query.
- JSON preferences stored as text on User entity:
field_menu_orderandfield_dashboard_ordertrigger full entity saves and cache invalidations for minor UI drag-and-drops. - Recommendation: Move fast-changing UI ordering to Drupal's
user.dataservice to avoid rebuilding User entity caches.
datatable_pleiade • "Documents récents" Aggregator
Aggregates actionable items across i-Parapheur, Maarch Courrier, Nextcloud, and Ciril Finances into a single Tabulator table.
- Centralized table with status unification across financial, administrative, and GED tools.
- Safe field output escaping before JSON rendering.
- Service Locator Anti-Pattern:
DatatableController::documents_recents()invokes\Drupal::getContainer()dynamically instead of using standard constructor Dependency Injection. - Synchronous Microservice Blocking: Sequentially queries 4 enterprise backends. If one slows down, the entire widget blocks.
- Zero Caching: Header set to
no-store, private; any tab switch forces 4 backend queries again.
api_ciril_pleiade • Ciril Finances Oracle Integration
Executes direct PDO_OCI queries against Oracle schemas (CIVILGF, CIRIL) to retrieve purchase orders and invoices requiring signature or approaching payment deadlines.
- Leverages Ciril's native SQL permission procedures (
f_acces_exercice,f_acces_budget). - Configurable threshold warning days (
mandate_warning_days) replaces hardcoded '00141'.
- LogSanitizer Bypassed:
CirilServicedoes NOT usePleiadeLoggerTrait. It calls$this->logger->error($e->getMessage())directly, which can leak Oracle credentials in TNS error strings. - Unescaped TNS String: Host and SID are concatenated directly into
(DESCRIPTION=...)without alphanumeric validation, presenting a TNS injection surface.
module_actu_pleiade • RSS News & Feed Ingestion
Ingests RSS news feeds from SITIV, individual municipalities, and internal Drupal nodes into a unified carousel widget.
- Feed caching enabled with 1800s TTL per tenant; dead feeds cached for 300s to avoid repeated timeouts.
- Interleaving algorithm smoothly blends syndicate and local commune news.
- SSRF (Server-Side Request Forgery) in localImage():
localImage()blindly downloads image URLs found inside RSS<enclosure>and<img src>without validating against private/internal IP ranges (e.g. 127.0.0.1, 10.0.0.0/8). - Recommendation: Add IP address validation to reject non-routable private subnets prior to calling
$this->httpClient->request().
api_maarch_pleiade • Maarch Courrier GED Integration
Connects to Maarch Courrier REST API to extract incoming correspondence baskets for the authenticated agent.
- Replays user's native basket clauses (
@user_id, @my_entities_id) respecting Maarch ACLs. - Links use configurable dynamic pattern templates.
- Memory-heavy user lookup: If
field_maarchuseridis blank, it callsGET userswhich downloads the complete organization directory into memory. - Sequential basket queries: Loops over every basket making a separate POST request to
res/list.
api_parapheur_pleiade • i-Parapheur v5 Electronic Signature
OIDC code flow on LemonLDAP using the user's session cookie, Keycloak token exchange, and multi-desk folder querying.
- Automated token exchange with automatic 401 token refresh retry.
- OAuth client secret removed from default configuration files.
- Nested HTTP Loop: For every desk, for every state, it makes a synchronous GET call (up to 12 HTTP calls on cold load).
- Recommendation: Parallelize desk requests with Guzzle concurrent promises.
Devbox & Docker Infrastructure Stack
Unified container stack with automated first-boot installation, healthcheck probes, and multi-stage Debian slim builds.
- Image size reduced from 1.55 GB to 583 MB (multi-stage build).
- MariaDB 11.4 isolated to internal docker bridge with healthchecks.
setpriv --reuid=www-dataprevents root-owned Drush file generation.
- Admin password echoed to stdout: Entrypoint prints admin password to
docker logs. In production environments with log forwarders, this leaks credentials. - Apache MPM Prefork memory model: Prefork consumes ~80MB per worker. Moving to Nginx + PHP-FPM cuts memory by 60%.
Production Hardening Checklist & Action Plan
Persist AI Jobs in Database
Migrate AiJobManager job state storage from volatile cache.default to a custom database table to prevent 404/403 callback errors upon cache rebuilds.
SSRF Mitigation in Actu
Add an IP validator to ActuPleiadeService::localImage() to block outbound requests resolving to RFC1918 private subnets and localhost.
Async Guzzle Promises in Datatable
Refactor DatatableController to parallelize remote backend requests via Guzzle async promises, cutting load latency from 2.5s down to ~600ms.