Skip to content

Commit 1ac2a3b

Browse files
committed
Merge branch '52367-cleanup-web-hooks-columns' into 'master'
Remove unencrypted webhook token and URL columns Closes #52367 See merge request gitlab-org/gitlab-ce!22199
2 parents 55bd24e + ff9881d commit 1ac2a3b

File tree

5 files changed

+31
-37
lines changed

5 files changed

+31
-37
lines changed

app/models/hooks/web_hook.rb

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,4 @@ def async_execute(data, hook_name)
3737
def allow_local_requests?
3838
false
3939
end
40-
41-
# In 11.4, the web_hooks table has both `token` and `encrypted_token` fields.
42-
# Ensure that the encrypted version always takes precedence if present.
43-
alias_method :attr_encrypted_token, :token
44-
def token
45-
attr_encrypted_token.presence || read_attribute(:token)
46-
end
47-
48-
# In 11.4, the web_hooks table has both `token` and `encrypted_token` fields.
49-
# Pending a background migration to encrypt all fields, we should just clear
50-
# the unencrypted value whenever the new value is set.
51-
alias_method :'attr_encrypted_token=', :'token='
52-
def token=(value)
53-
self.attr_encrypted_token = value
54-
55-
write_attribute(:token, nil)
56-
end
57-
58-
# In 11.4, the web_hooks table has both `url` and `encrypted_url` fields.
59-
# Ensure that the encrypted version always takes precedence if present.
60-
alias_method :attr_encrypted_url, :url
61-
def url
62-
attr_encrypted_url.presence || read_attribute(:url)
63-
end
64-
65-
# In 11.4, the web_hooks table has both `url` and `encrypted_url` fields.
66-
# Pending a background migration to encrypt all fields, we should just clear
67-
# the unencrypted value whenever the new value is set.
68-
alias_method :'attr_encrypted_url=', :'url='
69-
def url=(value)
70-
self.attr_encrypted_url = value
71-
72-
write_attribute(:url, nil)
73-
end
7440
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Remove legacy unencrypted webhook columns from the database
3+
merge_request: 22199
4+
author:
5+
type: changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class StealEncryptColumns < ActiveRecord::Migration
2+
include Gitlab::Database::MigrationHelpers
3+
4+
DOWNTIME = false
5+
6+
disable_ddl_transaction!
7+
8+
def up
9+
Gitlab::BackgroundMigration.steal('EncryptColumns')
10+
end
11+
12+
def down
13+
# no-op
14+
end
15+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class RemoveWebHooksTokenAndUrl < ActiveRecord::Migration
2+
include Gitlab::Database::MigrationHelpers
3+
4+
DOWNTIME = false
5+
6+
def change
7+
remove_column :web_hooks, :token, :string
8+
remove_column :web_hooks, :url, :string, limit: 2000
9+
end
10+
end

db/schema.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended that you check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(version: 20181002172433) do
14+
ActiveRecord::Schema.define(version: 20181008145359) do
1515

1616
# These are extensions that must be enabled in order to support this database
1717
enable_extension "plpgsql"
@@ -2256,7 +2256,6 @@
22562256
add_index "web_hook_logs", ["web_hook_id"], name: "index_web_hook_logs_on_web_hook_id", using: :btree
22572257

22582258
create_table "web_hooks", force: :cascade do |t|
2259-
t.string "url", limit: 2000
22602259
t.integer "project_id"
22612260
t.datetime "created_at"
22622261
t.datetime "updated_at"
@@ -2269,7 +2268,6 @@
22692268
t.boolean "note_events", default: false, null: false
22702269
t.boolean "enable_ssl_verification", default: true
22712270
t.boolean "wiki_page_events", default: false, null: false
2272-
t.string "token"
22732271
t.boolean "pipeline_events", default: false, null: false
22742272
t.boolean "confidential_issues_events", default: false, null: false
22752273
t.boolean "repository_update_events", default: false, null: false

0 commit comments

Comments
 (0)