diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-01 10:28:41 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-01 10:29:08 +0300 |
commit | 412bafb9ce77eaf2e00b9700d6a5cdfd73762ddb (patch) | |
tree | 0a2b9a6b1ac25195cf6b4de587005b4bd9113fd1 | |
parent | 780afecf300254a98c8db6818f7a53db564740ec (diff) |
Add latest changes from gitlab-org/security/gitlab@14-10-stable-ee
-rw-r--r-- | app/services/ci/pipeline_trigger_service.rb | 1 | ||||
-rw-r--r-- | spec/services/ci/pipeline_trigger_service_spec.rb | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/app/services/ci/pipeline_trigger_service.rb b/app/services/ci/pipeline_trigger_service.rb index 7746382b845..ecd84884d95 100644 --- a/app/services/ci/pipeline_trigger_service.rb +++ b/app/services/ci/pipeline_trigger_service.rb @@ -26,6 +26,7 @@ module Ci def create_pipeline_from_trigger(trigger) # this check is to not leak the presence of the project if user cannot read it return unless trigger.project == project + return unless can?(trigger.owner, :read_project, project) response = Ci::CreatePipelineService .new(project, trigger.owner, ref: params[:ref], variables_attributes: variables) diff --git a/spec/services/ci/pipeline_trigger_service_spec.rb b/spec/services/ci/pipeline_trigger_service_spec.rb index 29d12b0dd0e..9187ac9519c 100644 --- a/spec/services/ci/pipeline_trigger_service_spec.rb +++ b/spec/services/ci/pipeline_trigger_service_spec.rb @@ -56,6 +56,15 @@ RSpec.describe Ci::PipelineTriggerService do end end + context 'when trigger owner does not have a permission to read a project' do + let(:params) { { token: trigger.token, ref: 'master', variables: nil } } + let(:trigger) { create(:ci_trigger, project: project, owner: create(:user)) } + + it 'does nothing' do + expect { result }.not_to change { Ci::Pipeline.count } + end + end + context 'when params have an existing trigger token' do context 'when params have an existing ref' do let(:params) { { token: trigger.token, ref: 'master', variables: nil } } |