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
226b5c8d
Commit
226b5c8d
authored
Jun 01, 2021
by
dcouture
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set CSP back to disabled by default
Changelog: fixed
parent
1532ff00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
lib/gitlab/content_security_policy/config_loader.rb
lib/gitlab/content_security_policy/config_loader.rb
+1
-1
spec/lib/gitlab/content_security_policy/config_loader_spec.rb
.../lib/gitlab/content_security_policy/config_loader_spec.rb
+12
-3
No files found.
lib/gitlab/content_security_policy/config_loader.rb
View file @
226b5c8d
...
...
@@ -9,7 +9,7 @@ module Gitlab
def
self
.
default_settings_hash
settings_hash
=
{
'enabled'
=>
true
,
'enabled'
=>
Rails
.
env
.
development?
||
Rails
.
env
.
test?
,
'report_only'
=>
false
,
'directives'
=>
{
'default_src'
=>
"'self'"
,
...
...
spec/lib/gitlab/content_security_policy/config_loader_spec.rb
View file @
226b5c8d
...
...
@@ -20,9 +20,9 @@ RSpec.describe Gitlab::ContentSecurityPolicy::ConfigLoader do
end
describe
'.default_settings_hash'
do
it
'returns defaults for all keys'
do
settings
=
described_class
.
default_settings_hash
let
(
:settings
)
{
described_class
.
default_settings_hash
}
it
'returns defaults for all keys'
do
expect
(
settings
[
'enabled'
]).
to
be_truthy
expect
(
settings
[
'report_only'
]).
to
be_falsey
...
...
@@ -38,13 +38,22 @@ RSpec.describe Gitlab::ContentSecurityPolicy::ConfigLoader do
expect
(
directives
[
'child_src'
]).
to
eq
(
directives
[
'frame_src'
])
end
context
'when in production'
do
before
do
allow
(
Rails
).
to
receive
(
:env
).
and_return
(
ActiveSupport
::
StringInquirer
.
new
(
'production'
))
end
it
'is disabled'
do
expect
(
settings
[
'enabled'
]).
to
be_falsey
end
end
context
'when GITLAB_CDN_HOST is set'
do
before
do
stub_env
(
'GITLAB_CDN_HOST'
,
'https://example.com'
)
end
it
'adds GITLAB_CDN_HOST to CSP'
do
settings
=
described_class
.
default_settings_hash
directives
=
settings
[
'directives'
]
expect
(
directives
[
'script_src'
]).
to
eq
(
"'strict-dynamic' 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/ https://www.recaptcha.net https://apis.google.com https://example.com"
)
...
...
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