Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e491df5f
Commit
e491df5f
authored
Nov 20, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Encrypt runners communication token in the database
parent
478c15fa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
7 deletions
+23
-7
app/models/ci/runner.rb
app/models/ci/runner.rb
+4
-5
db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb
...grate/20181120151656_add_token_encrypted_to_ci_runners.rb
+12
-0
db/schema.rb
db/schema.rb
+2
-1
lib/gitlab/import_export/import_export.yml
lib/gitlab/import_export/import_export.yml
+3
-0
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+2
-1
No files found.
app/models/ci/runner.rb
View file @
e491df5f
...
...
@@ -8,6 +8,9 @@ module Ci
include
RedisCacheable
include
ChronicDurationAttribute
include
FromUnion
include
TokenAuthenticatable
add_authentication_token_field
:token
,
encrypted:
true
,
fallback:
true
enum
access_level:
{
not_protected:
0
,
...
...
@@ -39,7 +42,7 @@ module Ci
has_one
:last_build
,
->
()
{
order
(
'id DESC'
)
},
class_name:
'Ci::Build'
before_
validation
:set_default_values
before_
save
:ensure_token
scope
:active
,
->
{
where
(
active:
true
)
}
scope
:paused
,
->
{
where
(
active:
false
)
}
...
...
@@ -145,10 +148,6 @@ module Ci
end
end
def
set_default_values
self
.
token
=
SecureRandom
.
hex
(
15
)
if
self
.
token
.
blank?
end
def
assign_to
(
project
,
current_user
=
nil
)
if
instance_type?
self
.
runner_type
=
:project_type
...
...
db/migrate/20181120151656_add_token_encrypted_to_ci_runners.rb
0 → 100644
View file @
e491df5f
# frozen_string_literal: true
class
AddTokenEncryptedToCiRunners
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
add_column
:ci_runners
,
:token_encrypted
,
:string
# TODO index
end
end
db/schema.rb
View file @
e491df5f
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201811
16141504
)
do
ActiveRecord
::
Schema
.
define
(
version:
201811
20151656
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -543,6 +543,7 @@ ActiveRecord::Schema.define(version: 20181116141504) do
t
.
string
"ip_address"
t
.
integer
"maximum_timeout"
t
.
integer
"runner_type"
,
limit:
2
,
null:
false
t
.
string
"token_encrypted"
end
add_index
"ci_runners"
,
[
"contacted_at"
],
name:
"index_ci_runners_on_contacted_at"
,
using: :btree
...
...
lib/gitlab/import_export/import_export.yml
View file @
e491df5f
...
...
@@ -158,6 +158,9 @@ excluded_attributes:
-
:encrypted_token_iv
-
:encrypted_url
-
:encrypted_url_iv
runners
:
-
:token
-
:token_encrypted
methods
:
labels
:
...
...
lib/gitlab/import_export/relation_factory.rb
View file @
e491df5f
...
...
@@ -8,6 +8,7 @@ module Gitlab
triggers:
'Ci::Trigger'
,
pipeline_schedules:
'Ci::PipelineSchedule'
,
builds:
'Ci::Build'
,
runners:
'Ci::Runner'
,
hooks:
'ProjectHook'
,
merge_access_levels:
'ProtectedBranch::MergeAccessLevel'
,
push_access_levels:
'ProtectedBranch::PushAccessLevel'
,
...
...
@@ -31,7 +32,7 @@ module Gitlab
EXISTING_OBJECT_CHECK
=
%i[milestone milestones label labels project_label project_labels group_label group_labels project_feature]
.
freeze
TOKEN_RESET_MODELS
=
%w[Project Namespace
Group Ci::Trigger Ci::Build
ProjectHook]
.
freeze
TOKEN_RESET_MODELS
=
%w[Project Namespace
Ci::Trigger Ci::Build Ci::Runner
ProjectHook]
.
freeze
def
self
.
create
(
*
args
)
new
(
*
args
).
create
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment