Skip to content
Snippets Groups Projects

Protected packages: Push protection for deploy token

  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

What does this MR do and why?

Protected packages: Push protection for deploy token

  • Ensure that a protected package cannot be published with a deploy token when there is a package protection rule that matches the package name and type
  • We discussed the user expectation and concluded that deploy tokens should not be able to publish packages that are protected by a package protection rule, see #323970 (comment 1978981115)

:tools: with :heart: at Siemens

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

MR Checklist (@gerardo-navarro)

Screenshots or screen recordings

Before After
Deploy tokens can always push (publish) a protected package. Deploy tokens cannot push (publish) a package when a package protection rule exists for this package (matching only package_name and package_type, and disregarding minimum_access_level_for_push)

How to set up and validate locally

  1. Enable feature flag via rails c
Feature.enable(:packages_protected_packages)
  1. Create a new package protection rule through the frontend and use the following values: http://gdk.test:3000/flightjs/Flight/-/settings/packages_and_registries
  • Package name pattern: @flightjs/test-npm-package-*
  • Package type: :npm
  • Minimum access level for push: :maintainer
  1. Create a dummy project for npm package for testing publishing
# Go to a directory outside of the gitlab and gdk directory
mkdir test-npm-package && cd test-npm-package
npm init esm --yes
  1. Adjust the package name in package.json and set it to "@flightjs/test-npm-package-prod" <= this should match the given package_name_pattern in step 2
  2. Create or adjust file .npmrc in order to push the npm package to the GitLab registry, see https://docs.gitlab.com/ee/user/packages/npm_registry/#authenticating-via-the-npmrc
  3. Create a deploy token, see https://docs.gitlab.com/ee/user/project/deploy_tokens/#create-a-deploy-token
  4. Publish npm test package using the newly created deploy token
NPM_TOKEN=<deploy_token> npm publish
  1. The package should be protected and should not have been published :thumbsup:

:floppy_disk: Database review

Related to #323970 (closed)

Edited by David Fernandez

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading