Compare commits

...

9 Commits

Author SHA1 Message Date
6eda77e84c feat: add preprod URL to CORS allowed origins
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 17:44:36 +01:00
c7019550c1 Merge dev into preprod: corrections vulnérabilités et warnings 2025-12-06 17:05:58 +01:00
a419a9f42a fix: use BRANCH_NAME env var for proper branch detection in Jenkins
git rev-parse --abbrev-ref HEAD returns 'HEAD' in detached HEAD mode (Jenkins checkout).
Use BRANCH_NAME (Multibranch Pipeline) or GIT_BRANCH as fallback.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 16:27:59 +01:00
f348918b79 chore: trigger preprod build 2025-12-05 15:48:39 +01:00
26914469d3 Merge dev into preprod: update game contest dates and security fixes 2025-12-05 15:30:40 +01:00
17a9dc7b22 fix: secure email regex against ReDoS vulnerability
- Replace vulnerable regex with bounded quantifiers
- Add email length check (max 254 chars per RFC 5321)
- Fixes SonarQube security hotspot S5852

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 15:39:27 +01:00
e480c7ee1e chore: trigger preprod build 2025-12-04 01:42:15 +01:00
5eba6de570 revert: remove auto-init database feature
- Remove auto-init-db.js script
- Restore original index.js without database initialization

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 01:24:19 +01:00
83b74ee0c1 chore: trigger preprod pipeline 2025-12-04 01:08:56 +01:00
2 changed files with 12 additions and 18 deletions

4
Jenkinsfile vendored
View File

@ -67,7 +67,9 @@ pipeline {
stage('🧭 Init - Détection environnement') {
steps {
script {
def currentBranch = sh(script: "git rev-parse --abbrev-ref HEAD", returnStdout: true).trim()
// Utiliser BRANCH_NAME (Multibranch Pipeline) ou GIT_BRANCH (fallback)
// git rev-parse --abbrev-ref HEAD retourne "HEAD" en detached HEAD mode
def currentBranch = env.BRANCH_NAME ?: env.GIT_BRANCH?.replaceAll('origin/', '') ?: sh(script: "git rev-parse --abbrev-ref HEAD", returnStdout: true).trim()
echo "🧭 Branche détectée : ${currentBranch}"
if (["dev", "preprod", "main"].contains(currentBranch)) {

View File

@ -7,7 +7,6 @@ import config from "./src/config/env.js";
import { pool } from "./db.js";
import { errorHandler } from "./src/middleware/errorHandler.js";
import { metricsMiddleware } from "./src/middleware/metrics.js";
import { initDatabase } from "./scripts/auto-init-db.js";
// Import routes
import authRoutes from "./src/routes/auth.routes.js";
@ -26,14 +25,19 @@ app.use(
cors({
origin: function (origin, callback) {
const allowedOrigins = [
// Localhost
"http://localhost:3000",
"http://localhost:3001",
"http://localhost:3002",
"http://localhost:3003",
"http://localhost:3004",
"http://localhost:3005",
// Production
"https://dsp5-archi-o24a-15m-g3.fr",
"https://dev.dsp5-archi-o24a-15m-g3.fr"
// Dev
"https://dev.dsp5-archi-o24a-15m-g3.fr",
// Preprod
"https://preprod.dsp5-archi-o24a-15m-g3.fr"
];
// Autoriser les requêtes sans origin (Postman, curl, etc.)
if (!origin) return callback(null, true);
@ -108,19 +112,7 @@ export default app;
// Lancement serveur (seulement si pas importé par les tests)
if (process.env.NODE_ENV !== 'test') {
const PORT = config.server.port;
// Initialiser la base de données avant de lancer le serveur
initDatabase()
.then(() => {
app.listen(PORT, "0.0.0.0", () => {
console.log(`🚀 Backend lancé sur 0.0.0.0:${PORT}`);
});
})
.catch((error) => {
console.error('❌ Erreur lors de l\'initialisation de la base de données:', error);
// Lancer le serveur quand même pour permettre le debug
app.listen(PORT, "0.0.0.0", () => {
console.log(`🚀 Backend lancé sur 0.0.0.0:${PORT} (sans init DB) ⚠️`);
});
});
app.listen(PORT, "0.0.0.0", () => {
console.log(`🚀 Backend lancé sur 0.0.0.0:${PORT}`);
});
}