Skip to content
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

Improve GitLab Trusted Publisher project/namespace validation during creation #15852

Open
facutuesca opened this issue Apr 24, 2024 · 0 comments

Comments

@facutuesca
Copy link
Contributor

As discussed in this thread, creating a GitLab trusted publisher validates the input fields (like the namespace and project) against some simple regexes:

# https://docs.gitlab.com/ee/user/reserved_names.html#limitations-on-project-and-group-names
_VALID_GITLAB_PROJECT = re.compile(r"^[a-zA-Z0-9][a-zA-Z0-9-_.]*$")
_VALID_GITLAB_NAMESPACE = re.compile(r"^[a-zA-Z0-9][a-zA-Z0-9-_./]*$")
_VALID_GITLAB_ENVIRONMENT = re.compile(r"^[a-zA-Z0-9\-_/${} ]+$")

These regexes are too permissive: they accept all valid inputs, but don't fail on all invalid inputs. Looking at the GitLab docs, here is a few invalid cases which we don't detect:

  • Must not contain consecutive special characters.
  • Cannot start or end with a special character.
  • Cannot end in .git or .atom.

There are also reserved group, subgroup and project names which we don't detect.

Currently, accepting these invalid inputs does not have security consequences (it only means that the created trusted publisher will never work, since no GitLab project/namespace with that name will exist), but making the validation more accurate would be a UX improvement, preventing users from creating incorrect trusted publishers.

cc @di @woodruffw

@facutuesca facutuesca added feature request requires triaging maintainers need to do initial inspection of issue labels Apr 24, 2024
@miketheman miketheman removed the requires triaging maintainers need to do initial inspection of issue label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants