Commit 1afe0703 authored by John T Skarbek's avatar John T Skarbek

Merge remote-tracking branch 'dev/master'

parents b11dad83 7230cc82
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
## 13.0.4 (2020-06-03)
- No changes.
## 13.0.3 (2020-05-29) ## 13.0.3 (2020-05-29)
- No changes. - No changes.
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
documentation](doc/development/changelog.md) for instructions on adding your own documentation](doc/development/changelog.md) for instructions on adding your own
entry. entry.
## 13.0.4 (2020-06-03)
### Security (1 change)
- Prevent fetching repository code with unauthorized ci token.
## 13.0.3 (2020-05-29) ## 13.0.3 (2020-05-29)
### Fixed (8 changes, 1 of them is from the community) ### Fixed (8 changes, 1 of them is from the community)
......
...@@ -450,6 +450,7 @@ class ProjectPolicy < BasePolicy ...@@ -450,6 +450,7 @@ class ProjectPolicy < BasePolicy
rule { repository_disabled }.policy do rule { repository_disabled }.policy do
prevent :push_code prevent :push_code
prevent :download_code prevent :download_code
prevent :build_download_code
prevent :fork_project prevent :fork_project
prevent :read_commit_status prevent :read_commit_status
prevent :read_pipeline prevent :read_pipeline
......
...@@ -5,6 +5,7 @@ require 'spec_helper' ...@@ -5,6 +5,7 @@ require 'spec_helper'
describe ProjectPolicy do describe ProjectPolicy do
include ExternalAuthorizationServiceHelpers include ExternalAuthorizationServiceHelpers
include_context 'ProjectPolicy context' include_context 'ProjectPolicy context'
let_it_be(:other_user) { create(:user) }
let_it_be(:guest) { create(:user) } let_it_be(:guest) { create(:user) }
let_it_be(:reporter) { create(:user) } let_it_be(:reporter) { create(:user) }
let_it_be(:developer) { create(:user) } let_it_be(:developer) { create(:user) }
...@@ -163,7 +164,7 @@ describe ProjectPolicy do ...@@ -163,7 +164,7 @@ describe ProjectPolicy do
subject { described_class.new(owner, project) } subject { described_class.new(owner, project) }
it 'disallows all permissions when the feature is disabled' do it 'disallows all permissions when the feature is disabled' do
project.project_feature.update(merge_requests_access_level: ProjectFeature::DISABLED) project.project_feature.update!(merge_requests_access_level: ProjectFeature::DISABLED)
mr_permissions = [:create_merge_request_from, :read_merge_request, mr_permissions = [:create_merge_request_from, :read_merge_request,
:update_merge_request, :admin_merge_request, :update_merge_request, :admin_merge_request,
...@@ -215,7 +216,7 @@ describe ProjectPolicy do ...@@ -215,7 +216,7 @@ describe ProjectPolicy do
subject { described_class.new(owner, project) } subject { described_class.new(owner, project) }
before do before do
project.project_feature.update(builds_access_level: ProjectFeature::DISABLED) project.project_feature.update!(builds_access_level: ProjectFeature::DISABLED)
end end
it 'disallows all permissions except pipeline when the feature is disabled' do it 'disallows all permissions except pipeline when the feature is disabled' do
...@@ -235,7 +236,7 @@ describe ProjectPolicy do ...@@ -235,7 +236,7 @@ describe ProjectPolicy do
subject { described_class.new(guest, project) } subject { described_class.new(guest, project) }
before do before do
project.project_feature.update(builds_access_level: ProjectFeature::PRIVATE) project.project_feature.update!(builds_access_level: ProjectFeature::PRIVATE)
end end
it 'disallows pipeline and commit_status permissions' do it 'disallows pipeline and commit_status permissions' do
...@@ -250,24 +251,56 @@ describe ProjectPolicy do ...@@ -250,24 +251,56 @@ describe ProjectPolicy do
end end
context 'repository feature' do context 'repository feature' do
subject { described_class.new(owner, project) } let(:repository_permissions) do
[
it 'disallows all permissions when the feature is disabled' do
project.project_feature.update(repository_access_level: ProjectFeature::DISABLED)
repository_permissions = [
:create_pipeline, :update_pipeline, :admin_pipeline, :destroy_pipeline, :create_pipeline, :update_pipeline, :admin_pipeline, :destroy_pipeline,
:create_build, :read_build, :update_build, :admin_build, :destroy_build, :create_build, :read_build, :update_build, :admin_build, :destroy_build,
:create_pipeline_schedule, :read_pipeline_schedule, :update_pipeline_schedule, :admin_pipeline_schedule, :destroy_pipeline_schedule, :create_pipeline_schedule, :read_pipeline_schedule, :update_pipeline_schedule, :admin_pipeline_schedule, :destroy_pipeline_schedule,
:create_environment, :read_environment, :update_environment, :admin_environment, :destroy_environment, :create_environment, :read_environment, :update_environment, :admin_environment, :destroy_environment,
:create_cluster, :read_cluster, :update_cluster, :admin_cluster, :create_cluster, :read_cluster, :update_cluster, :admin_cluster,
:create_deployment, :read_deployment, :update_deployment, :admin_deployment, :destroy_deployment, :create_deployment, :read_deployment, :update_deployment, :admin_deployment, :destroy_deployment,
:destroy_release :destroy_release, :download_code, :build_download_code
] ]
end
context 'when user is a project member' do
subject { described_class.new(owner, project) }
context 'when it is disabled' do
before do
project.project_feature.update!(
repository_access_level: ProjectFeature::DISABLED,
merge_requests_access_level: ProjectFeature::DISABLED,
builds_access_level: ProjectFeature::DISABLED,
forking_access_level: ProjectFeature::DISABLED
)
end
it 'disallows all permissions' do
expect_disallowed(*repository_permissions) expect_disallowed(*repository_permissions)
end end
end end
end
context 'when user is some other user' do
subject { described_class.new(other_user, project) }
context 'when access level is private' do
before do
project.project_feature.update!(
repository_access_level: ProjectFeature::PRIVATE,
merge_requests_access_level: ProjectFeature::PRIVATE,
builds_access_level: ProjectFeature::PRIVATE,
forking_access_level: ProjectFeature::PRIVATE
)
end
it 'disallows all permissions' do
expect_disallowed(*repository_permissions)
end
end
end
end
it_behaves_like 'project policies as anonymous' it_behaves_like 'project policies as anonymous'
it_behaves_like 'project policies as guest' it_behaves_like 'project policies as guest'
...@@ -547,7 +580,7 @@ describe ProjectPolicy do ...@@ -547,7 +580,7 @@ describe ProjectPolicy do
context 'feature enabled' do context 'feature enabled' do
before do before do
project.project_feature.update(metrics_dashboard_access_level: ProjectFeature::ENABLED) project.project_feature.update!(metrics_dashboard_access_level: ProjectFeature::ENABLED)
end end
context 'with reporter' do context 'with reporter' do
...@@ -611,7 +644,7 @@ describe ProjectPolicy do ...@@ -611,7 +644,7 @@ describe ProjectPolicy do
context 'feature enabled' do context 'feature enabled' do
before do before do
project.project_feature.update(metrics_dashboard_access_level: ProjectFeature::ENABLED) project.project_feature.update!(metrics_dashboard_access_level: ProjectFeature::ENABLED)
end end
context 'with reporter' do context 'with reporter' do
...@@ -696,7 +729,7 @@ describe ProjectPolicy do ...@@ -696,7 +729,7 @@ describe ProjectPolicy do
context 'feature disabled' do context 'feature disabled' do
before do before do
project.project_feature.update(metrics_dashboard_access_level: ProjectFeature::DISABLED) project.project_feature.update!(metrics_dashboard_access_level: ProjectFeature::DISABLED)
end end
context 'with reporter' do context 'with reporter' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment