feat: Enhance security and validation in backend

- Added helmet for security headers and configured content security policy
- Implemented CORS with a whitelist for allowed origins
- Introduced express-validator for input validation in API endpoints
- Set request size limits to prevent DoS attacks
- Added global error handling and 404 response
- Updated TypeScript configuration to use node16 module resolution
- Improved Docker Compose configuration for security and resource limits
- Created a comprehensive .env.example for environment configuration
- Implemented automated security scans in CI/CD with Trivy
- Added cleanup script for debugging ports
- Established a detailed security policy document
This commit is contained in:
2025-12-01 08:37:35 +01:00
parent b13e7d1228
commit 4a6b4a0ae8
20 changed files with 1296 additions and 764 deletions

86
.vscode/launch.json vendored
View File

@@ -2,71 +2,49 @@
"version": "0.2.0",
"configurations": [
{
"name": "🚀 Debug Backend",
"type": "node",
"request": "launch",
"runtimeExecutable": "npx",
"runtimeArgs": [
"ts-node-dev",
"--respawn",
"--transpile-only",
"--no-notify"
],
"args": ["src/index.ts"],
"cwd": "${workspaceFolder}/backend",
"env": {
"NODE_ENV": "development"
},
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
"sourceMaps": true,
"restart": true,
"outputCapture": "std",
"presentation": {
"group": "fullstack",
"panel": "new"
},
"postDebugTask": "🛑 Terminate All Development Processes"
},
{
"name": "🌐 Debug Frontend (Chrome)",
"name": "Debug Vite",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/frontend/src",
"skipFiles": ["<node_internals>/**"]
"webRoot": "${workspaceFolder}/Client",
"skipFiles": ["<node_internals>/**"],
"preLaunchTask": "Start Vite (after backend ready)"
},
{
"name": "🔧 Debug Frontend (Edge)",
"type": "msedge",
"name": "Debug Backend",
"type": "node",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/frontend/src",
"runtimeExecutable": "npx",
"args": ["tsx", "watch", "--inspect=9229", "./src/index.ts"],
"cwd": "${workspaceFolder}/Server",
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
"preLaunchTask": "Clean Debug Ports",
"envFile": "${workspaceFolder}/Server/.env",
"env": {
"PORT": "3001"
}
},
{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/Server/node_modules/jest/bin/jest.js",
"args": [
"--config=Server/tests/jest.config.cjs",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": ["<node_internals>/**"]
}
],
"compounds": [
{
"name": "🚀🌐 Debug Full Stack (Chrome)",
"preLaunchTask": "🌐 Frontend",
"configurations": ["🚀 Debug Backend", "🌐 Debug Frontend (Chrome)"],
"stopAll": true,
"presentation": {
"hidden": false,
"group": "fullstack",
"order": 1
}
},
{
"name": "🚀🔧 Debug Full Stack (Edge)",
"preLaunchTask": "🌐 Frontend",
"configurations": ["🚀 Debug Backend", "🔧 Debug Frontend (Edge)"],
"stopAll": true,
"presentation": {
"hidden": false,
"group": "fullstack",
"order": 2
}
"name": "Compound Debug",
"configurations": ["Debug Vite", "Debug Backend"]
}
]
}