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
08b10ced
Commit
08b10ced
authored
Jan 18, 2022
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log untrusted regexp usage without project context too
parent
19e592d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
lib/gitlab/untrusted_regexp/ruby_syntax.rb
lib/gitlab/untrusted_regexp/ruby_syntax.rb
+6
-10
No files found.
lib/gitlab/untrusted_regexp/ruby_syntax.rb
View file @
08b10ced
...
...
@@ -20,8 +20,8 @@ module Gitlab
!!
self
.
fabricate
(
pattern
,
fallback:
fallback
)
end
def
self
.
fabricate
(
pattern
,
fallback:
false
)
self
.
fabricate!
(
pattern
,
fallback:
fallback
)
def
self
.
fabricate
(
pattern
,
fallback:
false
,
project:
nil
)
self
.
fabricate!
(
pattern
,
fallback:
fallback
,
project:
project
)
rescue
RegexpError
nil
end
...
...
@@ -38,13 +38,13 @@ module Gitlab
raise
unless
fallback
&&
Feature
.
enabled?
(
:allow_unsafe_ruby_regexp
,
default_enabled:
false
)
if
log_untrusted_ruby_regexp?
(
project
)
if
Feature
.
enabled?
(
:ci_unsafe_regexp_logger
,
type: :ops
,
default_enabled: :yaml
)
Gitlab
::
AppJsonLogger
.
info
(
class:
self
.
class
.
name
,
regexp:
pattern
.
to_s
regexp:
pattern
.
to_s
,
fabricated:
'unsafe ruby regexp'
,
project_id:
project
.
id
,
project_path:
project
.
full_path
,
project_id:
project
&
.
id
,
project_path:
project
&
.
full_path
)
end
...
...
@@ -52,10 +52,6 @@ module Gitlab
end
end
def
log_untrusted_ruby_regexp?
(
project
)
project
.
present?
&&
Feature
.
enabled?
(
:ci_unsafe_regexp_logger
,
project
,
type: :ops
,
default_enabled: :yaml
)
end
def
self
.
create_untrusted_regexp
(
pattern
,
flags
)
pattern
.
prepend
(
"(?
#{
flags
}
)"
)
if
flags
.
present?
...
...
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