gitlab-org--gitlab-foss/app/policies/ci/runner_policy.rb
Yorick Peterse 2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00

23 lines
610 B
Ruby

# frozen_string_literal: true
module Ci
class RunnerPolicy < BasePolicy
with_options scope: :subject, score: 0
condition(:locked, scope: :subject) { @subject.locked? }
# rubocop: disable CodeReuse/ActiveRecord
condition(:owned_runner) { @user.ci_owned_runners.exists?(@subject.id) }
# rubocop: enable CodeReuse/ActiveRecord
rule { anonymous }.prevent_all
rule { admin | owned_runner }.policy do
enable :assign_runner
enable :read_runner
enable :update_runner
enable :delete_runner
end
rule { ~admin & locked }.prevent :assign_runner
end
end