Add validation to Conan recipe that conforms with Conan.io
What does this MR do?
Description
The GitLab Conan registry does not have the same validation in the package recipe that the Conan client is checking as reported in #214471 (closed). This can lead to problems when working with the GitLab registry.
Proposed solution
All four parts of the recipe: <pkg-name>/<version>@<user>/<channel> are validated by modifying the current regex Gitlab::Regex.conan_recipe_component_regex to use the one in Conan.io - (^[a-zA-Z0-9_][a-zA-Z0-9_\+\.-]{1,50}$). Which is used in the following files:
- Validates all four of the component parameters in the incoming request on https://gitlab.com/gitlab-org/gitlab/blob/master/ee/lib/api/conan_packages.rb#L86 as
PACKAGE_COMPONENT_REGEX - Validates both
:nameandversion:in thePackages::Packagemodel as<pkg-name>and<version>resp. - Validates both
:package_usernameand:package_channelin thePackages::ConanMetadatummodel as<user>and<channel>resp.
TODO
I am not sure if the :name should be validated again with format: { with: Gitlab::Regex.package_name_regex } as in https://gitlab.com/gitlab-org/gitlab/blob/master/ee/app/models/packages/package.rb#L26. I am thinking of adding unless: :conan?
Also, am not sure if tests should be added to ee/spec/models/packages/package_spec.rb, ee/spec/requests/api/conan_packages_spec.rb and ee/spec/services/packages/conan
Update
-
Separate :nameformat validations for all other packages from Conan package using:unless conan? -
Add test for Gitlab::Regex.conan_recipe_component_regexto check for the format rules as follows:- minimum of two characters
- maximum of fifty characters
- starts with only alphanumeric or underscore
- includes only alphanumeric,
_,+,.and-
Screenshots
Regex format from conan.io
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec -
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Closes #214471 (closed)
