Skip to content

Allow versionless maven-metadata.xml file duplicates

Steve Abrams requested to merge 276882-Allow-metadata-duplicates into master

🏛 Context

#276882 (closed) Added new settings for the Maven package registry to allow users to control if they could upload duplicate packages or not. The problem is when we added the logic determining if an incoming package file was a duplicate, we failed to consider the versionless maven-metadata.xml file.

Now you're probably wondering what a "versionless metadata" file is 🤔. When working with maven packages, if I upload different versions of the same package (my-pkg-1.0.0 and my-pkg-2.0.0), each one is uploaded as a separate package, however a common metadata file containing info about all of the versions is uploaded too. We store these files in a "dummy package" of the same name (my-pkg) that has no version. So each time you upload a new version, that dummy package will seemingly be getting a duplicate file upload, but that is the behavior we want. We always want to have the most recent versionless metadata file.

So the bug is right now, we only allow one of each file type to be uploaded to a given package if the duplicate package settings (namespace_package_settings.maven_duplicates_allowed) is set to false. This causes trouble with the versionless package that expects many of the same file type.

🔎 What does this MR do?

When a Maven file is uploaded to a versionless package, it will allow the upload regardless of package duplicate settings. A condition is added to the logic dealing with the Maven duplicates to allow the error to be bypassed if the package has no version.

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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

Related to #276882 (closed)

Edited by Steve Abrams

Merge request reports