Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Potential fix for pull request finding 'CodeQL / Loop bound injection'

Andrii Romasiunc13ba9de76c3
diff --git a/backend/apps/community/src/project/project.controller.ts b/backend/apps/community/src/project/project.controller.ts
index 7b98910e4..bf54a5c08 100644
--- a/backend/apps/community/src/project/project.controller.ts
+++ b/backend/apps/community/src/project/project.controller.ts
@@ -1067,9 +1067,20 @@ export class ProjectController {
}
if (projectDTO.ipBlacklist !== undefined) {
- project.ipBlacklist = projectDTO.ipBlacklist
- ? (_map(projectDTO.ipBlacklist, _trim) as string[])
- : []
+ if (!projectDTO.ipBlacklist) {
+ project.ipBlacklist = []
+ } else {
+ if (!Array.isArray(projectDTO.ipBlacklist)) {
+ throw new BadRequestException('ipBlacklist must be an array')
+ }
+
+ const MAX_IP_BLACKLIST_ITEMS = 1000
+ if (projectDTO.ipBlacklist.length > MAX_IP_BLACKLIST_ITEMS) {
+ throw new BadRequestException('ipBlacklist is too large')
+ }
+
+ project.ipBlacklist = _map(projectDTO.ipBlacklist, _trim) as string[]
+ }
}
if (projectDTO.countryBlacklist !== undefined) {