Skip to content

Do not allow special characters in new namespaces path

What does this MR do and why?

This will restrict consecutive special characters and special characters at the start and the end of groups' paths and usernames.

It's a follow-up of !80055 (merged) where we disabled special characters in the project path.

Add a new validation that checks whether the namespace path conforms to [a-z0-9]+([._-][a-z0-9]+)*(/[a-z0-9]+([._-][a-z0-9]+)*)*. This restricts special characters at the start or the end of the namespace path and also restricts consecutive special characters in the namespace path. The regex used in this MR has been simplified as the namespace path cannot contain the forward-slash / character.

The validation only runs when the namespace path is updated or added. It will not run when any other namespace fields are updated or the namespace is read or deleted. This new validation is behind a feature flag.

How to set up and validate locally

  1. Enable the feature flag

    Feature.enable(:restrict_special_characters_in_namespace_path)
  2. Create a new group with the group path having _, -, or . at the start or end (or containing 2 or more consecutive such characters in between).

  3. Validation error is thrown.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #356162 (closed)

Edited by Abdul Wadood

Merge request reports