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 Romasiundf95fceed4b5
diff --git a/backend/apps/community/src/project/project.controller.ts b/backend/apps/community/src/project/project.controller.ts
index bf54a5c08..b209c3e7a 100644
--- a/backend/apps/community/src/project/project.controller.ts
+++ b/backend/apps/community/src/project/project.controller.ts
@@ -1061,9 +1061,20 @@ export class ProjectController {
}
if (projectDTO.origins !== undefined) {
- project.origins = projectDTO.origins
- ? (_map(projectDTO.origins, _trim) as string[])
- : []
+ if (!projectDTO.origins) {
+ project.origins = []
+ } else {
+ if (!Array.isArray(projectDTO.origins)) {
+ throw new BadRequestException('origins must be an array')
+ }
+
+ const MAX_ORIGINS_ITEMS = 1000
+ if (projectDTO.origins.length > MAX_ORIGINS_ITEMS) {
+ throw new BadRequestException('origins is too large')
+ }
+
+ project.origins = _map(projectDTO.origins, _trim) as string[]
+ }
}
if (projectDTO.ipBlacklist !== undefined) {