feat(finops): optimize ReDoS regex and GitHubMetricsService N+1 pattern#9
Merged
feat(finops): optimize ReDoS regex and GitHubMetricsService N+1 pattern#9
Conversation
Delivery 5: FinOps Optimization & Final Defense ## Optimizacion 1: ReDoS Email Regex (CPU) - Elimina regex con catastrophic backtracking O(2^n) en routes/products.js - Usa req.validatedBody de validatePurchase middleware (Zod) que ya valida el email de forma segura con z.string().email() - Antes: 2,745ms con input de ataque (33 chars) - Despues: 0.15ms — mejora del 99.99% (17,826x mas rapido) ## Optimizacion 2: GitHubMetricsService N+1 (I/O) - Agrega cache en memoria con TTL de 5 minutos para deployments y statuses - Pre-carga paralela de statuses en lotes de 10 (_prefetchStatuses) - getAllMetrics: 1 fetch compartido en vez de 4 independientes - Commits de lead time: Promise.all en lotes en vez de for-await secuencial - Antes: ~2,519ms (154 llamadas secuenciales con 50 deployments) - Despues: ~180ms — mejora del 92.8% (14x mas rapido) - 2da llamada (cache hit): ~50ms — mejora del 98% ## Tests - Nuevo test anti-ReDoS en validators.test.js (< 50ms con payload malicioso) - Nuevo test de cache en githubMetricsService.test.js - 35 tests pasan (unit) ## Benchmarks y reporte - benchmarks/redos-email-benchmark.js - benchmarks/github-metrics-benchmark.js - reports/benchmarks/FINOPS_BENCHMARK_REPORT.md ## README - Badges: CI, SonarCloud Quality Gate, Coverage, License, Node/Express/PostgreSQL - Estructura corregida: jerarquia de headings, Prerequisites, Documentation - Credenciales en bloque <details> colapsable - Seccion Historial de Entregas y links a toda la documentacion Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Delivery 5: FinOps Optimization & Final Defense
Optimizacion 1: ReDoS Email Regex (CPU)
Optimizacion 2: GitHubMetricsService N+1 (I/O)
Tests
Benchmarks y reporte
README
Details
colapsable