Commit c210f43a authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch 'default-disallow-pages-nfs-web-server-access' into 'master'

Disallow Pages access in web server

See merge request gitlab-org/gitlab!42063
parents 2ec094d7 132443cf
......@@ -6,7 +6,7 @@ module Gitlab
DiskAccessDenied = Class.new(StandardError)
def path
if ::Gitlab::Runtime.web_server? && ENV['GITLAB_PAGES_DENY_DISK_ACCESS'] == '1'
if ::Gitlab::Runtime.web_server? && !::Gitlab::Runtime.test_suite?
raise DiskAccessDenied
end
......
......@@ -10,22 +10,15 @@ RSpec.describe Gitlab::Pages::Settings do
it { is_expected.to eq('the path') }
context 'when running under a web server' do
context 'when running under a web server outside of test mode' do
before do
allow(::Gitlab::Runtime).to receive(:test_suite?).and_return(false)
allow(::Gitlab::Runtime).to receive(:web_server?).and_return(true)
end
it { is_expected.to eq('the path') }
context 'with the env var' do
before do
stub_env('GITLAB_PAGES_DENY_DISK_ACCESS', '1')
end
it 'raises a DiskAccessDenied exception' do
expect { subject }.to raise_error(described_class::DiskAccessDenied)
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment