-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[dashboard] Disallow team names that might conflict with dashboard URLs #5131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Looking at this now! 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const userRepo = await this.getUserRepo(); | ||
const existingUsers = await userRepo.query('SELECT COUNT(id) AS count FROM d_b_user WHERE fullName LIKE ? OR name LIKE ?', [ name, slug ]); | ||
if (existingUsers[0].count > 0) { | ||
throw new Error('A team cannot have the same name as an existing user'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Do we want to surface this kind of information? It seems this is privacy sensitive information, right? Maybe using a more generic message could be better? What do you think? 💭
throw new Error('A team cannot have the same name as an existing user'); | |
throw new Error('Team path is already in use'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not sure about the privacy aspect. If someone wants to create a team called "Jan Keromnes", and it fails, I'd be okay with the error message saying that a user is already called that name. 😋
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, user names come directly from GitHub or GitLab, where they're already public information anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think this something we could consider changing in the future but it should be fine shipping this as is for now! 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I'd love in the future is public Gitpod profiles, e.g. showcasing some public Gitpod stuff you'd like to share with the world. 🙂 Could give Gitpod more of a "social" vibe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the reasons I'd vote for making this more privacy-aware but should be fine to skip this for now.
@@ -15,6 +16,34 @@ import { DBTeamMembership } from "./entity/db-team-membership"; | |||
import { DBUser } from "./entity/db-user"; | |||
import { DBTeamMembershipInvite } from "./entity/db-team-membership-invite"; | |||
|
|||
const FORBIDDEN_SLUGS = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Thanks for extending the forbidden slugs here! 🌟
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we ensure this list does not drift w.r.t. the dashboard URLs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a perfect match is required at all times. The imported blocklist already contains a lot of teams names we wouldn't want to ever allow, and this complementary list ensures that current and potential near future dashboard paths aren't immediately taken by teams.
While a collision could still potentially happen in the more distant future, it's highly unlikely, and would be a sufficiently small problem that we can deal with it ad-hoc then.
'access-control', | ||
'account', | ||
'admin', | ||
'blocked', | ||
'from-referrer', | ||
'install-github-app', | ||
'integrations', | ||
'login', | ||
'new', | ||
'notifications', | ||
'oauth-approval', | ||
'plans', | ||
'preferences', | ||
'projects', | ||
'settings', | ||
'setup', | ||
'sorry', | ||
'start', | ||
'subscription', | ||
'teams', | ||
'upgrade-subscription', | ||
'usage', | ||
'variables', | ||
'workspaces', | ||
...(blocklist), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: What do you think of adding a few more slugs that could be useful in the near future?
For example, we could include snapshots
, prebuilds
, as well as branches
, issues
, pull-requests
, and merge-requests
. Your call! 🏓
@@ -4,6 +4,7 @@ | |||
* See License-AGPL.txt in the project root for license information. | |||
*/ | |||
|
|||
import { list as blocklist } from "the-big-username-blacklist"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Nice one! Thanks @corneliusludmann for also suggesting this in #4469 (comment). 🏀
Cool, thanks for the review! Will address your excellent suggestions. 🔝 /hold |
b8e485d
to
558f29b
Compare
[APPROVALNOTIFIER] This PR is APPROVED Approval requirements bypassed by manually added approval. This pull-request has been approved by: Associated issue: #4469 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/werft run 👍 started the job as gitpod-build-jx-disallow-bad-team-names.5 |
I believe all nits are addressed 😁 @gtsiolis please take another look when you have time 👀 /unhold |
@jankeromnes UX works like a charm. 🔮
|
Many thanks for the reviews! 🙌
Interpreting as /lgtm 😇 |
Thanks @jankeromnes for merging this and @csweichel for taking a look! 👀 |
Fixes #4469
How to test