BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d60b09d9
Commit
d60b09d9
authored
Jul 22, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'short-circuit-coverage-with-empty-regex' into 'master'
Short-circuit build coverage extraction for empty regexes See merge request !13015
parents
754d8cae
4bda5b50
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
5 deletions
+32
-5
stream.rb
lib/gitlab/ci/trace/stream.rb
+1
-1
untrusted_regexp.rb
lib/gitlab/untrusted_regexp.rb
+6
-1
stream_spec.rb
spec/lib/gitlab/ci/trace/stream_spec.rb
+22
-0
untrusted_regexp_spec.rb
spec/lib/gitlab/untrusted_regexp_spec.rb
+3
-3
No files found.
lib/gitlab/ci/trace/stream.rb
View file @
d60b09d9
...
...
@@ -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 @
d60b09d9
...
...
@@ -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 @
d60b09d9
...
...
@@ -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 @
d60b09d9
...
...
@@ -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