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
Jérome Perrin
gitlab-ce
Commits
4bda5b50
Commit
4bda5b50
authored
Jul 21, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Short-circuit build coverage extraction for empty regexes
parent
754d8cae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
5 deletions
+32
-5
lib/gitlab/ci/trace/stream.rb
lib/gitlab/ci/trace/stream.rb
+1
-1
lib/gitlab/untrusted_regexp.rb
lib/gitlab/untrusted_regexp.rb
+6
-1
spec/lib/gitlab/ci/trace/stream_spec.rb
spec/lib/gitlab/ci/trace/stream_spec.rb
+22
-0
spec/lib/gitlab/untrusted_regexp_spec.rb
spec/lib/gitlab/untrusted_regexp_spec.rb
+3
-3
No files found.
lib/gitlab/ci/trace/stream.rb
View file @
4bda5b50
...
...
@@ -67,7 +67,7 @@ module Gitlab
def
extract_coverage
(
regex
)
return
unless
valid?
return
unless
regex
return
unless
regex
.
present?
regex
=
Gitlab
::
UntrustedRegexp
.
new
(
regex
)
...
...
lib/gitlab/untrusted_regexp.rb
View file @
4bda5b50
...
...
@@ -39,7 +39,12 @@ module Gitlab
groups
[
1
..-
1
]
end
text
.
slice!
(
0
,
match
.
end
(
0
)
||
1
)
matchsize
=
match
.
end
(
0
)
# No further matches
break
unless
matchsize
.
present?
text
.
slice!
(
0
,
matchsize
)
break
unless
text
.
present?
end
...
...
spec/lib/gitlab/ci/trace/stream_spec.rb
View file @
4bda5b50
...
...
@@ -307,5 +307,27 @@ describe Gitlab::Ci::Trace::Stream do
it
{
is_expected
.
to
eq
(
'65'
)
}
end
context
'empty regex'
do
let
(
:data
)
{
'foo'
}
let
(
:regex
)
{
''
}
it
'skips processing'
do
expect
(
stream
).
not_to
receive
(
:read
)
is_expected
.
to
be_nil
end
end
context
'nil regex'
do
let
(
:data
)
{
'foo'
}
let
(
:regex
)
{
nil
}
it
'skips processing'
do
expect
(
stream
).
not_to
receive
(
:read
)
is_expected
.
to
be_nil
end
end
end
end
spec/lib/gitlab/untrusted_regexp_spec.rb
View file @
4bda5b50
...
...
@@ -55,7 +55,7 @@ describe Gitlab::UntrustedRegexp do
let
(
:text
)
{
'foo'
}
it
'returns an array of empty matches'
do
is_expected
.
to
eq
([
''
,
''
,
''
])
is_expected
.
to
eq
([
''
])
end
end
...
...
@@ -63,8 +63,8 @@ describe Gitlab::UntrustedRegexp do
let
(
:regexp
)
{
'()'
}
let
(
:text
)
{
'foo'
}
it
'returns a
rrays
of empty matches in an array'
do
is_expected
.
to
eq
([[
''
]
,
[
''
],
[
''
]
])
it
'returns a
n array
of empty matches in an array'
do
is_expected
.
to
eq
([[
''
]])
end
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