the-tip-top-backend/src/validations/newsletter.validation.js
soufiane a7f82b1215 fix: replace vulnerable email regex with safe alternatives
- Update isValidEmail in helpers.js with secure non-backtracking regex
- Use isValidEmail helper in auth.controller.js
- Use isValidEmail helper in contact.controller.js
- Replace regex with Zod .email() in newsletter.validation.js
- Fixes 5 SonarQube Security Hotspots for DoS via backtracking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 15:03:36 +01:00

34 lines
715 B
JavaScript

/**
* Schémas de validation avec Zod pour la newsletter
*/
import { z } from 'zod';
// Schéma pour l'abonnement à la newsletter
export const subscribeSchema = z.object({
body: z.object({
email: z
.string({
required_error: 'L\'email est requis',
})
.email('Format d\'email invalide')
.max(254, 'Email trop long'),
}),
});
// Schéma pour le désabonnement de la newsletter
export const unsubscribeSchema = z.object({
body: z.object({
email: z
.string({
required_error: 'L\'email est requis',
})
.email('Format d\'email invalide')
.max(254, 'Email trop long'),
}),
});
export default {
subscribeSchema,
unsubscribeSchema,
};