secure_headers 7.0.0 → 7.2.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 (67) 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 +36 -5
  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 +13 -15
  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 +15 -3
  26. metadata +31 -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 -25
  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/docs/upgrading-to-7-0.md +0 -12
  51. data/spec/lib/secure_headers/configuration_spec.rb +0 -121
  52. data/spec/lib/secure_headers/headers/clear_site_data_spec.rb +0 -87
  53. data/spec/lib/secure_headers/headers/content_security_policy_spec.rb +0 -215
  54. data/spec/lib/secure_headers/headers/cookie_spec.rb +0 -179
  55. data/spec/lib/secure_headers/headers/expect_certificate_transparency_spec.rb +0 -42
  56. data/spec/lib/secure_headers/headers/policy_management_spec.rb +0 -265
  57. data/spec/lib/secure_headers/headers/referrer_policy_spec.rb +0 -91
  58. data/spec/lib/secure_headers/headers/strict_transport_security_spec.rb +0 -33
  59. data/spec/lib/secure_headers/headers/x_content_type_options_spec.rb +0 -31
  60. data/spec/lib/secure_headers/headers/x_download_options_spec.rb +0 -29
  61. data/spec/lib/secure_headers/headers/x_frame_options_spec.rb +0 -36
  62. data/spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb +0 -48
  63. data/spec/lib/secure_headers/headers/x_xss_protection_spec.rb +0 -47
  64. data/spec/lib/secure_headers/middleware_spec.rb +0 -117
  65. data/spec/lib/secure_headers/view_helpers_spec.rb +0 -192
  66. data/spec/lib/secure_headers_spec.rb +0 -516
  67. data/spec/spec_helper.rb +0 -64
@@ -14,10 +14,22 @@ Gem::Specification.new do |gem|
14
14
  including content-security-policy, x-frame-options,
15
15
  strict-transport-security, etc.'
16
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: 7.0.0
4
+ version: 7.2.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-10-16 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,36 +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
- - docs/upgrading-to-7-0.md
65
57
  - lib/secure_headers.rb
66
58
  - lib/secure_headers/configuration.rb
67
59
  - lib/secure_headers/hash_helper.rb
@@ -72,6 +64,7 @@ files:
72
64
  - lib/secure_headers/headers/expect_certificate_transparency.rb
73
65
  - lib/secure_headers/headers/policy_management.rb
74
66
  - lib/secure_headers/headers/referrer_policy.rb
67
+ - lib/secure_headers/headers/reporting_endpoints.rb
75
68
  - lib/secure_headers/headers/strict_transport_security.rb
76
69
  - lib/secure_headers/headers/x_content_type_options.rb
77
70
  - lib/secure_headers/headers/x_download_options.rb
@@ -80,33 +73,22 @@ files:
80
73
  - lib/secure_headers/headers/x_xss_protection.rb
81
74
  - lib/secure_headers/middleware.rb
82
75
  - lib/secure_headers/railtie.rb
76
+ - lib/secure_headers/task_helper.rb
83
77
  - lib/secure_headers/utils/cookies_config.rb
84
78
  - lib/secure_headers/version.rb
85
79
  - lib/secure_headers/view_helper.rb
86
80
  - lib/tasks/tasks.rake
87
81
  - secure_headers.gemspec
88
- - spec/lib/secure_headers/configuration_spec.rb
89
- - spec/lib/secure_headers/headers/clear_site_data_spec.rb
90
- - spec/lib/secure_headers/headers/content_security_policy_spec.rb
91
- - spec/lib/secure_headers/headers/cookie_spec.rb
92
- - spec/lib/secure_headers/headers/expect_certificate_transparency_spec.rb
93
- - spec/lib/secure_headers/headers/policy_management_spec.rb
94
- - spec/lib/secure_headers/headers/referrer_policy_spec.rb
95
- - spec/lib/secure_headers/headers/strict_transport_security_spec.rb
96
- - spec/lib/secure_headers/headers/x_content_type_options_spec.rb
97
- - spec/lib/secure_headers/headers/x_download_options_spec.rb
98
- - spec/lib/secure_headers/headers/x_frame_options_spec.rb
99
- - spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb
100
- - spec/lib/secure_headers/headers/x_xss_protection_spec.rb
101
- - spec/lib/secure_headers/middleware_spec.rb
102
- - spec/lib/secure_headers/view_helpers_spec.rb
103
- - spec/lib/secure_headers_spec.rb
104
- - spec/spec_helper.rb
105
82
  homepage: https://github.com/github/secure_headers
106
83
  licenses:
107
84
  - MIT
108
- metadata: {}
109
- 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'
110
92
  rdoc_options: []
111
93
  require_paths:
112
94
  - lib
@@ -121,25 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
103
  - !ruby/object:Gem::Version
122
104
  version: '0'
123
105
  requirements: []
124
- rubygems_version: 3.0.3.1
125
- signing_key:
106
+ rubygems_version: 3.6.9
126
107
  specification_version: 4
127
108
  summary: Manages application of security headers with many safe defaults.
128
- test_files:
129
- - spec/lib/secure_headers/configuration_spec.rb
130
- - spec/lib/secure_headers/headers/clear_site_data_spec.rb
131
- - spec/lib/secure_headers/headers/content_security_policy_spec.rb
132
- - spec/lib/secure_headers/headers/cookie_spec.rb
133
- - spec/lib/secure_headers/headers/expect_certificate_transparency_spec.rb
134
- - spec/lib/secure_headers/headers/policy_management_spec.rb
135
- - spec/lib/secure_headers/headers/referrer_policy_spec.rb
136
- - spec/lib/secure_headers/headers/strict_transport_security_spec.rb
137
- - spec/lib/secure_headers/headers/x_content_type_options_spec.rb
138
- - spec/lib/secure_headers/headers/x_download_options_spec.rb
139
- - spec/lib/secure_headers/headers/x_frame_options_spec.rb
140
- - spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb
141
- - spec/lib/secure_headers/headers/x_xss_protection_spec.rb
142
- - spec/lib/secure_headers/middleware_spec.rb
143
- - spec/lib/secure_headers/view_helpers_spec.rb
144
- - spec/lib/secure_headers_spec.rb
145
- - 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,25 +0,0 @@
1
- name: Build + Test
2
- on: [pull_request, push]
3
-
4
- permissions:
5
- contents: read
6
-
7
- jobs:
8
- build:
9
- name: Build + Test
10
- runs-on: ubuntu-latest
11
- strategy:
12
- matrix:
13
- ruby: [ '2.6', '2.7', '3.0', '3.1', '3.2' ]
14
-
15
- steps:
16
- - uses: actions/checkout@v4
17
- - name: Set up Ruby ${{ matrix.ruby }}
18
- uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 #v1.190.0 tag
19
- with:
20
- ruby-version: ${{ matrix.ruby }}
21
- bundler-cache: true
22
- - name: Build and test with Rake
23
- run: |
24
- bundle exec rubocop
25
- bundle exec rspec spec
@@ -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
- ```
data/docs/hashes.md DELETED
@@ -1,64 +0,0 @@
1
- ## Hash
2
-
3
- `script`/`style-src` hashes can be used to whitelist inline content that is static. This has the benefit of allowing inline content without opening up the possibility of dynamic javascript like you would with a `nonce`.
4
-
5
- You can add hash sources directly to your policy :
6
-
7
- ```ruby
8
- ::SecureHeaders::Configuration.default do |config|
9
- config.csp = {
10
- default_src: %w('self')
11
-
12
- # this is a made up value but browsers will show the expected hash in the console.
13
- script_src: %w(sha256-123456)
14
- }
15
- end
16
- ```
17
-
18
- You can also use the automated inline script detection/collection/computation of hash source values in your app.
19
-
20
- ```bash
21
- rake secure_headers:generate_hashes
22
- ```
23
-
24
- This will generate a file (`config/secure_headers_generated_hashes.yml` by default, you can override by setting `ENV["secure_headers_generated_hashes_file"]`) containing a mapping of file names with the array of hash values found on that page. When ActionView renders a given file, we check if there are any known hashes for that given file. If so, they are added as values to the header.
25
-
26
- ```yaml
27
- ---
28
- scripts:
29
- app/views/asdfs/index.html.erb:
30
- - "'sha256-yktKiAsZWmc8WpOyhnmhQoDf9G2dAZvuBBC+V0LGQhg='"
31
- styles:
32
- app/views/asdfs/index.html.erb:
33
- - "'sha256-SLp6LO3rrKDJwsG9uJUxZapb4Wp2Zhj6Bu3l+d9rnAY='"
34
- - "'sha256-HSGHqlRoKmHAGTAJ2Rq0piXX4CnEbOl1ArNd6ejp2TE='"
35
- ```
36
-
37
- ##### Helpers
38
-
39
- **This will not compute dynamic hashes** by design. The output of both helpers will be a plain `script`/`style` tag without modification and the known hashes for a given file will be added to `script-src`/`style-src` when `hashed_javascript_tag` and `hashed_style_tag` are used. You can use `raise_error_on_unrecognized_hash = true` to be extra paranoid that you have precomputed hash values for all of your inline content. By default, this will raise an error in non-production environments.
40
-
41
- ```erb
42
- <%= hashed_style_tag do %>
43
- body {
44
- background-color: black;
45
- }
46
- <% end %>
47
-
48
- <%= hashed_style_tag do %>
49
- body {
50
- font-size: 30px;
51
- font-color: green;
52
- }
53
- <% end %>
54
-
55
- <%= hashed_javascript_tag do %>
56
- console.log(1)
57
- <% end %>
58
- ```
59
-
60
- ```
61
- Content-Security-Policy: ...
62
- script-src 'sha256-yktKiAsZWmc8WpOyhnmhQoDf9G2dAZvuBBC+V0LGQhg=' ... ;
63
- style-src 'sha256-SLp6LO3rrKDJwsG9uJUxZapb4Wp2Zhj6Bu3l+d9rnAY=' 'sha256-HSGHqlRoKmHAGTAJ2Rq0piXX4CnEbOl1ArNd6ejp2TE=' ...;
64
- ```