Skip to content

[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

Merged
merged 1 commit into from
Aug 10, 2021

Conversation

jankeromnes
Copy link
Contributor

@jankeromnes jankeromnes commented Aug 10, 2021

Fixes #4469

How to test

  1. Try to create a team called:
    • "workspaces" (or any other dashboard page)
    • "root" (or any other suspicious name)
    • the same as your user

@gtsiolis
Copy link
Contributor

gtsiolis commented Aug 10, 2021

Looking at this now! 👀

Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this @jankeromnes! 🔝

Works as expected! ✔️

Left some minor comments below.

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');
Copy link
Contributor

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? 💭

Suggested change
throw new Error('A team cannot have the same name as an existing user');
throw new Error('Team path is already in use');

Copy link
Contributor Author

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. 😋

Copy link
Contributor Author

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.

Copy link
Contributor

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! 🙈

Copy link
Contributor Author

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.

Copy link
Contributor

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 = [
Copy link
Contributor

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! 🌟

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Comment on lines 20 to 50
'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),
Copy link
Contributor

@gtsiolis gtsiolis Aug 10, 2021

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";
Copy link
Contributor

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). 🏀

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Aug 10, 2021

Cool, thanks for the review! Will address your excellent suggestions. 🔝

/hold

@jankeromnes jankeromnes force-pushed the jx/disallow-bad-team-names branch from b8e485d to 558f29b Compare August 10, 2021 12:31
@roboquat
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Aug 10, 2021

/werft run

👍 started the job as gitpod-build-jx-disallow-bad-team-names.5

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Aug 10, 2021

I believe all nits are addressed 😁

Screenshot 2021-08-10 at 15 51 55

@gtsiolis please take another look when you have time 👀

/unhold

@gtsiolis
Copy link
Contributor

gtsiolis commented Aug 10, 2021

@jankeromnes UX works like a charm. 🔮

  1. Feel free to forward this to someone on the crew to take a deeper look in the code changes if needed before merging. 🏓
  2. We may need an approval from a dashboard owner as described in [dashboard] Disallow team names that might conflict with dashboard URLs #5131 (comment) but not quite sure if this is the case after manual approval. 🤷

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Aug 10, 2021

Many thanks for the reviews! 🙌

Works as expected! ✔️

UX works like a charm. 🔮

Interpreting as /lgtm 😇

@roboquat roboquat merged commit 9103431 into main Aug 10, 2021
@roboquat roboquat deleted the jx/disallow-bad-team-names branch August 10, 2021 18:03
@gtsiolis
Copy link
Contributor

gtsiolis commented Aug 10, 2021

Thanks @jankeromnes for merging this and @csweichel for taking a look! 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Teams] Disallow team names that are also user names or that conflict with dashboard URLs
4 participants