Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
889a3e8c
Commit
889a3e8c
authored
Jul 23, 2020
by
Shreyas Agarwal
Committed by
Michael Kozono
Jul 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent certain policies at issue level when namespace is read only
parent
a9a3dec1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
2 deletions
+61
-2
app/models/issue.rb
app/models/issue.rb
+2
-0
app/policies/issue_policy.rb
app/policies/issue_policy.rb
+2
-0
ee/app/policies/ee/issue_policy.rb
ee/app/policies/ee/issue_policy.rb
+20
-0
ee/spec/policies/issue_policy_spec.rb
ee/spec/policies/issue_policy_spec.rb
+33
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+1
-0
spec/policies/issue_policy_spec.rb
spec/policies/issue_policy_spec.rb
+2
-2
No files found.
app/models/issue.rb
View file @
889a3e8c
...
...
@@ -30,6 +30,8 @@ class Issue < ApplicationRecord
SORTING_PREFERENCE_FIELD
=
:issues_sort
belongs_to
:project
has_one
:namespace
,
through: :project
belongs_to
:duplicated_to
,
class_name:
'Issue'
belongs_to
:closed_by
,
class_name:
'User'
belongs_to
:iteration
,
foreign_key:
'sprint_id'
...
...
app/policies/issue_policy.rb
View file @
889a3e8c
...
...
@@ -40,3 +40,5 @@ class IssuePolicy < IssuablePolicy
prevent
:destroy_design
end
end
IssuePolicy
.
prepend_if_ee
(
'EE::IssuePolicy'
)
ee/app/policies/ee/issue_policy.rb
0 → 100644
View file @
889a3e8c
# frozen_string_literal: true
module
EE
module
IssuePolicy
extend
ActiveSupport
::
Concern
prepended
do
condition
(
:over_storage_limit
,
scope: :subject
)
{
@subject
.
namespace
.
over_storage_limit?
}
rule
{
over_storage_limit
}.
policy
do
prevent
:create_issue
prevent
:update_issue
prevent
:read_issue_iid
prevent
:reopen_issue
prevent
:create_design
prevent
:create_note
end
end
end
end
ee/spec/policies/issue_policy_spec.rb
0 → 100644
View file @
889a3e8c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
IssuePolicy
do
let
(
:owner
)
{
build_stubbed
(
:user
)
}
let
(
:namespace
)
{
build_stubbed
(
:namespace
,
owner:
owner
)
}
let
(
:project
)
{
build_stubbed
(
:project
,
namespace:
namespace
)
}
let
(
:issue
)
{
build_stubbed
(
:issue
,
project:
project
)
}
subject
{
described_class
.
new
(
owner
,
issue
)
}
before
do
allow
(
issue
).
to
receive
(
:namespace
).
and_return
namespace
allow
(
project
).
to
receive
(
:design_management_enabled?
).
and_return
true
end
context
'when namespace is locked because storage usage limit exceeded'
do
before
do
allow
(
namespace
).
to
receive
(
:over_storage_limit?
).
and_return
true
end
it
{
is_expected
.
to
be_disallowed
(
:create_issue
,
:update_issue
,
:read_issue_iid
,
:reopen_issue
,
:create_design
,
:create_note
)
}
end
context
'when namespace is not locked because storage usage limit not exceeded'
do
before
do
allow
(
namespace
).
to
receive
(
:over_storage_limit?
).
and_return
false
end
it
{
is_expected
.
to
be_allowed
(
:create_issue
,
:update_issue
,
:read_issue_iid
,
:reopen_issue
,
:create_design
,
:create_note
)
}
end
end
spec/lib/gitlab/import_export/all_models.yml
View file @
889a3e8c
...
...
@@ -46,6 +46,7 @@ issues:
-
system_note_metadata
-
alert_management_alert
-
status_page_published_incident
-
namespace
events
:
-
author
-
project
...
...
spec/models/issue_spec.rb
View file @
889a3e8c
...
...
@@ -11,6 +11,7 @@ RSpec.describe Issue do
it
{
is_expected
.
to
belong_to
(
:milestone
)
}
it
{
is_expected
.
to
belong_to
(
:iteration
)
}
it
{
is_expected
.
to
belong_to
(
:project
)
}
it
{
is_expected
.
to
have_one
(
:namespace
).
through
(
:project
)
}
it
{
is_expected
.
to
belong_to
(
:moved_to
).
class_name
(
'Issue'
)
}
it
{
is_expected
.
to
have_one
(
:moved_from
).
class_name
(
'Issue'
)
}
it
{
is_expected
.
to
belong_to
(
:duplicated_to
).
class_name
(
'Issue'
)
}
...
...
spec/policies/issue_policy_spec.rb
View file @
889a3e8c
...
...
@@ -104,7 +104,7 @@ RSpec.describe IssuePolicy do
end
it
'does not allow issue author to read or update confidential issue moved to an private project'
do
confidential_issue
.
project
=
build
(
:project
,
:private
)
confidential_issue
.
project
=
create
(
:project
,
:private
)
expect
(
permissions
(
author
,
confidential_issue
)).
to
be_disallowed
(
:read_issue
,
:read_issue_iid
,
:update_issue
)
end
...
...
@@ -117,7 +117,7 @@ RSpec.describe IssuePolicy do
end
it
'does not allow issue assignees to read or update confidential issue moved to an private project'
do
confidential_issue
.
project
=
build
(
:project
,
:private
)
confidential_issue
.
project
=
create
(
:project
,
:private
)
expect
(
permissions
(
assignee
,
confidential_issue
)).
to
be_disallowed
(
:read_issue
,
:read_issue_iid
,
:update_issue
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment