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
9dae1a2e
Commit
9dae1a2e
authored
Jul 28, 2020
by
Jacob Vosmaer
Committed by
Jan Provaznik
Jul 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track web server access to Settings.pages.path
parent
361cf070
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
1 deletion
+71
-1
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
lib/gitlab/pages.rb
lib/gitlab/pages.rb
+1
-1
lib/gitlab/pages/settings.rb
lib/gitlab/pages/settings.rb
+21
-0
spec/lib/gitlab/pages/settings_spec.rb
spec/lib/gitlab/pages/settings_spec.rb
+48
-0
No files found.
config/initializers/1_settings.rb
View file @
9dae1a2e
...
...
@@ -283,6 +283,7 @@ Settings.sentry['clientside_dsn'] ||= nil
# Pages
#
Settings
[
'pages'
]
||=
Settingslogic
.
new
({})
Settings
[
'pages'
]
=
::
Gitlab
::
Pages
::
Settings
.
new
(
Settings
.
pages
)
# For path access detection https://gitlab.com/gitlab-org/gitlab/-/issues/230702
Settings
.
pages
[
'enabled'
]
=
false
if
Settings
.
pages
[
'enabled'
].
nil?
Settings
.
pages
[
'access_control'
]
=
false
if
Settings
.
pages
[
'access_control'
].
nil?
Settings
.
pages
[
'path'
]
=
Settings
.
absolute
(
Settings
.
pages
[
'path'
]
||
File
.
join
(
Settings
.
shared
[
'path'
],
"pages"
))
...
...
lib/gitlab/pages.rb
View file @
9dae1a2e
# frozen_string_literal: true
module
Gitlab
class
Pages
module
Pages
VERSION
=
File
.
read
(
Rails
.
root
.
join
(
"GITLAB_PAGES_VERSION"
)).
strip
.
freeze
INTERNAL_API_REQUEST_HEADER
=
'Gitlab-Pages-Api-Request'
.
freeze
MAX_SIZE
=
1
.
terabyte
...
...
lib/gitlab/pages/settings.rb
0 → 100644
View file @
9dae1a2e
# frozen_string_literal: true
module
Gitlab
module
Pages
class
Settings
<
::
SimpleDelegator
DiskAccessDenied
=
Class
.
new
(
StandardError
)
def
path
if
::
Gitlab
::
Runtime
.
web_server?
&&
ENV
[
'GITLAB_PAGES_DENY_DISK_ACCESS'
]
==
'1'
begin
raise
DiskAccessDenied
rescue
DiskAccessDenied
=>
ex
::
Gitlab
::
ErrorTracking
.
track_exception
(
ex
)
end
end
super
end
end
end
end
spec/lib/gitlab/pages/settings_spec.rb
0 → 100644
View file @
9dae1a2e
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Pages
::
Settings
do
describe
'#path'
do
subject
{
described_class
.
new
(
settings
).
path
}
let
(
:settings
)
{
double
(
path:
'the path'
)
}
it
{
is_expected
.
to
eq
(
'the path'
)
}
it
'does not track calls'
do
expect
(
::
Gitlab
::
ErrorTracking
).
not_to
receive
(
:track_exception
)
subject
end
context
'when running under a web server'
do
before
do
allow
(
::
Gitlab
::
Runtime
).
to
receive
(
:web_server?
).
and_return
(
true
)
end
it
{
is_expected
.
to
eq
(
'the path'
)
}
it
'does not track calls'
do
expect
(
::
Gitlab
::
ErrorTracking
).
not_to
receive
(
:track_exception
)
subject
end
context
'with the env var'
do
before
do
stub_env
(
'GITLAB_PAGES_DENY_DISK_ACCESS'
,
'1'
)
end
it
{
is_expected
.
to
eq
(
'the path'
)
}
it
'tracks a DiskAccessDenied exception'
do
expect
(
::
Gitlab
::
ErrorTracking
).
to
receive
(
:track_exception
)
.
with
(
instance_of
(
described_class
::
DiskAccessDenied
)).
and_call_original
subject
end
end
end
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