cuba-secure_headers 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gems +4 -0
- data/LICENSE +19 -0
- data/README.md +36 -0
- data/benchmark/secure_headers.rb +56 -0
- data/cuba-secure_headers.gemspec +15 -0
- data/lib/cuba/secure_headers.rb +22 -0
- data/makefile +7 -0
- data/test/secure_headers.rb +20 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5825ac4fba6dec67702d332095ad0389af9a4f58
|
4
|
+
data.tar.gz: 0ef1043e6bb07bd07d6faa5c3c77b5615425e1a3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ae544dafa870f78eb0bf4183e4fad2a41f65533a78c5fcdb905bbce1b1e13ac170845fc859659c48294f81fd287f3c221027678a0804772d867421649764818
|
7
|
+
data.tar.gz: 3d1eb6c90eca6814c2905fc8e1de9c5e6fcceb0e03ea6bd08d64c4ba0f584a41d2ac92a35a30dd6da2229b8c7d53efa72da183a7e313f6fbbac997b7588dc762
|
data/.gems
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2015-Present Francesco Rodríguez, Mayn Kjær
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
cuba-secure_headers
|
2
|
+
===================
|
3
|
+
|
4
|
+
Security related headers for Cuba applications. It's heavily inspired
|
5
|
+
by [secureheaders][secureheaders].
|
6
|
+
|
7
|
+
Description
|
8
|
+
-----------
|
9
|
+
|
10
|
+
This gem applies the following headers:
|
11
|
+
|
12
|
+
- HTTP Strict Transport Security (HSTS) - Ensures the browser never visits the http version of a website. Protects from SSLStrip/Firesheep attacks. [HSTS Specification](https://tools.ietf.org/html/rfc6797)
|
13
|
+
- X-Frame-Options (XFO) - Prevents your content from being framed and potentially clickjacked. [X-Frame-Options draft](https://tools.ietf.org/html/draft-ietf-websec-x-frame-options-02)
|
14
|
+
- X-XSS-Protection - [Cross site scripting heuristic filter for IE/Chrome](http://msdn.microsoft.com/en-us/library/dd565647\(v=vs.85\).aspx)
|
15
|
+
- X-Content-Type-Options - [Prevent content type sniffing](http://msdn.microsoft.com/en-us/library/ie/gg622941\(v=vs.85\).aspx)
|
16
|
+
- X-Download-Options - [Prevent file downloads opening](http://msdn.microsoft.com/en-us/library/ie/jj542450(v=vs.85).aspx)
|
17
|
+
- X-Permitted-Cross-Domain-Policies - [Restrict Adobe Flash Player's access to data](https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html)
|
18
|
+
|
19
|
+
Usage
|
20
|
+
-----
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require "cuba"
|
24
|
+
require "cuba/secure_headers"
|
25
|
+
|
26
|
+
Cuba.plugin(Cuba::SecureHeaders)
|
27
|
+
```
|
28
|
+
|
29
|
+
Installation
|
30
|
+
------------
|
31
|
+
|
32
|
+
```
|
33
|
+
$ gem install cuba-secure_headers
|
34
|
+
```
|
35
|
+
|
36
|
+
[secureheaders]: https://github.com/twitter/secureheaders
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "benchmark/ips"
|
2
|
+
require "cuba"
|
3
|
+
require "rack/protection"
|
4
|
+
require_relative "../lib/cuba/secure_headers"
|
5
|
+
|
6
|
+
# Cuba::SecureHeaders sets:
|
7
|
+
#
|
8
|
+
# - X-XSS-Protection
|
9
|
+
# - X-Frame-Options
|
10
|
+
# - X-Content-Type-Options
|
11
|
+
# - X-Download-Options
|
12
|
+
# - X-Permitted-Cross-Domain-Policies
|
13
|
+
#
|
14
|
+
class CubaSecureHeaders < Cuba
|
15
|
+
plugin(Cuba::SecureHeaders)
|
16
|
+
|
17
|
+
define do
|
18
|
+
on root do
|
19
|
+
res.write("hello")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Rack::Protection only sets:
|
25
|
+
#
|
26
|
+
# - X-XSS-Protection
|
27
|
+
# - X-Frame-Options
|
28
|
+
# - X-Content-Type-Options
|
29
|
+
#
|
30
|
+
class RackProtection < Cuba
|
31
|
+
use(Rack::Protection::FrameOptions)
|
32
|
+
use(Rack::Protection::XSSHeader)
|
33
|
+
|
34
|
+
define do
|
35
|
+
on root do
|
36
|
+
res.write("hello")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Benchmark.ips do |x|
|
42
|
+
x.report("rack-protection") do
|
43
|
+
RackProtection.call("PATH_INFO" => "/", "SCRIPT_NAME" => "/")
|
44
|
+
end
|
45
|
+
|
46
|
+
x.report("cuba-secure_headers") do
|
47
|
+
CubaSecureHeaders.call("PATH_INFO" => "/", "SCRIPT_NAME" => "/")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Calculating -------------------------------------
|
52
|
+
# rack-protection 4.938k i/100ms
|
53
|
+
# cuba-secure_headers 6.750k i/100ms
|
54
|
+
# -------------------------------------------------
|
55
|
+
# rack-protection 50.248k (± 7.7%) i/s - 251.838k
|
56
|
+
# cuba-secure_headers 76.533k (± 3.5%) i/s - 384.750k
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "cuba-secure_headers"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.summary = "Secure HTTP headers for Cuba"
|
5
|
+
s.description = s.summary
|
6
|
+
s.authors = ["Francesco Rodríguez", "Mayn Kjær"]
|
7
|
+
s.email = ["frodsan@me.com", "mayn.kjaer@gmail.com"]
|
8
|
+
s.homepage = "https://github.com/harmoni-io/cuba-secure_headers"
|
9
|
+
s.license = "MIT"
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
|
13
|
+
s.add_dependency "cuba"
|
14
|
+
s.add_development_dependency "cutest"
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "cuba"
|
2
|
+
|
3
|
+
module Cuba::SecureHeaders
|
4
|
+
class SafeResponse < ::Cuba::Response
|
5
|
+
HEADERS = {
|
6
|
+
"X-Content-Type-Options" => "nosniff",
|
7
|
+
"X-Download-Options" => "noopen",
|
8
|
+
"X-Frame-Options" => "SAMEORIGIN",
|
9
|
+
"X-Permitted-Cross-Domain-Policies" => "none",
|
10
|
+
"X-XSS-Protection" => "1; mode=block",
|
11
|
+
"Strict-Transport-Security" => "max-age=631138519; includeSubdomains; preload"
|
12
|
+
}
|
13
|
+
|
14
|
+
def initialize(status = nil, headers = HEADERS.dup)
|
15
|
+
super(status, headers)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.setup(app)
|
20
|
+
app.settings[:res] = SafeResponse
|
21
|
+
end
|
22
|
+
end
|
data/makefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "cutest"
|
2
|
+
require_relative "../lib/cuba/secure_headers"
|
3
|
+
|
4
|
+
test "secure headers" do
|
5
|
+
Cuba.plugin(Cuba::SecureHeaders)
|
6
|
+
|
7
|
+
Cuba.define do
|
8
|
+
on root do
|
9
|
+
res.write("hello")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
_, headers, _ = Cuba.call("PATH_INFO" => "/", "SCRIPT_NAME" => "/")
|
14
|
+
|
15
|
+
secure_headers = Cuba::SecureHeaders::SafeResponse::HEADERS
|
16
|
+
secure_headers.each do |header, value|
|
17
|
+
assert_equal(value, headers[header])
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cuba-secure_headers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Francesco Rodríguez
|
8
|
+
- Mayn Kjær
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cuba
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: cutest
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
description: Secure HTTP headers for Cuba
|
43
|
+
email:
|
44
|
+
- frodsan@me.com
|
45
|
+
- mayn.kjaer@gmail.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gems"
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- benchmark/secure_headers.rb
|
54
|
+
- cuba-secure_headers.gemspec
|
55
|
+
- lib/cuba/secure_headers.rb
|
56
|
+
- makefile
|
57
|
+
- test/secure_headers.rb
|
58
|
+
homepage: https://github.com/harmoni-io/cuba-secure_headers
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.4.5
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Secure HTTP headers for Cuba
|
82
|
+
test_files: []
|