You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by robertkowalski <gi...@git.apache.org> on 2014/05/17 20:33:40 UTC
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
GitHub user robertkowalski opened a pull request:
https://github.com/apache/couchdb/pull/233
Add Experimental Content-Security-Policy-Support (CSP) for Fauxton
Like every web application, Fauxton is vulnerable against XSS
and CSP is a technology that tries to help against that.
The patch makes it possible to enable CSP for the /_utils path
and allows configuration of the sent header.
The default setting for the value of the header breaks the old
Futon, when CSP is enabled there. The old Futon has alot of
inline-JavaScript which is not allowed in the setting I have
chosen as default.
For development, the header is also sent from the node server
which launches Fauxton in dev-mode.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/robertkowalski/couchdb erlang-csp
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/couchdb/pull/233.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #233
----
commit 5262d5626ff85aa19eeb451f240bc63e7a9e440c
Author: Robert Kowalski <ro...@kowalski.gd>
Date: 2014-05-17T16:37:30Z
Add Experimental Content-Security-Policy-Support (CSP) for Fauxton
Like every web application, Fauxton is vulnerable against XSS
and CSP is a technology that tries to help against that.
The patch makes it possible to enable CSP for the /_utils path
and allows configuration of the sent header.
The default setting for the value of the header breaks the old
Futon, when CSP is enabled there. The old Futon has alot of
inline-JavaScript which is not allowed in the setting I have
chosen as default.
For development, the header is also sent from the node server
which launches Fauxton in dev-mode.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12857351
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
+ "script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline';",
+ Value = couch_config:get("csp", "header_value", DefaultValues),
+ Headers ++ [{"Content-Security-Policy", Value}].
--- End diff --
@kxepal:
We are shipping a binary for Windows, but this does not mean we have to support every particular case that runs on Windows for the Webinterface. For Windows users with Chrome or Firefox the feature just works. Another example would be our CORS Feature which is not supported by IE 7 and just partially by IE 8 & IE 9 (source: http://caniuse.com/cors)
And this new feature supports Graceful Degration: for IE users it stays like it is currently (and it is not that bad, just read further), Fauxton will keep working for them. We are supporting the W3C Standard and every browser which implements it, can make use of it.
Because we are supporting standarts, and not supporting proprietary technology these technologies will hopefully make more use of open web standarts in the future - supporting them means that these technologies will stay longer on the market and stick with long release/update cycles.
If we are talking about http://www.w3.org/TR/CSP11/ and the reflected-xss directive the spec reads for me that the directive is just an equivalent to X-XSS-Protection and not exactly the same header that is standarized for old browsers. They are just creating a kind of mapping which is meant to subsume the functionality of X-XSS-Protection which works in another way than the Content-Security-Policy header (I think it is used in IE to disable the default XSS protection). Regarding the IE8 and upwards the docs of MSDN says: "Internet Explorer 8 included a novel new feature to help prevent reflected cross-site scripting attacks, known as the XSS Filter. This filter runs by default in the Internet, [...]" (source: http://blogs.msdn.com/b/ieinternals/archive/2011/01/31/controlling-the-internet-explorer-xss-filter-with-the-x-xss-protection-http-header.aspx), and that would mean that it is enabled by default. As we do not send something to disable it, everything should be fine as they a
re implementing their own proprietary XSS filter that is enabled by default.
In the end this would mean that IE > 8 has an own implementation of XSS filters and that would mean that we have to do nothing here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:
https://github.com/apache/couchdb/pull/233#issuecomment-45273835
Ok, I applied all suggested changes and added docs.
As PR #235 landed I could also restrict the fonts to font: 'self'
May someone take a final look before I merge? - it is my first Erlang patch :)
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:
https://github.com/apache/couchdb/pull/233#issuecomment-45314672
Remember not to merge these 9 commits directly. Please reconstitute the patch into logical components before merge.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r13480805
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
--- End diff --
explicit clauses for just "false" and "true" will lead to ugly crashes if a user sets config to a different value. Instead, and like many other places, match "true" in the first case and _ in the second. That is, only exactly "true" enables this.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r13480746
--- Diff: etc/couchdb/default.ini.tpl.in ---
@@ -88,6 +88,10 @@ credentials = false
; List of accepted methods
; methods =
+; Experimental CSP (Content Security Policy) Support for _utils
+[csp]
+enable_csp = false
--- End diff --
maybe just "enable", since we're in the [csp] section?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12776633
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
+ "script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline';",
+ Value = couch_config:get("csp", "header_value", DefaultValues),
+ Headers ++ [{"Content-Security-Policy", Value}].
--- End diff --
I see the point to bring this feature even to users with old browsers, but I have mixed feelings about that: the `Content-Security-Policy` header is defined by a W3C Spec, the other headers not.
I am personally not a big fan of the other versions, especially the IE 8 and 9 one, as they are not a part of a spec and just used by special browsers.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:
https://github.com/apache/couchdb/pull/233#issuecomment-45476687
fwiw, example.com is a good substitute, it's explicitly reserved for example urls
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12772146
--- Diff: etc/couchdb/default.ini.tpl.in ---
@@ -88,6 +88,10 @@ credentials = false
; List of accepted methods
; methods =
+; Experimental CSP (Content Security Policy) Support for _utils
+[csp]
+; enable_csp = true
--- End diff --
How about explicitly say there, that `enable_csp = false`, as default behaviour instructs? Otherwise it's hard to say is commented `true` reflects default value or not.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:
https://github.com/apache/couchdb/pull/233#issuecomment-44547510
I will see if I get #235 merged before: I could remove the `font: *` then
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12776692
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
+ "script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline';",
+ Value = couch_config:get("csp", "header_value", DefaultValues),
+ Headers ++ [{"Content-Security-Policy", Value}].
--- End diff --
Well, `X-Content-Security-Policy` was used during experimental period: so can cover modern IEs and older browsers with no cost. As for `X-XSS-Protection` you can say, that it's a part of `CSP 1.1` spec which by the way covers some old browsers for today. In anyway, ignoring IE is hard since we're doing Windows releases and it's still on the market (:
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on the pull request:
https://github.com/apache/couchdb/pull/233#issuecomment-43431565
Good idea!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12772196
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
+ "script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline';",
+ Value = couch_config:get("csp", "header_value", DefaultValues),
+ Headers ++ [{"Content-Security-Policy", Value}].
--- End diff --
And as for IE 8 and 9 (which are also remains popular) there is need to use [X-XSS-Protection](http://blogs.msdn.com/b/ieinternals/archive/2011/01/31/controlling-the-internet-explorer-xss-filter-with-the-x-xss-protection-http-header.aspx) header instead.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12776674
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
--- End diff --
Good questions! Here are the points I found:
- Regarding fonts: we are loading currently fonts from a netdna cdn, I want to remove this already in https://issues.apache.org/jira/browse/COUCHDB-2238
- `unsafe-eval`: our dependency lodash needs it for the templating if I remember right
- img-src will have a look again and change it, if everything works
- style-src: we are having a lot of inline styles where we depend on, sometimes it is not that easy to remove them
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12772159
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
+ "script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline';",
+ Value = couch_config:get("csp", "header_value", DefaultValues),
+ Headers ++ [{"Content-Security-Policy", Value}].
--- End diff --
Need to note, that IE 10 and 11 supports only `X-Content-Security-Policy ` header. This wouldn't a problem unless these versions are the most modern for now /:
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12858278
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
+ "script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline';",
+ Value = couch_config:get("csp", "header_value", DefaultValues),
+ Headers ++ [{"Content-Security-Policy", Value}].
--- End diff --
@robertkowalski All good points. I have nothing to say and no objections about, +1. I'll quote your statements for docs on CSP about IE support when you merge (or you can add these to docs by your own as part of this PR).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on the pull request:
https://github.com/apache/couchdb/pull/233#issuecomment-45516297
landed as 3bcf664b2f46750bf64bf970da07f9b133f980 - thank you all for your support!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on the pull request:
https://github.com/apache/couchdb/pull/233#issuecomment-45317416
+1 after addressing those comments and squashing these 9 commits into something more readable for future historians. Nice!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12869615
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
--- End diff --
Good to know!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12782602
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
--- End diff --
No need for ++ to join these strings, you can just split the string across multiple lines, each surrounded by double quotes.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski closed the pull request at:
https://github.com/apache/couchdb/pull/233
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12772184
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
--- End diff --
Why not to replace all these with just `allow 'self';` ? Looks good and solid default behaviour. Is there any need in external images, fonts, unsafe arbitrary code execution and style inline (you may inline style with JS code to overrun XSS policy)?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by robertkowalski <gi...@git.apache.org>.
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12776632
--- Diff: etc/couchdb/default.ini.tpl.in ---
@@ -88,6 +88,10 @@ credentials = false
; List of accepted methods
; methods =
+; Experimental CSP (Content Security Policy) Support for _utils
+[csp]
+; enable_csp = true
--- End diff --
good point! i will change that!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by kxepal <gi...@git.apache.org>.
Github user kxepal commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12776722
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
--- End diff --
I see. OK then. Just wanted to ensure that they're set as minimum as required (:
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] couchdb pull request: Add Experimental Content-Security-Policy-Sup...
Posted by rnewson <gi...@git.apache.org>.
Github user rnewson commented on a diff in the pull request:
https://github.com/apache/couchdb/pull/233#discussion_r12782501
--- Diff: src/couchdb/couch_httpd_misc_handlers.erl ---
@@ -79,6 +80,15 @@ handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
handle_utils_dir_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
+maybe_add_csp_headers(Headers, "false") ->
+ Headers;
+maybe_add_csp_headers(Headers, "true") ->
+ DefaultValues = "default-src 'self'; img-src *; font-src *; " ++
+ "script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline';",
+ Value = couch_config:get("csp", "header_value", DefaultValues),
+ Headers ++ [{"Content-Security-Policy", Value}].
--- End diff --
Use [{"Content-Security-Policy", Value} | Headers], please. (faster).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---