Skip to content
GitLab Next
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 43,808
    • Issues 43,808
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,419
    • Merge requests 1,419
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #976
Closed
Open
Created Sep 06, 2016 by Rémy Coutable@rymai🔴Maintainer

MergeRequest#number_of_potential_approvers doesn't exclude blocked users

Similarly to gitlab-org/gitlab-ce#21650, it seems that blocked users are note excluded from MergeRequest#number_of_potential_approvers:

def number_of_potential_approvers
  has_access = ['access_level > ?', Member::REPORTER]
  wheres = [
    "id IN (#{overall_approvers.select(:user_id).to_sql})",
    "id IN (#{project.members.where(has_access).select(:user_id).to_sql})"
  ]

  if project.group
    wheres << "id IN (#{project.group.members.where(has_access).select(:user_id).to_sql})"
  end

  User.where("(#{wheres.join(' OR ')}) AND id NOT IN (#{approvals.select(:user_id).to_sql}) AND id != #{author.id}").count
end

Simple fix is to change the last line to:

User.where(state: :active).where("(#{wheres.join(' OR ')}) AND id NOT IN (#{approvals.select(:user_id).to_sql}) AND id != #{author.id}").count

This is a very minor security issue since the worst-case scenario would be that the MR gets 'stuck' in a state where it can't be approved since we think there are enough approvers when there are not (e.g. we require 2 approvals but the project has only a developer and a blocked developer).

/cc @nick.thomas

Assignee
Assign to
Time tracking