← Back to Pull requests

fix(seguranca): sonda de saude publica minima e diagnostico so com credencial (etapa 035) #250

Open
unknown opened this pull request with 250 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 26, 2026 03:21 UTC
Author

Causa

supabase/functions/health/index.ts não verificava nada (etapa 035 do plano, achado G12-4). A cada chamada anônima ele: consultava organizations, gastava uma consulta paga ao Google Places (places:searchText), gravava um registro em health_checks e devolvia quais segredos estavam ausentes.

Correção

Sem credencial de serviço → apenas {status:ok,timestamp:...}, sem consulta, sem custo e sem gravação. Com isCronAuthorized → diagnóstico completo como antes (banco, scraper, Places API, AI gateway), com o registro em health_checks.

Escolhi credencial de serviço em vez de sessão de administrador porque não existe chamador que precise do corpo completo: git grep functions/v1/health em src/, e2e/, scripts/, .github/ e supabase/ → 0 ocorrências; só docs/prod-readiness.md:84 registra a chamada manual. Não há página /status no repositório.

Verificação

Harness Deno com globalThis.fetch mockado (contando URL e insert):

| Caso | patch | ab29fc22 (main) |
| --- | --- | --- |
| GET anônimo | 200 {status:ok} — 0 chamadas externas, 0 inserts | 200 completo — 5 chamadas (banco, scraper, Places, AI) + 1 insert |
| GET com credencial de serviço | 200 com database, gmaps_api, google_places_api, ai_gateway — 5 chamadas, 1 insert | igual |
| OPTIONS | 200 sem nenhuma chamada | igual |

deno check: os 2 erros (note não existe em HealthCheckResult, linhas 86 e 89) são herdados do main — mesmos 2 erros, mesmas causas, antes e depois do patch.

Escopo

supabase/functions/health/index.ts + ledger. Sem migration.
<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/adm01-debug/promo_lux_v2/pull/250" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->

Diff: 250 lines (+187 / -63) across 3 files Reviewer: devin-ai-integration[bot] Review duration: 6m
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.39) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 250 lines diff across 3 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
42%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.331
Real PR Conversation Timeline
1 comments
"Review active on #250"
general weight: 0.35
Assignees
Unassigned
Labels
risk: low confidence: 43.0% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.0% (MEDIUM) · Higher = larger blast radius
39.0%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 43.0% · Lower = rushed or shallow review
43.0%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 22.2% · Safe to merge
22.2%