Skip to content

Commit 2479e48

Browse files
JanKoehnleinroboquat
authored andcommitted
[db] use blocklist to filter team names
1 parent 8d20205 commit 2479e48

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

components/gitpod-db/src/typeorm/team-db-impl.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* See License-AGPL.txt in the project root for license information.
55
*/
66

7+
import { list as blocklist } from "the-big-username-blacklist";
78
import { Team, TeamMemberInfo, TeamMemberRole, TeamMembershipInvite, User } from "@gitpod/gitpod-protocol";
89
import { inject, injectable } from "inversify";
910
import { TypeORM } from "./typeorm";
@@ -95,6 +96,9 @@ export class TeamDBImpl implements TeamDB {
9596
throw new Error('Please choose a team name containing only letters, numbers, -, _, \', or spaces.');
9697
}
9798
const slug = name.toLocaleLowerCase().replace(/[ ']/g, '-');
99+
if (blocklist.indexOf(slug) !== -1) {
100+
throw new Error('Creating a team with this name is not allowed');
101+
}
98102
const userRepo = await this.getUserRepo();
99103
const existingUsers = await userRepo.query('SELECT COUNT(id) AS count FROM d_b_user WHERE fullName LIKE ? OR name LIKE ?', [ name, slug ]);
100104
if (Number.parseInt(existingUsers[0].count) > 0) {

0 commit comments

Comments
 (0)