Skip to content

Commit c38afda

Browse files
committed
Merge pull request #225 from twitter/quality
Quality
2 parents 5084a83 + d35b310 commit c38afda

File tree

12 files changed

+548
-553
lines changed

12 files changed

+548
-553
lines changed

.gitignore

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,8 @@
66
.yardoc
77
*.log
88
Gemfile.lock
9-
InstalledFiles
109
_yardoc
1110
coverage
12-
doc/
13-
lib/bundler/man
1411
pkg
1512
rdoc
1613
spec/reports
17-
test/tmp
18-
test/version_tmp
19-
*tmp
20-
*.sqlite3
21-
fixtures/rails_3_2_12_no_init/log
22-
fixtures/rails_3_2_12/log

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ matrix:
1515
- rvm: ruby-head
1616

1717
before_install: gem update bundler
18+
bundler_args: --without guard -j 3
1819

1920
sudo: false
2021
cache: bundler

Gemfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ group :test do
66
gem "tins", "~> 1.6.0" # 1.7 requires ruby 2.0
77
gem "pry-nav"
88
gem "rack"
9+
gem "rspec"
10+
gem "coveralls"
11+
end
12+
13+
group :guard do
914
gem "guard-rspec", platforms: [:ruby_19, :ruby_20, :ruby_21, :ruby_22]
10-
gem "rspec", ">= 3.1"
1115
gem "growl"
1216
gem "rb-fsevent"
13-
gem "coveralls", platforms: [:ruby_19, :ruby_20, :ruby_21, :ruby_22]
1417
end

README.md

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ All `nil` values will fallback to their default values. `SecureHeaders::OPT_OUT`
2929

3030
```ruby
3131
SecureHeaders::Configuration.default do |config|
32-
config.hsts = "max-age=#{20.years.to_i}"
32+
config.hsts = "max-age=#{20.years.to_i}; includeSubdomains; preload"
3333
config.x_frame_options = "DENY"
3434
config.x_content_type_options = "nosniff"
3535
config.x_xss_protection = "1; mode=block"
@@ -57,13 +57,13 @@ SecureHeaders::Configuration.default do |config|
5757
plugin_types: %w(application/x-shockwave-flash),
5858
block_all_mixed_content: true, # see [http://www.w3.org/TR/mixed-content/](http://www.w3.org/TR/mixed-content/)
5959
upgrade_insecure_requests: true, # see https://www.w3.org/TR/upgrade-insecure-requests/
60-
report_uri: %w(https://example.com/uri-directive)
60+
report_uri: %w(https://report-uri.io/example-csp)
6161
}
6262
config.hpkp = {
6363
report_only: false,
6464
max_age: 60.days.to_i,
6565
include_subdomains: true,
66-
report_uri: "https://example.com/uri-directive",
66+
report_uri: "https://report-uri.io/example-hpkp",
6767
pins: [
6868
{sha256: "abc"},
6969
{sha256: "123"}
@@ -175,7 +175,7 @@ When manipulating content security policy, there are a few things to consider. T
175175

176176
#### Append to the policy with a directive other than `default_src`
177177

178-
The value of `default_src` is joined with the addition. Note the `https:` is carried over from the `default-src` config. If you do not want this, use `override_content_security_policy_directives` instead. To illustrate:
178+
The value of `default_src` is joined with the addition if the it is a [fetch directive](https://w3c.github.io/webappsec-csp/#directives-fetch). Note the `https:` is carried over from the `default-src` config. If you do not want this, use `override_content_security_policy_directives` instead. To illustrate:
179179

180180
```ruby
181181
::SecureHeaders::Configuration.default do |config|
@@ -255,7 +255,7 @@ config.hpkp = {
255255
{sha256: '73a2c64f9545172c1195efb6616ca5f7afd1df6f245407cafb90de3998a1c97f'}
256256
],
257257
report_only: true, # defaults to false (report-only mode)
258-
report_uri: '//example.com/uri-directive',
258+
report_uri: 'https://report-uri.io/example-hpkp',
259259
app_name: 'example',
260260
tag_report_uri: true
261261
}
@@ -287,43 +287,6 @@ class Donkey < Sinatra::Application
287287
end
288288
```
289289

290-
### Using with Padrino
291-
292-
You can use SecureHeaders for Padrino applications as well:
293-
294-
In your `Gemfile`:
295-
296-
```ruby
297-
gem "secure_headers", require: 'secure_headers'
298-
```
299-
300-
then in your `app.rb` file you can:
301-
302-
```ruby
303-
Padrino.use(SecureHeaders::Middleware)
304-
require 'secure_headers/padrino'
305-
306-
module Web
307-
class App < Padrino::Application
308-
register SecureHeaders::Padrino
309-
310-
get '/' do
311-
render 'index'
312-
end
313-
end
314-
end
315-
```
316-
317-
and in `config/boot.rb`:
318-
319-
```ruby
320-
def before_load
321-
SecureHeaders::Configuration.default do |config|
322-
...
323-
end
324-
end
325-
```
326-
327290
## Similar libraries
328291

329292
* Rack [rack-secure_headers](https://github.com/frodsan/rack-secure_headers)

0 commit comments

Comments
 (0)