summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorFabio Pitino <fpitino@gitlab.com>2019-09-13 07:40:00 +0100
committerFabio Pitino <fpitino@gitlab.com>2019-09-24 10:24:00 +0100
commit90466e7009e5c1791de07590055db35921ac30c5 (patch)
tree3a913f45c8d7c7032c2b5e9145dfbe9c51b79d51 /app/services
parent7099ecf77cb45c7b456a47f24064657ca59549b7 (diff)
downloadgitlab-ce-90466e7009e5c1791de07590055db35921ac30c5.tar.gz
Cancel all running CI jobs when user is blocked
This prevents a MITM attack where attacker could still access Git repository if any jobs were running long enough.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/ci/cancel_user_pipelines_service.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/services/ci/cancel_user_pipelines_service.rb b/app/services/ci/cancel_user_pipelines_service.rb
new file mode 100644
index 00000000000..bcafb6b4a35
--- /dev/null
+++ b/app/services/ci/cancel_user_pipelines_service.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module Ci
+ class CancelUserPipelinesService
+ # rubocop: disable CodeReuse/ActiveRecord
+ # This is a bug with CodeReuse/ActiveRecord cop
+ # https://gitlab.com/gitlab-org/gitlab/issues/32332
+ def execute(user)
+ user.pipelines.cancelable.find_each(&:cancel_running)
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
+ end
+end