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
1081915a
Commit
1081915a
authored
Aug 09, 2021
by
dcouture
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify CSP when sentry is configured
parent
c3be0d38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
lib/gitlab/content_security_policy/config_loader.rb
lib/gitlab/content_security_policy/config_loader.rb
+9
-0
spec/lib/gitlab/content_security_policy/config_loader_spec.rb
.../lib/gitlab/content_security_policy/config_loader_spec.rb
+12
-0
No files found.
lib/gitlab/content_security_policy/config_loader.rb
View file @
1081915a
...
...
@@ -38,6 +38,7 @@ module Gitlab
allow_webpack_dev_server
(
settings_hash
)
if
Rails
.
env
.
development?
allow_cdn
(
settings_hash
)
if
ENV
[
'GITLAB_CDN_HOST'
].
present?
allow_customersdot
(
settings_hash
)
if
Rails
.
env
.
development?
&&
ENV
[
'CUSTOMER_PORTAL_URL'
].
present?
allow_sentry
(
settings_hash
)
if
Gitlab
.
config
.
sentry
&
.
enabled
&&
Gitlab
.
config
.
sentry
&
.
clientside_dsn
settings_hash
end
...
...
@@ -92,6 +93,14 @@ module Gitlab
append_to_directive
(
settings_hash
,
'frame_src'
,
customersdot_host
)
end
def
self
.
allow_sentry
(
settings_hash
)
sentry_dsn
=
Gitlab
.
config
.
sentry
.
clientside_dsn
sentry_uri
=
URI
(
sentry_dsn
)
sentry_uri
.
user
=
nil
append_to_directive
(
settings_hash
,
'connect_src'
,
sentry_uri
.
to_s
)
end
end
end
end
spec/lib/gitlab/content_security_policy/config_loader_spec.rb
View file @
1081915a
...
...
@@ -62,6 +62,18 @@ RSpec.describe Gitlab::ContentSecurityPolicy::ConfigLoader do
end
end
context
'when sentry is configured'
do
before
do
stub_sentry_settings
end
it
'adds sentry path to CSP without user'
do
directives
=
settings
[
'directives'
]
expect
(
directives
[
'connect_src'
]).
to
eq
(
"'self' dummy://example.com/43"
)
end
end
context
'when CUSTOMER_PORTAL_URL is set'
do
before
do
stub_env
(
'CUSTOMER_PORTAL_URL'
,
'https://customers.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