secure_headers 6.3.1 → 7.1.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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/Gemfile +3 -1
  4. data/README.md +22 -17
  5. data/lib/secure_headers/configuration.rb +11 -7
  6. data/lib/secure_headers/headers/clear_site_data.rb +4 -4
  7. data/lib/secure_headers/headers/content_security_policy.rb +25 -38
  8. data/lib/secure_headers/headers/content_security_policy_config.rb +17 -54
  9. data/lib/secure_headers/headers/cookie.rb +2 -2
  10. data/lib/secure_headers/headers/expect_certificate_transparency.rb +2 -2
  11. data/lib/secure_headers/headers/policy_management.rb +54 -12
  12. data/lib/secure_headers/headers/referrer_policy.rb +1 -1
  13. data/lib/secure_headers/headers/strict_transport_security.rb +1 -1
  14. data/lib/secure_headers/headers/x_content_type_options.rb +1 -1
  15. data/lib/secure_headers/headers/x_download_options.rb +2 -2
  16. data/lib/secure_headers/headers/x_frame_options.rb +1 -1
  17. data/lib/secure_headers/headers/x_permitted_cross_domain_policies.rb +2 -2
  18. data/lib/secure_headers/headers/x_xss_protection.rb +2 -2
  19. data/lib/secure_headers/railtie.rb +5 -5
  20. data/lib/secure_headers/version.rb +1 -1
  21. data/lib/secure_headers/view_helper.rb +7 -6
  22. data/lib/tasks/tasks.rake +6 -7
  23. data/secure_headers.gemspec +17 -7
  24. metadata +22 -67
  25. data/.github/ISSUE_TEMPLATE.md +0 -41
  26. data/.github/PULL_REQUEST_TEMPLATE.md +0 -20
  27. data/.github/workflows/build.yml +0 -24
  28. data/.github/workflows/sync.yml +0 -20
  29. data/.gitignore +0 -13
  30. data/.rspec +0 -3
  31. data/.rubocop.yml +0 -4
  32. data/.ruby-gemset +0 -1
  33. data/.ruby-version +0 -1
  34. data/CODE_OF_CONDUCT.md +0 -46
  35. data/CONTRIBUTING.md +0 -41
  36. data/Guardfile +0 -13
  37. data/Rakefile +0 -32
  38. data/docs/cookies.md +0 -65
  39. data/docs/hashes.md +0 -64
  40. data/docs/named_overrides_and_appends.md +0 -104
  41. data/docs/per_action_configuration.md +0 -141
  42. data/docs/sinatra.md +0 -25
  43. data/docs/upgrading-to-3-0.md +0 -42
  44. data/docs/upgrading-to-4-0.md +0 -35
  45. data/docs/upgrading-to-5-0.md +0 -15
  46. data/docs/upgrading-to-6-0.md +0 -50
  47. data/spec/lib/secure_headers/configuration_spec.rb +0 -121
  48. data/spec/lib/secure_headers/headers/clear_site_data_spec.rb +0 -87
  49. data/spec/lib/secure_headers/headers/content_security_policy_spec.rb +0 -165
  50. data/spec/lib/secure_headers/headers/cookie_spec.rb +0 -179
  51. data/spec/lib/secure_headers/headers/expect_certificate_transparency_spec.rb +0 -42
  52. data/spec/lib/secure_headers/headers/policy_management_spec.rb +0 -260
  53. data/spec/lib/secure_headers/headers/referrer_policy_spec.rb +0 -91
  54. data/spec/lib/secure_headers/headers/strict_transport_security_spec.rb +0 -33
  55. data/spec/lib/secure_headers/headers/x_content_type_options_spec.rb +0 -31
  56. data/spec/lib/secure_headers/headers/x_download_options_spec.rb +0 -29
  57. data/spec/lib/secure_headers/headers/x_frame_options_spec.rb +0 -36
  58. data/spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb +0 -48
  59. data/spec/lib/secure_headers/headers/x_xss_protection_spec.rb +0 -47
  60. data/spec/lib/secure_headers/middleware_spec.rb +0 -117
  61. data/spec/lib/secure_headers/view_helpers_spec.rb +0 -191
  62. data/spec/lib/secure_headers_spec.rb +0 -516
  63. data/spec/spec_helper.rb +0 -64
@@ -2,7 +2,7 @@
2
2
  module SecureHeaders
3
3
  class XFOConfigError < StandardError; end
4
4
  class XFrameOptions
5
- HEADER_NAME = "X-Frame-Options".freeze
5
+ HEADER_NAME = "x-frame-options".freeze
6
6
  SAMEORIGIN = "sameorigin"
7
7
  DENY = "deny"
8
8
  ALLOW_FROM = "allow-from"
@@ -2,12 +2,12 @@
2
2
  module SecureHeaders
3
3
  class XPCDPConfigError < StandardError; end
4
4
  class XPermittedCrossDomainPolicies
5
- HEADER_NAME = "X-Permitted-Cross-Domain-Policies".freeze
5
+ HEADER_NAME = "x-permitted-cross-domain-policies".freeze
6
6
  DEFAULT_VALUE = "none"
7
7
  VALID_POLICIES = %w(all none master-only by-content-type by-ftp-filename)
8
8
 
9
9
  class << self
10
- # Public: generate an X-Permitted-Cross-Domain-Policies header.
10
+ # Public: generate an x-permitted-cross-domain-policies header.
11
11
  #
12
12
  # Returns a default header if no configuration is provided, or a
13
13
  # header name and value based on the config.
@@ -2,8 +2,8 @@
2
2
  module SecureHeaders
3
3
  class XXssProtectionConfigError < StandardError; end
4
4
  class XXssProtection
5
- HEADER_NAME = "X-XSS-Protection".freeze
6
- DEFAULT_VALUE = "1; mode=block"
5
+ HEADER_NAME = "x-xss-protection".freeze
6
+ DEFAULT_VALUE = "0".freeze
7
7
  VALID_X_XSS_HEADER = /\A[01](; mode=block)?(; report=.*)?\z/
8
8
 
9
9
  class << self
@@ -4,11 +4,11 @@ if defined?(Rails::Railtie)
4
4
  module SecureHeaders
5
5
  class Railtie < Rails::Railtie
6
6
  isolate_namespace SecureHeaders if defined? isolate_namespace # rails 3.0
7
- conflicting_headers = ["X-Frame-Options", "X-XSS-Protection",
8
- "X-Permitted-Cross-Domain-Policies", "X-Download-Options",
9
- "X-Content-Type-Options", "Strict-Transport-Security",
10
- "Content-Security-Policy", "Content-Security-Policy-Report-Only",
11
- "Public-Key-Pins", "Public-Key-Pins-Report-Only", "Referrer-Policy"]
7
+ conflicting_headers = ["x-frame-options", "x-xss-protection",
8
+ "x-permitted-cross-domain-policies", "x-download-options",
9
+ "x-content-type-options", "strict-transport-security",
10
+ "content-security-policy", "content-security-policy-report-only",
11
+ "public-key-pins", "public-key-pins-report-only", "referrer-policy"]
12
12
 
13
13
  initializer "secure_headers.middleware" do
14
14
  Rails.application.config.middleware.insert_before 0, SecureHeaders::Middleware
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SecureHeaders
4
- VERSION = "6.3.1"
4
+ VERSION = "7.1.0"
5
5
  end
@@ -147,12 +147,13 @@ module SecureHeaders
147
147
 
148
148
  def nonced_tag(type, content_or_options, block)
149
149
  options = {}
150
- content = if block
151
- options = content_or_options
152
- capture(&block)
153
- else
154
- content_or_options.html_safe # :'(
155
- end
150
+ content =
151
+ if block
152
+ options = content_or_options
153
+ capture(&block)
154
+ else
155
+ content_or_options.html_safe # :'(
156
+ end
156
157
  content_tag type, content, options.merge(nonce: _content_security_policy_nonce(type))
157
158
  end
158
159
 
data/lib/tasks/tasks.rake CHANGED
@@ -20,10 +20,11 @@ namespace :secure_headers do
20
20
  (is_erb?(filename) && inline_script =~ /<%.*%>/)
21
21
  end
22
22
 
23
- def find_inline_content(filename, regex, hashes)
23
+ def find_inline_content(filename, regex, hashes, strip_trailing_whitespace)
24
24
  file = File.read(filename)
25
25
  file.scan(regex) do # TODO don't use gsub
26
26
  inline_script = Regexp.last_match.captures.last
27
+ inline_script.gsub!(/(\r?\n)[\t ]+\z/, '\1') if strip_trailing_whitespace
27
28
  if dynamic_content?(filename, inline_script)
28
29
  puts "Looks like there's some dynamic content inside of a tag :-/"
29
30
  puts "That pretty much means the hash value will never match."
@@ -38,9 +39,8 @@ namespace :secure_headers do
38
39
  def generate_inline_script_hashes(filename)
39
40
  hashes = []
40
41
 
41
- [INLINE_SCRIPT_REGEX, INLINE_HASH_SCRIPT_HELPER_REGEX].each do |regex|
42
- find_inline_content(filename, regex, hashes)
43
- end
42
+ find_inline_content(filename, INLINE_SCRIPT_REGEX, hashes, false)
43
+ find_inline_content(filename, INLINE_HASH_SCRIPT_HELPER_REGEX, hashes, true)
44
44
 
45
45
  hashes
46
46
  end
@@ -48,9 +48,8 @@ namespace :secure_headers do
48
48
  def generate_inline_style_hashes(filename)
49
49
  hashes = []
50
50
 
51
- [INLINE_STYLE_REGEX, INLINE_HASH_STYLE_HELPER_REGEX].each do |regex|
52
- find_inline_content(filename, regex, hashes)
53
- end
51
+ find_inline_content(filename, INLINE_STYLE_REGEX, hashes, false)
52
+ find_inline_content(filename, INLINE_HASH_STYLE_HELPER_REGEX, hashes, true)
54
53
 
55
54
  hashes
56
55
  end
@@ -9,15 +9,25 @@ Gem::Specification.new do |gem|
9
9
  gem.version = SecureHeaders::VERSION
10
10
  gem.authors = ["Neil Matatall"]
11
11
  gem.email = ["neil.matatall@gmail.com"]
12
- gem.description = "Manages application of security headers with many safe defaults."
13
- gem.summary = 'Add easily configured security headers to responses
12
+ gem.summary = "Manages application of security headers with many safe defaults."
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"
17
- gem.license = "Apache Public License 2.0"
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)/})
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
+ }
25
+ gem.license = "MIT"
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
+
22
32
  gem.add_development_dependency "rake"
23
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secure_headers
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.1
4
+ version: 7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Matatall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-26 00:00:00.000000000 Z
11
+ date: 2024-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,39 +24,23 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- description: Manages application of security headers with many safe defaults.
27
+ description: |-
28
+ Add easily configured security headers to responses
29
+ including content-security-policy, x-frame-options,
30
+ strict-transport-security, etc.
28
31
  email:
29
32
  - neil.matatall@gmail.com
30
33
  executables: []
31
34
  extensions: []
32
- extra_rdoc_files: []
35
+ extra_rdoc_files:
36
+ - README.md
37
+ - CHANGELOG.md
38
+ - LICENSE
33
39
  files:
34
- - ".github/ISSUE_TEMPLATE.md"
35
- - ".github/PULL_REQUEST_TEMPLATE.md"
36
- - ".github/workflows/build.yml"
37
- - ".github/workflows/sync.yml"
38
- - ".gitignore"
39
- - ".rspec"
40
- - ".rubocop.yml"
41
- - ".ruby-gemset"
42
- - ".ruby-version"
43
40
  - CHANGELOG.md
44
- - CODE_OF_CONDUCT.md
45
- - CONTRIBUTING.md
46
41
  - Gemfile
47
- - Guardfile
48
42
  - LICENSE
49
43
  - README.md
50
- - Rakefile
51
- - docs/cookies.md
52
- - docs/hashes.md
53
- - docs/named_overrides_and_appends.md
54
- - docs/per_action_configuration.md
55
- - docs/sinatra.md
56
- - docs/upgrading-to-3-0.md
57
- - docs/upgrading-to-4-0.md
58
- - docs/upgrading-to-5-0.md
59
- - docs/upgrading-to-6-0.md
60
44
  - lib/secure_headers.rb
61
45
  - lib/secure_headers/configuration.rb
62
46
  - lib/secure_headers/hash_helper.rb
@@ -80,27 +64,16 @@ files:
80
64
  - lib/secure_headers/view_helper.rb
81
65
  - lib/tasks/tasks.rake
82
66
  - secure_headers.gemspec
83
- - spec/lib/secure_headers/configuration_spec.rb
84
- - spec/lib/secure_headers/headers/clear_site_data_spec.rb
85
- - spec/lib/secure_headers/headers/content_security_policy_spec.rb
86
- - spec/lib/secure_headers/headers/cookie_spec.rb
87
- - spec/lib/secure_headers/headers/expect_certificate_transparency_spec.rb
88
- - spec/lib/secure_headers/headers/policy_management_spec.rb
89
- - spec/lib/secure_headers/headers/referrer_policy_spec.rb
90
- - spec/lib/secure_headers/headers/strict_transport_security_spec.rb
91
- - spec/lib/secure_headers/headers/x_content_type_options_spec.rb
92
- - spec/lib/secure_headers/headers/x_download_options_spec.rb
93
- - spec/lib/secure_headers/headers/x_frame_options_spec.rb
94
- - spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb
95
- - spec/lib/secure_headers/headers/x_xss_protection_spec.rb
96
- - spec/lib/secure_headers/middleware_spec.rb
97
- - spec/lib/secure_headers/view_helpers_spec.rb
98
- - spec/lib/secure_headers_spec.rb
99
- - spec/spec_helper.rb
100
- homepage: https://github.com/twitter/secureheaders
67
+ homepage: https://github.com/github/secure_headers
101
68
  licenses:
102
- - Apache Public License 2.0
103
- metadata: {}
69
+ - MIT
70
+ metadata:
71
+ bug_tracker_uri: https://github.com/github/secure_headers/issues
72
+ changelog_uri: https://github.com/github/secure_headers/blob/master/CHANGELOG.md
73
+ documentation_uri: https://rubydoc.info/gems/secure_headers
74
+ homepage_uri: https://github.com/github/secure_headers
75
+ source_code_uri: https://github.com/github/secure_headers
76
+ rubygems_mfa_required: 'true'
104
77
  post_install_message:
105
78
  rdoc_options: []
106
79
  require_paths:
@@ -116,26 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
89
  - !ruby/object:Gem::Version
117
90
  version: '0'
118
91
  requirements: []
119
- rubygems_version: 3.0.3
92
+ rubygems_version: 3.0.3.1
120
93
  signing_key:
121
94
  specification_version: 4
122
- summary: Add easily configured security headers to responses including content-security-policy,
123
- x-frame-options, strict-transport-security, etc.
124
- test_files:
125
- - spec/lib/secure_headers/configuration_spec.rb
126
- - spec/lib/secure_headers/headers/clear_site_data_spec.rb
127
- - spec/lib/secure_headers/headers/content_security_policy_spec.rb
128
- - spec/lib/secure_headers/headers/cookie_spec.rb
129
- - spec/lib/secure_headers/headers/expect_certificate_transparency_spec.rb
130
- - spec/lib/secure_headers/headers/policy_management_spec.rb
131
- - spec/lib/secure_headers/headers/referrer_policy_spec.rb
132
- - spec/lib/secure_headers/headers/strict_transport_security_spec.rb
133
- - spec/lib/secure_headers/headers/x_content_type_options_spec.rb
134
- - spec/lib/secure_headers/headers/x_download_options_spec.rb
135
- - spec/lib/secure_headers/headers/x_frame_options_spec.rb
136
- - spec/lib/secure_headers/headers/x_permitted_cross_domain_policies_spec.rb
137
- - spec/lib/secure_headers/headers/x_xss_protection_spec.rb
138
- - spec/lib/secure_headers/middleware_spec.rb
139
- - spec/lib/secure_headers/view_helpers_spec.rb
140
- - spec/lib/secure_headers_spec.rb
141
- - spec/spec_helper.rb
95
+ summary: Manages application of security headers with many safe defaults.
96
+ 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,24 +0,0 @@
1
- name: Build + Test
2
- on: [pull_request]
3
-
4
- jobs:
5
- build:
6
- name: Build + Test
7
- runs-on: ubuntu-latest
8
- strategy:
9
- matrix:
10
- ruby: [ '2.4', '2.5', '2.6', '2.7' ]
11
-
12
- steps:
13
- - uses: actions/checkout@v2
14
- - name: Set up Ruby ${{ matrix.ruby }}
15
- uses: actions/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,20 +0,0 @@
1
- # This workflow ensures the "master" branch is always up-to-date with the
2
- # "main" branch (our default one)
3
- name: sync_main_branch
4
- on:
5
- push:
6
- branches: [ main ]
7
- jobs:
8
- catch_up:
9
- runs-on: ubuntu-latest
10
- steps:
11
- - name: Check out the repository
12
- uses: actions/checkout@v2
13
- with:
14
- fetch-depth: 0
15
- - name: Merge development into master, then push it
16
- run: |
17
- git pull
18
- git checkout master
19
- git merge main
20
- git push
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
- 2.6.6
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
- ```