Defect #18855
closed
User with only Move Issue rights in the project can still create issues using mass copy!
Added by Scott Cunningham almost 10 years ago.
Updated almost 10 years ago.
Category:
Issues permissions
Description
I found this bug when I was trying to use a project with a list of issues as a template for other projects (process flow). I assigned members to custom role "Copy" which only allows viewing and moving issues. If, however, the user does not change the project (i.e. copy into other project), new issues will be created within the existing project where they do not have rights!
I am running 2.5.2 on a Bitnami stack. I do not have the chance to try 2.6.x at the moment.
Note - we use task instead of issue in our language file.
Custom Role Copy settings:¶
User does not have issue edit rights (correct)¶
User can copy multiple issues at once (correct)¶
Copy screenshot¶
Issues were added to existing project without regard to no Add Issue rights (not correct)¶
Files
I believe I have tracked down the problem.
Context menu
Copy calls the
bulk_edit
function in
issues_controller.rb:
- checks if user has move issue rights
- builds an allowed projects list by calling
allowed_target_projects_on_move
in issue.rb:
- which checks projects for move rights, not add rights...
So for copy, the program checks for move-out and move-in rights. But move-in rights is really add rights.
I think instead, move rights should be checked at source project and then add rights at destination project. This should block a user from copying issues into a project where they do not have add issue rights.
issues_controller.rb snippet
# Bulk edit/copy a set of issues
def bulk_edit
@issues.sort!
@copy = params[:copy].present?
@notes = params[:notes]
if User.current.allowed_to?(:move_issues, @projects) # <----------- this is correct: can user move/copy in the first place
@allowed_projects = Issue.allowed_target_projects_on_move # <-------- i think this is wrong: target projects should only be add rights
if params[:issue]
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
if @target_project
target_projects = [@target_project]
end
end
end
target_projects ||= @projects
I made a small patch and destination projects are now only ones with Add issue rights.
Unresolved: If the user does not change the project pull down from (No change), then new issues will still be created even when the permissions should not allow it. This is past my knowledge point now.
- Modify models\issue.rb file:
# Returns a scope of projects that user can move issues to
def self.allowed_target_projects_on_move(user=User.current)
Project.where(Project.allowed_to_condition(user, :move_issues))
end
# Returns a scope of projects that user can add issues to # <--- new
def self.allowed_target_projects_on_copy(user=User.current) # <--- new
Project.where(Project.allowed_to_condition(user, :add_issues)) # <--- new
end # <--- new
- Modify controllers\issues_controller.rb file:
# Bulk edit/copy a set of issues
def bulk_edit
@issues.sort!
@copy = params[:copy].present?
@notes = params[:notes]
if User.current.allowed_to?(:move_issues, @projects)
#@allowed_projects = Issue.allowed_target_projects_on_move # <---- comment out
@allowed_projects = Issue.allowed_target_projects_on_copy # <---- new line
if params[:issue]
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
if @target_project
target_projects = [@target_project]
end
end
end
target_projects ||= @projects
- Target version set to Candidate for next major release
- Status changed from New to Closed
- Assignee set to Jean-Philippe Lang
- Target version changed from Candidate for next major release to 3.0.0
- Resolution set to Fixed
This is now fixed. The :move_issues permission is removed (r13981) and replaced with a :copy_issues permissionn (r13985). When allowed to copy issues, use can copy them to projects on which he has the :add_issues permission.
- Related to Patch #28311: Remove unused i18n key "permission_move_issues" added
Also available in: Atom
PDF