Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd security related headers to build.servo.org #511
Conversation
Add some headers to `build.servo.org` to improve our Mozilla Observatory score. The helps the cause of #473, by raising our score from F (0) to a whopping B- (65). The testing is still basic, the docker-observatory based testing will go in a different PR. To get to an A+ we must first implement https. This is the local observatory report: Score Rule Description -20 redirection Does not redirect to an https site. -20 strict-transport-security HTTP Strict Transport Security (HSTS) header cannot be set for sites not available over https. -5 contribute Contribute.json file missing from root of website. 5 content-security-policy Content Security Policy (CSP) implemented without 'unsafe-inline' or 'unsafe-eval'. 5 x-frame-options X-Frame-Options (XFO) implemented via the CSP frame-ancestors directive. Score: 65 Grade: B-
highfive
commented
Oct 17, 2016
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @aneeshusa (or someone else) soon. |
|
@jarondl Can you point me to some documentation about the |
|
Yes, contribute.json is quite obscure. I have found out about it only when I've browsed through the observatory code to resolve some issues.
The list of mozilla related sites is hard coded here: https://github.com/mozilla/http-observatory/blob/7dd04ff5b51e39698a8b683df33ef430b4ed4213/httpobs/conf/httpobs.conf#L33 |
|
I believe the tests have failed because buildbot is down in travis. This should be solved by #505, right? |
|
Buildbot immediately stops on Travis after being started (due to our fake test credentials not validating IIRC), which I don't have an easy fix for. In the meantime, I believe this is why I added the |
|
Sorry about the delay in reviewing. The headers themselves and the test case look good modulo a few nits, the Salt side needs a little more work. |
| @@ -0,0 +1,15 @@ | |||
| # The following headers were added to pass the mozilla http observatory | |||
This comment has been minimized.
This comment has been minimized.
| @@ -0,0 +1,15 @@ | |||
| # The following headers were added to pass the mozilla http observatory | |||
| # test suit. | |||
This comment has been minimized.
This comment has been minimized.
| # All of them are very simple in this case, because both homu and buildbot | ||
| # do not use external resources. | ||
|
|
||
| # CSP is the most important one |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Oct 30, 2016
Member
The options we're setting are fairly basic and IMO the headers are readable enough as is that we don't need an expository comment for each one.
| @@ -14,6 +14,15 @@ nginx: | |||
| - watch_in: | |||
| - service: nginx | |||
|
|
|||
| /etc/nginx/conf.d/https_headers.conf: | |||
| file.managed: | |||
| - source: salt://nginx/https_headers.conf | |||
This comment has been minimized.
This comment has been minimized.
aneeshusa
Oct 30, 2016
Member
Use salt://{{ tpldir }}/files/https_headers.conf, and make a files subdir to put the config file in.
I'm not sure how well you know Salt, but we'll also want the /etc/nginx/conf.d state from #375 and some requisites to order things correctly/restart nginx automatically on config change. I can also take care of this if you'd like.
| failures = [] | ||
| for header in expected_headers: | ||
| if header not in actual_headers: | ||
| failures.append('Missing or changed header - {}:{}'.format(*header)) |
This comment has been minimized.
This comment has been minimized.
| "default-src 'self'; frame-ancestors 'none'"), | ||
| ('X-Frame-Options', 'DENY'), | ||
| ('X-XSS-Protection', '1; mode=block'), | ||
| ('X-Content-Type-Options', 'nosniff')] |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Oct 30, 2016
Member
style nit: leave a trailing comma after this last tuple, and put the closing ] by itself on the next line.
| failures.append('Missing or changed header - {}:{}'.format(*header)) | ||
|
|
||
| if len(failures) > 0: | ||
| return Failure('nginx is serving wrong securirty headers', |
This comment has been minimized.
This comment has been minimized.
|
Also, please open a separate issue about |
|
Hi @aneeshusa , thanks for reviewing, I will work on it. |
|
I'm going to close this as it's been inactive for a while; anyone is welcome to pick this work up again. |
jarondl commentedOct 17, 2016
•
edited
Add some headers to
build.servo.orgto improve our Mozilla Observatoryscore. The helps the cause of #473, by raising our score from F (0) to a
whopping B- (65). The testing is still basic, the docker-observatory
based testing will go in a different PR.
To get to an A+ we must first implement https.
This is the local observatory report:
This change is