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
Léo-Paul Géneau
gitlab-ce
Commits
8ea9c815
Commit
8ea9c815
authored
Jul 17, 2018
by
Ahmad Hassan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use rugged to validate ref name
parent
59b82fbc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
lib/gitlab/git_ref_validator.rb
lib/gitlab/git_ref_validator.rb
+4
-4
scripts/lint-rugged
scripts/lint-rugged
+4
-1
No files found.
lib/gitlab/git_ref_validator.rb
View file @
8ea9c815
...
@@ -7,11 +7,11 @@ module Gitlab
...
@@ -7,11 +7,11 @@ module Gitlab
#
#
# Returns true for a valid reference name, false otherwise
# Returns true for a valid reference name, false otherwise
def
validate
(
ref_name
)
def
validate
(
ref_name
)
return
false
if
ref_name
.
start_with?
(
'refs/heads/'
)
not_allowed_prefixes
=
%w(refs/heads/ refs/remotes/ -)
return
false
if
ref_name
.
start_with?
(
'refs/remotes/'
)
return
false
if
ref_name
.
start_with?
(
*
not_allowed_prefixes
)
return
false
if
ref_name
==
'HEAD'
Gitlab
::
Utils
.
system_silent
(
Rugged
::
Reference
.
valid_name?
"refs/heads/
#{
ref_name
}
"
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
check-ref-format --branch
#{
ref_name
}
)
)
end
end
end
end
end
end
scripts/lint-rugged
View file @
8ea9c815
...
@@ -14,7 +14,10 @@ ALLOWED = [
...
@@ -14,7 +14,10 @@ ALLOWED = [
'lib/tasks/gitlab/cleanup.rake'
,
'lib/tasks/gitlab/cleanup.rake'
,
# The only place where Rugged code is still allowed in production
# The only place where Rugged code is still allowed in production
'lib/gitlab/git/'
'lib/gitlab/git/'
,
# Needed to avoid using the git binary to validate a branch name
'lib/gitlab/git_ref_validator.rb'
].
freeze
].
freeze
rugged_lines
=
IO
.
popen
(
%w[git grep -i -n rugged -- app config lib]
,
&
:read
).
lines
rugged_lines
=
IO
.
popen
(
%w[git grep -i -n rugged -- app config lib]
,
&
:read
).
lines
...
...
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