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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
cefefb2a
Commit
cefefb2a
authored
Mar 03, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP - refactored migration and updated project_import_data with encrypted att
parent
18411645
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
15 deletions
+37
-15
app/models/project.rb
app/models/project.rb
+0
-1
app/models/project_import_data.rb
app/models/project_import_data.rb
+2
-1
db/migrate/20160302151724_add_import_credentials_to_project_import_data.rb
...02151724_add_import_credentials_to_project_import_data.rb
+6
-0
db/migrate/20160302151724_add_import_credentials_to_projects.rb
...rate/20160302151724_add_import_credentials_to_projects.rb
+0
-6
db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
...e/20160302152808_remove_wrong_import_url_from_projects.rb
+29
-7
No files found.
app/models/project.rb
View file @
cefefb2a
...
...
@@ -91,7 +91,6 @@ class Project < ActiveRecord::Base
attr_accessor
:new_default_branch
attr_accessor
:old_path_with_namespace
attr_encrypted
:import_credentials
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
# Relations
belongs_to
:creator
,
foreign_key:
'creator_id'
,
class_name:
'User'
...
...
app/models/project_import_data.rb
View file @
cefefb2a
...
...
@@ -12,6 +12,7 @@ require 'file_size_validator'
class
ProjectImportData
<
ActiveRecord
::
Base
belongs_to
:project
attr_encrypted
:credentials
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
serialize
:data
,
JSON
...
...
db/migrate/20160302151724_add_import_credentials_to_project_import_data.rb
0 → 100644
View file @
cefefb2a
class
AddImportCredentialsToProjectImportData
<
ActiveRecord
::
Migration
def
change
add_column
:project_import_data
,
:encrypted_credentials
,
:text
add_column
:project_import_data
,
:encrypted_credentials_iv
,
:text
end
end
db/migrate/20160302151724_add_import_credentials_to_projects.rb
deleted
100644 → 0
View file @
18411645
class
AddImportCredentialsToProjects
<
ActiveRecord
::
Migration
def
change
add_column
:projects
,
:encrypted_import_credentials
,
:text
add_column
:projects
,
:encrypted_import_credentials_iv
,
:text
end
end
db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
View file @
cefefb2a
class
RemoveWrongImportUrlFromProjects
<
ActiveRecord
::
Migration
def
up
projects_with_wrong_import_url
.
each
do
|
project
|
project
.
update_columns
(
import_url:
nil
)
# TODO Check really nil?
# TODO: migrate current credentials to import_credentials?
# TODO: Notify user ?
class
ImportUrlSanitizer
def
initialize
(
url
)
@url
=
url
end
def
sanitized_url
@sanitized_url
||=
@url
[
regex_extractor
,
1
]
+
@url
[
regex_extractor
,
3
]
end
def
credentials
@credentials
||=
@url
[
regex_extractor
,
2
]
end
private
# Regex matches 1 <first part of URL>, 2 <token or to be encrypted stuff>,
# 3 <last part of URL>
def
regex_extractor
/(.*\/\/)(.*)(\@.*)/
end
end
def
up
projects_with_wrong_import_url
.
each
do
|
project
|
sanitizer
=
ImportUrlSanitizer
.
new
(
project
.
import_urls
)
project
.
update_columns
(
import_url:
sanitizer
.
sanitized_url
)
if
project
.
import_data
project
.
import_data
.
update_columns
(
credentials:
sanitizer
.
credentials
)
end
end
end
def
projects_with_
dot_atom
def
projects_with_
wrong_import_url
# TODO Check live with #operations for possible false positives. Also, consider regex? But may have issues MySQL/PSQL
select_all
(
"SELECT p.id from projects p WHERE p.import_url LIKE '%//%:%@%' or p.import_url like '
#{
"_"
*
40
}
@github.com%'"
)
end
...
...
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