feat(chat): implement spam protection and profanity filter
Add comprehensive message validation with three protection mechanisms: 1. Rate Limiting: 10 messages per minute per user 2. Duplicate Detection: Prevents sending identical messages within 1 minute 3. Profanity Filter: Blocks inappropriate language (English + Polish) Implementation: - New messageValidation.js middleware with validateMessage() function - Integrated into both event chat and match chat handlers - Uses bad-words library (v2.0.0 for CommonJS compatibility) - In-memory tracking with automatic cleanup every 5 minutes - User-friendly error messages for each validation type Technical details: - Rate limit: 10 msg/min sliding window - Duplicate check: Last 5 messages within 60s window - Profanity: bad-words + 11 Polish words - Memory management: Periodic cleanup of expired data
This commit is contained in:
16
backend/package-lock.json
generated
16
backend/package-lock.json
generated
@@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-ses": "^3.930.0",
|
||||
"@prisma/client": "^5.8.0",
|
||||
"bad-words": "^2.0.0",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"cookie-parser": "^1.4.7",
|
||||
"cors": "^2.8.5",
|
||||
@@ -2863,6 +2864,21 @@
|
||||
"@babel/core": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bad-words": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bad-words/-/bad-words-2.0.0.tgz",
|
||||
"integrity": "sha512-NsfaHcGgNsPTlWl54HrXawEfsJ5TLcIVa5KQcMoGzQTycCECcYfcGRWwjuxdYz7PbgarFl9Epv/+qT5JV+oBtA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"badwords-list": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/badwords-list": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/badwords-list/-/badwords-list-1.0.0.tgz",
|
||||
"integrity": "sha512-oWhaSG67e+HQj3OGHQt2ucP+vAPm1wTbdp2aDHeuh4xlGXBdWwzZ//pfu6swf5gZ8iX0b7JgmSo8BhgybbqszA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"dev": true,
|
||||
|
||||
Reference in New Issue
Block a user