Matriz de Serviços — #07 SQL Injection
Data: 2026-07-08
Legenda
| Símbolo | Significado |
|---|---|
| ✅ | Já usa IUserProvider — protegido automaticamente |
| 🔧 | Precisa migrar leitura direta → IUserProvider |
| ⬜ | Não afetado (não lê api-company-target) |
Matriz Completa
| Serviço | Schema source | Tipo de leitura | Queries Dapper | EF Core | DML | Cache key | Ação |
|---|---|---|---|---|---|---|---|
| cart | IUserProvider | Indireta | ~15 | ✅ | UPDATE | ✅ 2 | ✅ Nenhuma |
| checkout | IUserProvider | Indireta | ~17 | ✅ | UPDATE | — | ✅ Nenhuma |
| jobs | IUserProvider | Indireta | ~10 | ✅ | INSERT | — | ✅ Nenhuma |
| auth | JWT claim only | — | — | — | — | — | ⬜ Nenhuma |
| product | DatabaseConfig direto + IUserProvider | Tipo A | ~5 | ✅ dinamico | — | — | 🔧 Migrar DatabaseConfig.GetSchema() |
| store | IUserProvider + DatabaseConfig direto | Tipo A | ~7 | ✅ | INSERT, UPDATE, DELETE | ✅ 4 | 🔧 Migrar DatabaseConfig.GetSchema() |
| backoffice | IUserProvider + DatabaseConfig direto | Tipo A | ~9 | ✅ | INSERT | ✅ 3 | 🔧 Migrar DatabaseConfig.GetSchema() |
| integration | DatabaseConfig direto | Tipo A + B | — | ✅ | — | — | 🔧 Migrar DatabaseConfig.GetSchema() + 3 handlers |
| message | DatabaseConfig direto | Tipo A | — | ✅ | — | — | 🔧 Migrar DatabaseConfig.GetSchema() |
| payments-reports | Direto (6 locais) | Tipo A + B + C | ~17 | ✅ | — | — | 🔧 Migrar 6 pontos + DatabaseConfig |
| showcase | Direto (3 locais) | Tipo A + C | ~5 | ✅ | — | — | 🔧 Migrar 3 pontos + DatabaseConfig |
| bff | Propaga apenas | — | — | — | — | — | ⬜ Nenhuma (só repassa) |
Detalhamento por Serviço
✅ Serviços já protegidos (usam IUserProvider)
coezzion-service-cart
CartService.cs→_userProvider.GetSchemaName()ProductRepository.cs→ schema via parâmetro (do caller viaIUserProvider)CartRepository.cs→ schema via_userProviderAttendanceRepository.cs→ schema via_userProviderCacheStoreRepositoryDecorator.cs→ schema via_userProviderCacheUserReadRepositoryDecorator.cs→ schema via_userProvider
coezzion-service-checkout
ControlOperationRepository.cs→_userProvider.GetSchemaName()PaymentRepository.cs→_userProvider.GetSchemaName()CoreSqlRepository.cs→_userProvider.GetSchemaName()PaymentSqlRepository.cs→_userProvider.GetSchemaName()
coezzion-service-jobs
- Todos os repositórios usam
_userProvider.GetSchemaName()
🔧 Serviços que precisam de migração
coezzion-service-product (3 pontos)
| # | Arquivo | Linha | Tipo | Ação |
|---|---|---|---|---|
| 1 | Product.API/Configuration/DatabaseConfig.cs | 78 | Tipo A | Injetar IUserProvider via provider.GetService<IUserProvider>() |
| 2 | Product.API/gRPC/ProductAppService.cs | 31 | Tipo D | Middleware/interceptador gRPC que popula SchemaNameScopedWrapper |
| 3 | Product.API/Filters/CompanyTargetHeaderAttribute.cs | 66-70 | Filtro | Já popula SchemaNameScopedWrapper — após fix no UserProvider, o fallback (E) valida |
coezzion-service-store (2 pontos)
| # | Arquivo | Linha | Tipo | Ação |
|---|---|---|---|---|
| 1 | Store.API/Configuration/DatabaseConfig.cs | 79 | Tipo A | Injetar IUserProvider |
| 2 | Store.Infrastructure/Data/Repositories/SellerVacationRepository.cs | varia | Indireta | Já usa _userProvider.GetSchemaName() |
coezzion-service-backoffice (1 ponto)
| # | Arquivo | Linha | Tipo | Ação |
|---|---|---|---|---|
| 1 | Backoffice.API/Configuration/DatabaseConfig.cs | 100 | Tipo A | Injetar IUserProvider |
coezzion-service-integration (4 pontos)
| # | Arquivo | Linha | Tipo | Ação |
|---|---|---|---|---|
| 1 | Integration.API/Configuration/DatabaseConfig.cs | 95 | Tipo A | Injetar IUserProvider |
| 2 | Integration.Infrastructure/EventHandlers/PaymentCreatedEventHandler.cs | 22 | Tipo B | Injetar IUserProvider no handler |
| 3 | Integration.Infrastructure/EventHandlers/ChangeCartDataEventHandler.cs | 24 | Tipo B | Injetar IUserProvider no handler |
| 4 | Integration.Infrastructure/EventHandlers/UpdateStatusPaymentEventHandler.cs | 27 | Tipo B | Injetar IUserProvider no handler |
coezzion-service-message (1 ponto)
| # | Arquivo | Linha | Tipo | Ação |
|---|---|---|---|---|
| 1 | Message.API/Configuration/DatabaseConfig.cs | 44 | Tipo A | Injetar IUserProvider |
coezzion-service-payments-reports (6 pontos)
| # | Arquivo | Linha | Tipo | Ação |
|---|---|---|---|---|
| 1 | Payments.Reports.API/Configuration/DatabaseConfig.cs | 112 | Tipo A | Injetar IUserProvider |
| 2 | Payments.Reports.Infraestructure/Data/Repositories/PaymentRepository.cs | 293, 367 | Tipo C | Injetar IUserProvider no construtor |
| 3 | Payments.Reports.Infraestructure/Data/Repositories/Read/CartRepository.cs | 245, 322 | Tipo C | Injetar IUserProvider no construtor |
| 4 | Payments.Reports.Infraestructure/Data/Repositories/Read/IntegrationRepository.cs | 110 | Tipo C | Injetar IUserProvider no construtor |
| 5 | Payments.Reports.Infraestructure/Utils/CreateCodePaymentsForIntegrations.cs | 20 | Tipo B | Injetar IUserProvider |
| 6 | Payments.Reports.Infraestructure/EventHandlers/PaymentCreatedEventHandler.cs | 22 | Tipo B | Injetar IUserProvider |
coezzion-service-showcase (3 pontos)
| # | Arquivo | Linha | Tipo | Ação |
|---|---|---|---|---|
| 1 | ShowCase.Api/Configuration/DatabaseConfig.cs | 60 | Tipo A | Injetar IUserProvider |
| 2 | ShowCase.Infrastructure/Data/Repositories/Read/UserRepository.cs | 22 | Tipo C | Injetar IUserProvider no construtor |
| 3 | ShowCase.Infrastructure/Services/PushNotification/PushNotificationService.cs | 26 | Tipo C | Injetar IUserProvider |
⬜ Serviços não afetados
coezzion-service-auth
Usa apenas JWT claim schema — não lê o header api-company-target.
coezzion-service-bff
Repassa o header via HttpClientDelegatingHandlerSchema, mas não executa queries SQL diretamente.
Resumo de esforço
| Categoria | Quantidade | Esforço estimado |
|---|---|---|
Fix central (UserProvider) | 1 arquivo | ~15 linhas |
DatabaseConfig.GetSchema() | 8 arquivos | ~2 linhas cada |
| Event handlers | 5 arquivos | ~2 linhas cada |
| Repositórios (construtor) | 5 arquivos | ~3 linhas cada |
| gRPC | 1 arquivo | ~10 linhas (interceptador) |
| Total | 20 arquivos | ~80 linhas |