release: sprint 9 follow-up hardening y limpieza operativa#30
Merged
Conversation
Los docs se movieron a docs/ — corregir paths de ERP_CRM_Plan_v2.md, SPRINTS.md, RELEASE_CANDIDATE_CHECKLIST.md y DEPLOYMENT_RUNBOOK.md. Agregar CONTRIBUTING.md al árbol. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…ticas (#14) * hotfix: security hardening - middleware, RLS, triggers, índices, políticas - Agregar dependabot.yml para actualizaciones automáticas de dependencias - Agregar security.yml: dependency-review, gitleaks, CodeQL, npm audit - Agregar dast.yml: ZAP baseline scan semanal contra /login - Agregar dependency-review-config.yml: fail en severidad high - Migración 20260034: funciones helper RLS (can_access_*), índices de soporte, políticas narrowed en pdv/vitrinas/fotos/incidencias/storage, vistas analytics con security_invoker, generación idempotente de visitas - QueryErrorState: componente reutilizable para errores de query en admin - OfflineSessionGuard: aislamiento de sesión offline por usuario (PWA) - lib/storage/paths.ts: helper para rutas de fotos con extensión sanitizada Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: corregir errores de CI en hotfix/production-hardening - lib/offline/db.ts: agregar ensureOfflineSessionOwner para aislamiento de datos offline por sesión de usuario - security.yml: remover dependency-review (requiere GitHub Advanced Security), reemplazar rhysd/actionlint action por instalación CLI directa (el repo no expone un action.yml) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…torage
La nueva política fotos_visita_upload exige paths con el UID del usuario:
visitas/{uid}/{entityId}/{photoId}.ext
incidencias/{uid}/{entityId}/{photoId}.ext
Actualizar useVisita y useIncidencias para usar buildScopedPhotoPath en lugar
de paths hardcoded con visitaId/incidenciaId como primer segmento.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…eso a PDV La política anterior exigía can_access_pdv(pdv_id) siempre, incluso cuando visita_id estaba presente. Esto bloqueaba el INSERT porque can_access_pdv hace un JOIN recursivo que en ciertos contextos no resuelve correctamente. Nueva lógica: si visita_id está presente → can_access_visita() es suficiente. Si visita_id es NULL → can_access_pdv() para incidencias directas sobre el PDV. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…to-referencia La SELECT policy usando can_access_incidencia() causaba que INSERT+RETURNING fallara: la función SECURITY DEFINER selecciona FROM incidencias pero la SELECT policy se aplica al RETURNING antes de que la fila sea visible. Nueva SELECT policy: JOIN directo con visitas (sin función wrapper), preserva seguridad sin el problema de auto-referencia. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Las políticas de detalle_visita_insert, cobros_insert, fotos_select y
fotos_insert usaban can_access_visita() causando latencia en queries
durante el flujo de cobro, lo que generaba race conditions en los tests e2e.
La seguridad de acceso a fotos se garantiza via storage path
(visitas/{uid}/... enforced by buildScopedPhotoPath en el cliente y
las storage.objects policies que sí permanecen con can_access_photo_object).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e índices Las políticas que modificaban detalle_visita, cobros, fotos_visita, incidencias, garantías y storage rompían los tests e2e existentes. Se mantienen: funciones helper, índices, vistas analytics con security_invoker, y generación idempotente de visitas diarias. 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.
Resumen
Continuacion de la entrega de
release/sprint-9despues de#18.Este PR consolida el delta actual de la rama frente a
main, incluyendo hardening operativo y limpieza estructural del repo.Cambios principales
INTERNAL_CRON_SECRETValidacion local
npm run type-checknpm run lintnpm testnpm run buildNotas
#18); este PR captura el estado actual quemaintodavia no refleja.