Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Mastodon
Commits
623d3d2e
Unverified
Commit
623d3d2e
authored
2 years ago
by
Claire
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Change CSP directives on API to be tight and concise (#20960)
parent
19f78ea8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/api/base_controller.rb
+20
-0
20 additions, 0 deletions
app/controllers/api/base_controller.rb
with
20 additions
and
0 deletions
app/controllers/api/base_controller.rb
+
20
−
0
View file @
623d3d2e
...
...
@@ -16,6 +16,26 @@ class Api::BaseController < ApplicationController
protect_from_forgery
with: :null_session
content_security_policy
do
|
p
|
# Set every directive that does not have a fallback
p
.
default_src
:none
p
.
frame_ancestors
:none
p
.
form_action
:none
# Disable every directive with a fallback to cut on response size
p
.
base_uri
false
p
.
font_src
false
p
.
img_src
false
p
.
style_src
false
p
.
media_src
false
p
.
frame_src
false
p
.
manifest_src
false
p
.
connect_src
false
p
.
script_src
false
p
.
child_src
false
p
.
worker_src
false
end
rescue_from
ActiveRecord
::
RecordInvalid
,
Mastodon
::
ValidationError
do
|
e
|
render
json:
{
error:
e
.
to_s
},
status:
422
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment