secure_headers 6.7.0 → 7.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -2
  3. data/README.md +78 -14
  4. data/lib/secure_headers/configuration.rb +54 -7
  5. data/lib/secure_headers/headers/clear_site_data.rb +31 -33
  6. data/lib/secure_headers/headers/content_security_policy.rb +61 -13
  7. data/lib/secure_headers/headers/content_security_policy_config.rb +2 -2
  8. data/lib/secure_headers/headers/cookie.rb +2 -4
  9. data/lib/secure_headers/headers/expect_certificate_transparency.rb +20 -22
  10. data/lib/secure_headers/headers/policy_management.rb +27 -9
  11. data/lib/secure_headers/headers/referrer_policy.rb +20 -22
  12. data/lib/secure_headers/headers/reporting_endpoints.rb +54 -0
  13. data/lib/secure_headers/headers/strict_transport_security.rb +13 -15
  14. data/lib/secure_headers/headers/x_content_type_options.rb +14 -16
  15. data/lib/secure_headers/headers/x_download_options.rb +14 -16
  16. data/lib/secure_headers/headers/x_frame_options.rb +14 -16
  17. data/lib/secure_headers/headers/x_permitted_cross_domain_policies.rb +14 -16
  18. data/lib/secure_headers/headers/x_xss_protection.rb +14 -16
  19. data/lib/secure_headers/middleware.rb +11 -7
  20. data/lib/secure_headers/railtie.rb +11 -8
  21. data/lib/secure_headers/task_helper.rb +65 -0
  22. data/lib/secure_headers/version.rb +1 -1
  23. data/lib/secure_headers.rb +26 -2
  24. data/lib/tasks/tasks.rake +4 -53
  25. data/secure_headers.gemspec +16 -4
  26. metadata +32 -67
  27. data/.github/ISSUE_TEMPLATE.md +0 -41
  28. data/.github/PULL_REQUEST_TEMPLATE.md +0 -20
  29. data/.github/dependabot.yml +0 -6
  30. data/.github/workflows/build.yml +0 -24
  31. data/.github/workflows/github-release.yml +0 -28
  32. data/.gitignore +0 -13
  33. data/.rspec +0 -3
  34. data/.rubocop.yml +0 -4
  35. data/.ruby-gemset +0 -1
  36. data/.ruby-version +0 -1
  37. data/CODE_OF_CONDUCT.md +0 -46
  38. data/CONTRIBUTING.md +0 -41
  39. data/Guardfile +0 -13
  40. data/Rakefile +0 -32
  41. data/docs/cookies.md +0 -65
  42. data/docs/hashes.md +0 -64
  43. data/docs/named_overrides_and_appends.md +0 -104
  44. data/docs/per_action_configuration.md +0 -139
  45. data/docs/sinatra.md +0 -25
  46. data/docs/upgrading-to-3-0.md +0 -42
  47. data/docs/upgrading-to-4-0.md +0 -35
  48. data/docs/upgrading-to-5-0.md +0 -15
  49. data/docs/upgrading-to-6-0.md +0 -50
  50. data/spec/lib/secure_headers/configuration_spec.rb +0 -121
  51. data/spec/lib/secure_headers/headers/clear_site_data_spec.rb +0 -87
  52. data/spec/lib/secure_headers/headers/content_security_policy_spec.rb +0 -215
  53. data/spec/lib/secure_headers/headers/cookie_spec.rb +0 -179
  54. data/spec/lib/secure_headers/headers/expect_certificate_transparency_spec.rb +0 -42
  55. data/spec/lib/secure_headers/headers/policy_management_spec.rb +0 -265
  56. data/spec/lib/secure_headers/headers/referrer_policy_spec.rb +0 -91
  57. data/spec/lib/secure_headers/headers/strict_transport_security_spec.rb +0 -33
  58. data/spec/lib/secure_headers/headers/x_content_type_options_spec.rb +0 -31
  59. data/spec/lib/secure_headers/headers/x_download_options_spec.rb +0 -29
  60. data/spec/lib/secure_headers/headers/x_frame_options_spec.rb +0 -36
  61. data/spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb +0 -48
  62. data/spec/lib/secure_headers/headers/x_xss_protection_spec.rb +0 -47
  63. data/spec/lib/secure_headers/middleware_spec.rb +0 -117
  64. data/spec/lib/secure_headers/view_helpers_spec.rb +0 -192
  65. data/spec/lib/secure_headers_spec.rb +0 -516
  66. data/spec/spec_helper.rb +0 -64
@@ -11,6 +11,7 @@ require "secure_headers/headers/x_permitted_cross_domain_policies"
11
11
  require "secure_headers/headers/referrer_policy"
12
12
  require "secure_headers/headers/clear_site_data"
13
13
  require "secure_headers/headers/expect_certificate_transparency"
14
+ require "secure_headers/headers/reporting_endpoints"
14
15
  require "secure_headers/middleware"
15
16
  require "secure_headers/railtie"
16
17
  require "secure_headers/view_helper"
@@ -133,6 +134,7 @@ module SecureHeaders
133
134
  # request.
134
135
  #
135
136
  # StrictTransportSecurity is not applied to http requests.
137
+ # upgrade_insecure_requests is not applied to http requests.
136
138
  # See #config_for to determine which config is used for a given request.
137
139
  #
138
140
  # Returns a hash of header names => header values. The value
@@ -146,6 +148,11 @@ module SecureHeaders
146
148
 
147
149
  if request.scheme != HTTPS
148
150
  headers.delete(StrictTransportSecurity::HEADER_NAME)
151
+
152
+ # Remove upgrade_insecure_requests from CSP headers for HTTP requests
153
+ # as it doesn't make sense to upgrade requests when the page itself is served over HTTP
154
+ remove_upgrade_insecure_requests_from_csp!(headers, config.csp)
155
+ remove_upgrade_insecure_requests_from_csp!(headers, config.csp_report_only)
149
156
  end
150
157
  headers
151
158
  end
@@ -178,7 +185,7 @@ module SecureHeaders
178
185
  content_security_policy_nonce(request, ContentSecurityPolicy::STYLE_SRC)
179
186
  end
180
187
 
181
- # Public: Retreives the config for a given header type:
188
+ # Public: Retrieves the config for a given header type:
182
189
  #
183
190
  # Checks to see if there is an override for this request, then
184
191
  # Checks to see if a named override is used for this request, then
@@ -208,7 +215,7 @@ module SecureHeaders
208
215
 
209
216
  def config_and_target(request, target)
210
217
  config = config_for(request)
211
- target = guess_target(config) unless target
218
+ target ||= guess_target(config)
212
219
  raise_on_unknown_target(target)
213
220
  [config, target]
214
221
  end
@@ -242,6 +249,23 @@ module SecureHeaders
242
249
  def override_secure_headers_request_config(request, config)
243
250
  request.env[SECURE_HEADERS_CONFIG] = config
244
251
  end
252
+
253
+ # Private: removes upgrade_insecure_requests directive from a CSP config
254
+ # if it's present, and updates the headers hash with the modified CSP.
255
+ #
256
+ # headers - the headers hash to update
257
+ # csp_config - the CSP config to check and potentially modify
258
+ #
259
+ # Returns nothing (modifies headers in place)
260
+ def remove_upgrade_insecure_requests_from_csp!(headers, csp_config)
261
+ return if csp_config.opt_out?
262
+ return unless csp_config.directive_value(ContentSecurityPolicy::UPGRADE_INSECURE_REQUESTS)
263
+
264
+ modified_config = csp_config.dup
265
+ modified_config.update_directive(ContentSecurityPolicy::UPGRADE_INSECURE_REQUESTS, false)
266
+ header_name, value = ContentSecurityPolicy.make_header(modified_config)
267
+ headers[header_name] = value if header_name && value
268
+ end
245
269
  end
246
270
 
247
271
  # These methods are mixed into controllers and delegate to the class method
data/lib/tasks/tasks.rake CHANGED
@@ -1,58 +1,8 @@
1
1
  # frozen_string_literal: true
2
- INLINE_SCRIPT_REGEX = /(<script(\s*(?!src)([\w\-])+=([\"\'])[^\"\']+\4)*\s*>)(.*?)<\/script>/mx unless defined? INLINE_SCRIPT_REGEX
3
- INLINE_STYLE_REGEX = /(<style[^>]*>)(.*?)<\/style>/mx unless defined? INLINE_STYLE_REGEX
4
- INLINE_HASH_SCRIPT_HELPER_REGEX = /<%=\s?hashed_javascript_tag(.*?)\s+do\s?%>(.*?)<%\s*end\s*%>/mx unless defined? INLINE_HASH_SCRIPT_HELPER_REGEX
5
- INLINE_HASH_STYLE_HELPER_REGEX = /<%=\s?hashed_style_tag(.*?)\s+do\s?%>(.*?)<%\s*end\s*%>/mx unless defined? INLINE_HASH_STYLE_HELPER_REGEX
2
+ require "secure_headers/task_helper"
6
3
 
7
4
  namespace :secure_headers do
8
- include SecureHeaders::HashHelper
9
-
10
- def is_erb?(filename)
11
- filename =~ /\.erb\Z/
12
- end
13
-
14
- def is_mustache?(filename)
15
- filename =~ /\.mustache\Z/
16
- end
17
-
18
- def dynamic_content?(filename, inline_script)
19
- (is_mustache?(filename) && inline_script =~ /\{\{.*\}\}/) ||
20
- (is_erb?(filename) && inline_script =~ /<%.*%>/)
21
- end
22
-
23
- def find_inline_content(filename, regex, hashes, strip_trailing_whitespace)
24
- file = File.read(filename)
25
- file.scan(regex) do # TODO don't use gsub
26
- inline_script = Regexp.last_match.captures.last
27
- inline_script.gsub!(/(\r?\n)[\t ]+\z/, '\1') if strip_trailing_whitespace
28
- if dynamic_content?(filename, inline_script)
29
- puts "Looks like there's some dynamic content inside of a tag :-/"
30
- puts "That pretty much means the hash value will never match."
31
- puts "Code: " + inline_script
32
- puts "=" * 20
33
- end
34
-
35
- hashes << hash_source(inline_script)
36
- end
37
- end
38
-
39
- def generate_inline_script_hashes(filename)
40
- hashes = []
41
-
42
- find_inline_content(filename, INLINE_SCRIPT_REGEX, hashes, false)
43
- find_inline_content(filename, INLINE_HASH_SCRIPT_HELPER_REGEX, hashes, true)
44
-
45
- hashes
46
- end
47
-
48
- def generate_inline_style_hashes(filename)
49
- hashes = []
50
-
51
- find_inline_content(filename, INLINE_STYLE_REGEX, hashes, false)
52
- find_inline_content(filename, INLINE_HASH_STYLE_HELPER_REGEX, hashes, true)
53
-
54
- hashes
55
- end
5
+ include SecureHeaders::TaskHelper
56
6
 
57
7
  desc "Generate #{SecureHeaders::Configuration::HASH_CONFIG_FILE}"
58
8
  task :generate_hashes do |t, args|
@@ -77,6 +27,7 @@ namespace :secure_headers do
77
27
  file.write(script_hashes.to_yaml)
78
28
  end
79
29
 
80
- puts "Script hashes from " + script_hashes.keys.size.to_s + " files added to #{SecureHeaders::Configuration::HASH_CONFIG_FILE}"
30
+ file_count = (script_hashes["scripts"].keys + script_hashes["styles"].keys).uniq.count
31
+ puts "Script and style hashes from #{file_count} files added to #{SecureHeaders::Configuration::HASH_CONFIG_FILE}"
81
32
  end
82
33
  end
@@ -13,11 +13,23 @@ Gem::Specification.new do |gem|
13
13
  gem.description = 'Add easily configured security headers to responses
14
14
  including content-security-policy, x-frame-options,
15
15
  strict-transport-security, etc.'
16
- gem.homepage = "https://github.com/twitter/secureheaders"
16
+ gem.homepage = "https://github.com/github/secure_headers"
17
+ gem.metadata = {
18
+ "bug_tracker_uri" => "https://github.com/github/secure_headers/issues",
19
+ "changelog_uri" => "https://github.com/github/secure_headers/blob/master/CHANGELOG.md",
20
+ "documentation_uri" => "https://rubydoc.info/gems/secure_headers",
21
+ "homepage_uri" => gem.homepage,
22
+ "source_code_uri" => "https://github.com/github/secure_headers",
23
+ "rubygems_mfa_required" => "true",
24
+ }
17
25
  gem.license = "MIT"
18
- gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
19
- gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
20
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
26
+
27
+ gem.files = Dir["bin/**/*", "lib/**/*", "README.md", "CHANGELOG.md", "LICENSE", "Gemfile", "secure_headers.gemspec"]
21
28
  gem.require_paths = ["lib"]
29
+
30
+ gem.extra_rdoc_files = Dir["README.md", "CHANGELOG.md", "LICENSE"]
31
+
32
+ gem.add_dependency "cgi", ">= 0.1"
33
+
22
34
  gem.add_development_dependency "rake"
23
35
  end
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secure_headers
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.7.0
4
+ version: 7.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Matatall
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-08-09 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: cgi
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0.1'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0.1'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: rake
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -32,35 +45,15 @@ email:
32
45
  - neil.matatall@gmail.com
33
46
  executables: []
34
47
  extensions: []
35
- extra_rdoc_files: []
48
+ extra_rdoc_files:
49
+ - CHANGELOG.md
50
+ - LICENSE
51
+ - README.md
36
52
  files:
37
- - ".github/ISSUE_TEMPLATE.md"
38
- - ".github/PULL_REQUEST_TEMPLATE.md"
39
- - ".github/dependabot.yml"
40
- - ".github/workflows/build.yml"
41
- - ".github/workflows/github-release.yml"
42
- - ".gitignore"
43
- - ".rspec"
44
- - ".rubocop.yml"
45
- - ".ruby-gemset"
46
- - ".ruby-version"
47
53
  - CHANGELOG.md
48
- - CODE_OF_CONDUCT.md
49
- - CONTRIBUTING.md
50
54
  - Gemfile
51
- - Guardfile
52
55
  - LICENSE
53
56
  - README.md
54
- - Rakefile
55
- - docs/cookies.md
56
- - docs/hashes.md
57
- - docs/named_overrides_and_appends.md
58
- - docs/per_action_configuration.md
59
- - docs/sinatra.md
60
- - docs/upgrading-to-3-0.md
61
- - docs/upgrading-to-4-0.md
62
- - docs/upgrading-to-5-0.md
63
- - docs/upgrading-to-6-0.md
64
57
  - lib/secure_headers.rb
65
58
  - lib/secure_headers/configuration.rb
66
59
  - lib/secure_headers/hash_helper.rb
@@ -71,6 +64,7 @@ files:
71
64
  - lib/secure_headers/headers/expect_certificate_transparency.rb
72
65
  - lib/secure_headers/headers/policy_management.rb
73
66
  - lib/secure_headers/headers/referrer_policy.rb
67
+ - lib/secure_headers/headers/reporting_endpoints.rb
74
68
  - lib/secure_headers/headers/strict_transport_security.rb
75
69
  - lib/secure_headers/headers/x_content_type_options.rb
76
70
  - lib/secure_headers/headers/x_download_options.rb
@@ -79,33 +73,22 @@ files:
79
73
  - lib/secure_headers/headers/x_xss_protection.rb
80
74
  - lib/secure_headers/middleware.rb
81
75
  - lib/secure_headers/railtie.rb
76
+ - lib/secure_headers/task_helper.rb
82
77
  - lib/secure_headers/utils/cookies_config.rb
83
78
  - lib/secure_headers/version.rb
84
79
  - lib/secure_headers/view_helper.rb
85
80
  - lib/tasks/tasks.rake
86
81
  - secure_headers.gemspec
87
- - spec/lib/secure_headers/configuration_spec.rb
88
- - spec/lib/secure_headers/headers/clear_site_data_spec.rb
89
- - spec/lib/secure_headers/headers/content_security_policy_spec.rb
90
- - spec/lib/secure_headers/headers/cookie_spec.rb
91
- - spec/lib/secure_headers/headers/expect_certificate_transparency_spec.rb
92
- - spec/lib/secure_headers/headers/policy_management_spec.rb
93
- - spec/lib/secure_headers/headers/referrer_policy_spec.rb
94
- - spec/lib/secure_headers/headers/strict_transport_security_spec.rb
95
- - spec/lib/secure_headers/headers/x_content_type_options_spec.rb
96
- - spec/lib/secure_headers/headers/x_download_options_spec.rb
97
- - spec/lib/secure_headers/headers/x_frame_options_spec.rb
98
- - spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb
99
- - spec/lib/secure_headers/headers/x_xss_protection_spec.rb
100
- - spec/lib/secure_headers/middleware_spec.rb
101
- - spec/lib/secure_headers/view_helpers_spec.rb
102
- - spec/lib/secure_headers_spec.rb
103
- - spec/spec_helper.rb
104
- homepage: https://github.com/twitter/secureheaders
82
+ homepage: https://github.com/github/secure_headers
105
83
  licenses:
106
84
  - MIT
107
- metadata: {}
108
- post_install_message:
85
+ metadata:
86
+ bug_tracker_uri: https://github.com/github/secure_headers/issues
87
+ changelog_uri: https://github.com/github/secure_headers/blob/master/CHANGELOG.md
88
+ documentation_uri: https://rubydoc.info/gems/secure_headers
89
+ homepage_uri: https://github.com/github/secure_headers
90
+ source_code_uri: https://github.com/github/secure_headers
91
+ rubygems_mfa_required: 'true'
109
92
  rdoc_options: []
110
93
  require_paths:
111
94
  - lib
@@ -120,25 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
103
  - !ruby/object:Gem::Version
121
104
  version: '0'
122
105
  requirements: []
123
- rubygems_version: 3.0.3.1
124
- signing_key:
106
+ rubygems_version: 3.6.9
125
107
  specification_version: 4
126
108
  summary: Manages application of security headers with many safe defaults.
127
- test_files:
128
- - spec/lib/secure_headers/configuration_spec.rb
129
- - spec/lib/secure_headers/headers/clear_site_data_spec.rb
130
- - spec/lib/secure_headers/headers/content_security_policy_spec.rb
131
- - spec/lib/secure_headers/headers/cookie_spec.rb
132
- - spec/lib/secure_headers/headers/expect_certificate_transparency_spec.rb
133
- - spec/lib/secure_headers/headers/policy_management_spec.rb
134
- - spec/lib/secure_headers/headers/referrer_policy_spec.rb
135
- - spec/lib/secure_headers/headers/strict_transport_security_spec.rb
136
- - spec/lib/secure_headers/headers/x_content_type_options_spec.rb
137
- - spec/lib/secure_headers/headers/x_download_options_spec.rb
138
- - spec/lib/secure_headers/headers/x_frame_options_spec.rb
139
- - spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb
140
- - spec/lib/secure_headers/headers/x_xss_protection_spec.rb
141
- - spec/lib/secure_headers/middleware_spec.rb
142
- - spec/lib/secure_headers/view_helpers_spec.rb
143
- - spec/lib/secure_headers_spec.rb
144
- - spec/spec_helper.rb
109
+ test_files: []
@@ -1,41 +0,0 @@
1
- # Feature Requests
2
-
3
- ## Adding a new header
4
-
5
- Generally, adding a new header is always OK.
6
-
7
- * Is the header supported by any user agent? If so, which?
8
- * What does it do?
9
- * What are the valid values for the header?
10
- * Where does the specification live?
11
-
12
- ## Adding a new CSP directive
13
-
14
- * Is the directive supported by any user agent? If so, which?
15
- * What does it do?
16
- * What are the valid values for the directive?
17
-
18
- ---
19
-
20
- # Bugs
21
-
22
- Console errors and deprecation warnings are considered bugs that should be addressed with more precise UA sniffing. Bugs caused by incorrect or invalid UA sniffing are also bugs.
23
-
24
- ### Expected outcome
25
-
26
- Describe what you expected to happen
27
-
28
- 1. I configure CSP to do X
29
- 1. When I inspect the response headers, the CSP should have included X
30
-
31
- ### Actual outcome
32
-
33
- 1. The generated policy did not include X
34
-
35
- ### Config
36
-
37
- Please provide the configuration (`SecureHeaders::Configuration.default`) you are using including any overrides (`SecureHeaders::Configuration.override`).
38
-
39
- ### Generated headers
40
-
41
- Provide a sample response containing the headers
@@ -1,20 +0,0 @@
1
- ## All PRs:
2
-
3
- * [ ] Has tests
4
- * [ ] Documentation updated
5
-
6
- ## Adding a new header
7
-
8
- Generally, adding a new header is always OK.
9
-
10
- * Is the header supported by any user agent? If so, which?
11
- * What does it do?
12
- * What are the valid values for the header?
13
- * Where does the specification live?
14
-
15
- ## Adding a new CSP directive
16
-
17
- * Is the directive supported by any user agent? If so, which?
18
- * What does it do?
19
- * What are the valid values for the directive?
20
-
@@ -1,6 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: "github-actions"
4
- directory: "/"
5
- schedule:
6
- interval: "weekly"
@@ -1,24 +0,0 @@
1
- name: Build + Test
2
- on: [pull_request, push]
3
-
4
- jobs:
5
- build:
6
- name: Build + Test
7
- runs-on: ubuntu-latest
8
- strategy:
9
- matrix:
10
- ruby: [ '2.6', '2.7', '3.0', '3.1', '3.2' ]
11
-
12
- steps:
13
- - uses: actions/checkout@v3
14
- - name: Set up Ruby ${{ matrix.ruby }}
15
- uses: ruby/setup-ruby@v1
16
- with:
17
- ruby-version: ${{ matrix.ruby }}
18
- - name: Build and test with Rake
19
- run: |
20
- gem install bundler
21
- bundle install --jobs 4 --retry 3 --without guard
22
- bundle exec rspec spec
23
- bundle exec rubocop
24
-
@@ -1,28 +0,0 @@
1
- name: GitHub Release
2
-
3
- on:
4
- push:
5
- tags:
6
- - v*
7
-
8
- jobs:
9
- Publish:
10
- permissions:
11
- contents: write
12
- runs-on: ubuntu-latest
13
- if: startsWith(github.ref, 'refs/tags/v')
14
- steps:
15
- - name: Calculate release name
16
- run: |
17
- GITHUB_REF=${{ github.ref }}
18
- RELEASE_NAME=${GITHUB_REF#"refs/tags/"}
19
- echo "RELEASE_NAME=${RELEASE_NAME}" >> $GITHUB_ENV
20
- - name: Publish release
21
- uses: actions/create-release@v1
22
- env:
23
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24
- with:
25
- tag_name: ${{ github.ref }}
26
- release_name: ${{ env.RELEASE_NAME }}
27
- draft: false
28
- prerelease: false
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- *.gem
2
- *.DS_STORE
3
- *.rbc
4
- .bundle
5
- .config
6
- .yardoc
7
- *.log
8
- Gemfile.lock
9
- _yardoc
10
- coverage
11
- pkg
12
- rdoc
13
- spec/reports
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --order rand
2
- --warnings
3
- --format progress
data/.rubocop.yml DELETED
@@ -1,4 +0,0 @@
1
- inherit_gem:
2
- rubocop-github:
3
- - config/default.yml
4
- require: rubocop-performance
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- secureheaders
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.1.1
data/CODE_OF_CONDUCT.md DELETED
@@ -1,46 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- ## Our Standards
8
-
9
- Examples of behavior that contributes to creating a positive environment include:
10
-
11
- * Using welcoming and inclusive language
12
- * Being respectful of differing viewpoints and experiences
13
- * Gracefully accepting constructive criticism
14
- * Focusing on what is best for the community
15
- * Showing empathy towards other community members
16
-
17
- Examples of unacceptable behavior by participants include:
18
-
19
- * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
- * Trolling, insulting/derogatory comments, and personal or political attacks
21
- * Public or private harassment
22
- * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
- * Other conduct which could reasonably be considered inappropriate in a professional setting
24
-
25
- ## Our Responsibilities
26
-
27
- Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
-
29
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
-
31
- ## Scope
32
-
33
- This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
-
35
- ## Enforcement
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at neil.matatall@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
-
39
- Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
-
41
- ## Attribution
42
-
43
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
-
45
- [homepage]: http://contributor-covenant.org
46
- [version]: http://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md DELETED
@@ -1,41 +0,0 @@
1
- ## Contributing
2
-
3
- [fork]: https://github.com/twitter/secureheaders/fork
4
- [pr]: https://github.com/twitter/secureheaders/compare
5
- [style]: https://github.com/styleguide/ruby
6
- [code-of-conduct]: CODE_OF_CONDUCT.md
7
-
8
- Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
9
-
10
- Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
11
-
12
- ## Submitting a pull request
13
-
14
- 0. [Fork][fork] and clone the repository
15
- 0. Configure and install the dependencies: `bundle install`
16
- 0. Make sure the tests pass on your machine: `bundle exec rspec spec`
17
- 0. Create a new branch: `git checkout -b my-branch-name`
18
- 0. Make your change, add tests, and make sure the tests still pass and that no warnings are raised
19
- 0. Push to your fork and [submit a pull request][pr]
20
- 0. Pat your self on the back and wait for your pull request to be reviewed and merged.
21
-
22
- Here are a few things you can do that will increase the likelihood of your pull request being accepted:
23
-
24
- - Write tests.
25
- - Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
26
- - Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
27
-
28
- ## Releasing
29
-
30
- 0. Ensure CI is green
31
- 0. Pull the latest code
32
- 0. Increment the version
33
- 0. Run `gem build secure_headers.gemspec`
34
- 0. Bump the Gemfile and Gemfile.lock versions for an app which relies on this gem
35
- 0. Test behavior locally, branch deploy, whatever needs to happen
36
- 0. Run `bundle exec rake release`
37
-
38
- ## Resources
39
-
40
- - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
41
- - [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
data/Guardfile DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
- guard :rspec, cmd: "bundle exec rspec", all_on_start: true, all_after_pass: true do
3
- require "guard/rspec/dsl"
4
- dsl = Guard::RSpec::Dsl.new(self)
5
-
6
- # RSpec files
7
- rspec = dsl.rspec
8
- watch(rspec.spec_helper) { rspec.spec_dir }
9
- watch(rspec.spec_support) { rspec.spec_dir }
10
- watch(rspec.spec_files)
11
-
12
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
13
- end
data/Rakefile DELETED
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env rake
2
- # frozen_string_literal: true
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
- require "net/http"
6
- require "net/https"
7
-
8
- RSpec::Core::RakeTask.new
9
-
10
- begin
11
- require "rdoc/task"
12
- rescue LoadError
13
- require "rdoc/rdoc"
14
- require "rake/rdoctask"
15
- RDoc::Task = Rake::RDocTask
16
- end
17
-
18
- begin
19
- require "rubocop/rake_task"
20
- RuboCop::RakeTask.new
21
- rescue LoadError
22
- task(:rubocop) { $stderr.puts "RuboCop is disabled" }
23
- end
24
-
25
- RDoc::Task.new(:rdoc) do |rdoc|
26
- rdoc.rdoc_dir = "rdoc"
27
- rdoc.title = "SecureHeaders"
28
- rdoc.options << "--line-numbers"
29
- rdoc.rdoc_files.include("lib/**/*.rb")
30
- end
31
-
32
- task default: [:spec, :rubocop]
data/docs/cookies.md DELETED
@@ -1,65 +0,0 @@
1
- ## Cookies
2
-
3
- SecureHeaders supports `Secure`, `HttpOnly` and [`SameSite`](https://tools.ietf.org/html/draft-west-first-party-cookies-07) cookies. These can be defined in the form of a boolean, or as a Hash for more refined configuration.
4
-
5
- __Note__: Regardless of the configuration specified, Secure cookies are only enabled for HTTPS requests.
6
-
7
- #### Defaults
8
-
9
- By default, all cookies will get both `Secure`, `HttpOnly`, and `SameSite=Lax`.
10
-
11
- ```ruby
12
- config.cookies = {
13
- secure: true, # defaults to true but will be a no op on non-HTTPS requests
14
- httponly: true, # defaults to true
15
- samesite: { # defaults to set `SameSite=Lax`
16
- lax: true
17
- }
18
- }
19
- ```
20
-
21
- #### Boolean-based configuration
22
-
23
- Boolean-based configuration is intended to globally enable or disable a specific cookie attribute. *Note: As of 4.0, you must use OPT_OUT rather than false to opt out of the defaults.*
24
-
25
- ```ruby
26
- config.cookies = {
27
- secure: true, # mark all cookies as Secure
28
- httponly: SecureHeaders::OPT_OUT, # do not mark any cookies as HttpOnly
29
- }
30
- ```
31
-
32
- #### Hash-based configuration
33
-
34
- Hash-based configuration allows for fine-grained control.
35
-
36
- ```ruby
37
- config.cookies = {
38
- secure: { except: ['_guest'] }, # mark all but the `_guest` cookie as Secure
39
- httponly: { only: ['_rails_session'] }, # only mark the `_rails_session` cookie as HttpOnly
40
- }
41
- ```
42
-
43
- #### SameSite cookie configuration
44
-
45
- SameSite cookies permit either `Strict` or `Lax` enforcement mode options.
46
-
47
- ```ruby
48
- config.cookies = {
49
- samesite: {
50
- strict: true # mark all cookies as SameSite=Strict
51
- }
52
- }
53
- ```
54
-
55
- `Strict`, `Lax`, and `None` enforcement modes can also be specified using a Hash.
56
-
57
- ```ruby
58
- config.cookies = {
59
- samesite: {
60
- strict: { only: ['session_id_duplicate'] },
61
- lax: { only: ['_guest', '_rails_session', 'device_id'] },
62
- none: { only: ['_tracking', 'saml_cookie', 'session_id'] },
63
- }
64
- }
65
- ```