summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorFabio Pitino <fpitino@gitlab.com>2019-09-13 07:40:00 +0100
committerYorick Peterse <yorick@yorickpeterse.com>2019-09-30 14:22:05 +0200
commitc9396f31c6a0088e1529b9d0bbea7f5ba4e58af9 (patch)
tree584ef4ae34bf82954c80f4e4572feda914b00847 /app/models/user.rb
parent58290d90e5b642322e397d197eb063a3ff712008 (diff)
downloadgitlab-ce-c9396f31c6a0088e1529b9d0bbea7f5ba4e58af9.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/models/user.rb')
-rw-r--r--app/models/user.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 5711162aa1a..f5fbc912cc8 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -267,6 +267,16 @@ class User < ApplicationRecord
BLOCKED_MESSAGE
end
end
+
+ # rubocop: disable CodeReuse/ServiceClass
+ # Ideally we should not call a service object here but user.block
+ # is also bcalled by Users::MigrateToGhostUserService which references
+ # this state transition object in order to do a rollback.
+ # For this reason the tradeoff is to disable this cop.
+ after_transition any => :blocked do |user|
+ Ci::CancelUserPipelinesService.new.execute(user)
+ end
+ # rubocop: enable CodeReuse/ServiceClass
end
# Scopes