secure_headers 3.6.0 → 3.7.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.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +2 -0
- data/CHANGELOG.md +34 -1
- data/CODE_OF_CONDUCT.md +46 -0
- data/CONTRIBUTING.md +41 -0
- data/LICENSE +4 -199
- data/README.md +12 -3
- data/docs/hashes.md +1 -1
- data/lib/secure_headers/configuration.rb +25 -5
- data/lib/secure_headers/headers/clear_site_data.rb +12 -9
- data/lib/secure_headers/headers/content_security_policy.rb +2 -2
- data/lib/secure_headers/headers/content_security_policy_config.rb +45 -12
- data/lib/secure_headers/headers/expect_certificate_transparency.rb +70 -0
- data/lib/secure_headers/headers/policy_management.rb +22 -22
- data/lib/secure_headers/headers/public_key_pins.rb +1 -1
- data/lib/secure_headers/headers/referrer_policy.rb +1 -1
- data/lib/secure_headers/headers/strict_transport_security.rb +1 -1
- data/lib/secure_headers/headers/x_content_type_options.rb +1 -1
- data/lib/secure_headers/headers/x_download_options.rb +1 -1
- data/lib/secure_headers/headers/x_frame_options.rb +1 -1
- data/lib/secure_headers/headers/x_permitted_cross_domain_policies.rb +1 -1
- data/lib/secure_headers/headers/x_xss_protection.rb +1 -1
- data/lib/secure_headers/view_helper.rb +2 -2
- data/lib/secure_headers.rb +5 -2
- data/secure_headers.gemspec +2 -2
- data/spec/lib/secure_headers/headers/clear_site_data_spec.rb +9 -26
- data/spec/lib/secure_headers/headers/content_security_policy_spec.rb +12 -8
- data/spec/lib/secure_headers/headers/expect_certificate_spec.rb +42 -0
- data/spec/lib/secure_headers/headers/policy_management_spec.rb +1 -0
- data/spec/lib/secure_headers/view_helpers_spec.rb +0 -1
- data/spec/lib/secure_headers_spec.rb +31 -4
- data/spec/spec_helper.rb +1 -0
- metadata +9 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 591de0f41bc64b3520fbb2fdab9fc94b490d1604
|
|
4
|
+
data.tar.gz: f836c5e63e4d054ff2ce3f1ec597bbd9cf67ed4b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5317d425d7c65dfc73b32703aae7e16e3a566b620b42e3233cd6dc7403a1a9842bb7dc00ffc5c13a86240c5a8abee3ae07fed0c73d4b06a06bcc11db39a79a20
|
|
7
|
+
data.tar.gz: 154573bfb9112b4b1510abbde3f5eb1e85b709f7839ff4a6a547223e67e698ff014bb578f02b0e8775ee723016f5903e8cda38cb9846b24cafe3dc8e414bb007
|
data/.rspec
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.3.3
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## 3.7.0
|
|
2
|
+
|
|
3
|
+
Adds support for the `Expect-CT` header (@jacobbednarz: https://github.com/twitter/secureheaders/pull/322)
|
|
4
|
+
|
|
5
|
+
## 3.6.7
|
|
6
|
+
|
|
7
|
+
Actually set manifest-src when configured. https://github.com/twitter/secureheaders/pull/339 Thanks @carlosantoniodasilva!
|
|
8
|
+
|
|
9
|
+
## 3.6.6
|
|
10
|
+
|
|
11
|
+
wat?
|
|
12
|
+
|
|
13
|
+
## 3.6.5
|
|
14
|
+
|
|
15
|
+
Update clear-site-data header to use current format specified by the specification.
|
|
16
|
+
|
|
17
|
+
## 3.6.4
|
|
18
|
+
|
|
19
|
+
Fix case where mixing frame-src/child-src dynamically would behave in unexpected ways: https://github.com/twitter/secureheaders/pull/325
|
|
20
|
+
|
|
21
|
+
## 3.6.3
|
|
22
|
+
|
|
23
|
+
Remove deprecation warning when setting `frame-src`. It is no longer deprecated.
|
|
24
|
+
|
|
25
|
+
## 3.6.2
|
|
26
|
+
|
|
27
|
+
Now that Safari 10 supports nonces and it appears to work, enable the nonce feature for safari.
|
|
28
|
+
|
|
29
|
+
## 3.6.1
|
|
30
|
+
|
|
31
|
+
Improved memory use via minor improvements clever hacks that are sadly needed.
|
|
32
|
+
Thanks @carlosantoniodasilva!
|
|
33
|
+
|
|
1
34
|
## 3.6.0
|
|
2
35
|
|
|
3
36
|
Add support for the clear-site-data header
|
|
@@ -179,7 +212,7 @@ You can add hash sources directly to your policy :
|
|
|
179
212
|
rake secure_headers:generate_hashes
|
|
180
213
|
```
|
|
181
214
|
|
|
182
|
-
This will generate a file (`config/
|
|
215
|
+
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.
|
|
183
216
|
|
|
184
217
|
```yaml
|
|
185
218
|
---
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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 darrrr.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/LICENSE
CHANGED
|
@@ -1,202 +1,7 @@
|
|
|
1
|
+
Copyright 2013, 2014, 2015, 2016, 2017 Twitter, Inc.
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
-
|
|
181
|
-
To apply the Apache License to your work, attach the following
|
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
-
replaced with your own identifying information. (Don't include
|
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format. We also recommend that a
|
|
186
|
-
file or class name and description of purpose be included on the
|
|
187
|
-
same "printed page" as the copyright notice for easier
|
|
188
|
-
identification within third-party archives.
|
|
189
|
-
|
|
190
|
-
Copyright 2011 Julio Capote, Christopher Burnett
|
|
191
|
-
|
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
you may not use this file except in compliance with the License.
|
|
194
|
-
You may obtain a copy of the License at
|
|
195
|
-
|
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
|
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
-
See the License for the specific language governing permissions and
|
|
202
|
-
limitations under the License.
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -18,7 +18,8 @@ The gem will automatically apply several headers that are related to security.
|
|
|
18
18
|
- 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)
|
|
19
19
|
- Referrer-Policy - [Referrer Policy draft](https://w3c.github.io/webappsec-referrer-policy/)
|
|
20
20
|
- Public Key Pinning - Pin certificate fingerprints in the browser to prevent man-in-the-middle attacks due to compromised Certificate Authorities. [Public Key Pinning Specification](https://tools.ietf.org/html/rfc7469)
|
|
21
|
-
-
|
|
21
|
+
- Expect-CT - Only use certificates that are present in the certificate transparency logs. [Expect-CT draft specification](https://datatracker.ietf.org/doc/draft-stark-expect-ct/).
|
|
22
|
+
- Clear-Site-Data - Clearing browser data for origin. [Clear-Site-Data specification](https://w3c.github.io/webappsec-clear-site-data/).
|
|
22
23
|
|
|
23
24
|
It can also mark all http cookies with the Secure, HttpOnly and SameSite attributes (when configured to do so).
|
|
24
25
|
|
|
@@ -62,7 +63,8 @@ SecureHeaders::Configuration.default do |config|
|
|
|
62
63
|
lax: true # mark all cookies as SameSite=lax
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
+
# Add "; preload" and submit the site to hstspreload.org for best protection.
|
|
67
|
+
config.hsts = "max-age=#{20.years.to_i}; includeSubdomains"
|
|
66
68
|
config.x_frame_options = "DENY"
|
|
67
69
|
config.x_content_type_options = "nosniff"
|
|
68
70
|
config.x_xss_protection = "1; mode=block"
|
|
@@ -75,9 +77,14 @@ SecureHeaders::Configuration.default do |config|
|
|
|
75
77
|
"storage",
|
|
76
78
|
"executionContexts"
|
|
77
79
|
]
|
|
80
|
+
config.expect_certificate_transparency = {
|
|
81
|
+
enforce: false,
|
|
82
|
+
max_age: 1.day.to_i,
|
|
83
|
+
report_uri: "https://report-uri.io/example-ct"
|
|
84
|
+
}
|
|
78
85
|
config.csp = {
|
|
79
86
|
# "meta" values. these will shaped the header, but the values are not included in the header.
|
|
80
|
-
report_only: true, # default: false [DEPRECATED from 3.5.0: instead, configure csp_report_only]
|
|
87
|
+
# report_only: true, # default: false [DEPRECATED from 3.5.0: instead, configure csp_report_only]
|
|
81
88
|
preserve_schemes: true, # default: false. Schemes are removed from host sources to save bytes and discourage mixed content.
|
|
82
89
|
|
|
83
90
|
# directive values: these values will directly translate into source directives
|
|
@@ -90,6 +97,7 @@ SecureHeaders::Configuration.default do |config|
|
|
|
90
97
|
form_action: %w('self' github.com),
|
|
91
98
|
frame_ancestors: %w('none'),
|
|
92
99
|
img_src: %w(mycdn.com data:),
|
|
100
|
+
manifest_src: %w('self'),
|
|
93
101
|
media_src: %w(utoob.com),
|
|
94
102
|
object_src: %w('self'),
|
|
95
103
|
plugin_types: %w(application/x-shockwave-flash),
|
|
@@ -156,6 +164,7 @@ end
|
|
|
156
164
|
* Elixir [secure_headers](https://github.com/anotherhale/secure_headers)
|
|
157
165
|
* Dropwizard [dropwizard-web-security](https://github.com/palantir/dropwizard-web-security)
|
|
158
166
|
* Ember.js [ember-cli-content-security-policy](https://github.com/rwjblue/ember-cli-content-security-policy/)
|
|
167
|
+
* PHP [secure-headers](https://github.com/BePsvPT/secure-headers)
|
|
159
168
|
|
|
160
169
|
## License
|
|
161
170
|
|
data/docs/hashes.md
CHANGED
|
@@ -21,7 +21,7 @@ You can add hash sources directly to your policy :
|
|
|
21
21
|
rake secure_headers:generate_hashes
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
This will generate a file (`config/
|
|
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
25
|
|
|
26
26
|
```yaml
|
|
27
27
|
---
|
|
@@ -31,7 +31,7 @@ module SecureHeaders
|
|
|
31
31
|
raise NotYetConfiguredError, "#{base} policy not yet supplied"
|
|
32
32
|
end
|
|
33
33
|
override = @configurations[base].dup
|
|
34
|
-
override.instance_eval
|
|
34
|
+
override.instance_eval(&block) if block_given?
|
|
35
35
|
add_configuration(name, override)
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -116,23 +116,41 @@ module SecureHeaders
|
|
|
116
116
|
|
|
117
117
|
attr_writer :hsts, :x_frame_options, :x_content_type_options,
|
|
118
118
|
:x_xss_protection, :x_download_options, :x_permitted_cross_domain_policies,
|
|
119
|
-
:referrer_policy, :clear_site_data
|
|
119
|
+
:referrer_policy, :clear_site_data, :expect_certificate_transparency
|
|
120
120
|
|
|
121
121
|
attr_reader :cached_headers, :csp, :cookies, :csp_report_only, :hpkp, :hpkp_report_host
|
|
122
122
|
|
|
123
|
+
@script_hashes = nil
|
|
124
|
+
@style_hashes = nil
|
|
125
|
+
|
|
123
126
|
HASH_CONFIG_FILE = ENV["secure_headers_generated_hashes_file"] || "config/secure_headers_generated_hashes.yml"
|
|
124
|
-
if File.
|
|
127
|
+
if File.exist?(HASH_CONFIG_FILE)
|
|
125
128
|
config = YAML.safe_load(File.open(HASH_CONFIG_FILE))
|
|
126
129
|
@script_hashes = config["scripts"]
|
|
127
130
|
@style_hashes = config["styles"]
|
|
128
131
|
end
|
|
129
132
|
|
|
130
133
|
def initialize(&block)
|
|
134
|
+
@cookies = nil
|
|
135
|
+
@clear_site_data = nil
|
|
136
|
+
@csp = nil
|
|
137
|
+
@csp_report_only = nil
|
|
138
|
+
@hpkp_report_host = nil
|
|
139
|
+
@hpkp = nil
|
|
140
|
+
@hsts = nil
|
|
141
|
+
@x_content_type_options = nil
|
|
142
|
+
@x_download_options = nil
|
|
143
|
+
@x_frame_options = nil
|
|
144
|
+
@x_permitted_cross_domain_policies = nil
|
|
145
|
+
@x_xss_protection = nil
|
|
146
|
+
@expect_certificate_transparency = nil
|
|
147
|
+
|
|
131
148
|
self.hpkp = OPT_OUT
|
|
132
149
|
self.referrer_policy = OPT_OUT
|
|
133
150
|
self.csp = ContentSecurityPolicyConfig.new(ContentSecurityPolicyConfig::DEFAULT)
|
|
134
151
|
self.csp_report_only = OPT_OUT
|
|
135
|
-
|
|
152
|
+
|
|
153
|
+
instance_eval(&block) if block_given?
|
|
136
154
|
end
|
|
137
155
|
|
|
138
156
|
# Public: copy everything but the cached headers
|
|
@@ -151,6 +169,7 @@ module SecureHeaders
|
|
|
151
169
|
copy.x_download_options = @x_download_options
|
|
152
170
|
copy.x_permitted_cross_domain_policies = @x_permitted_cross_domain_policies
|
|
153
171
|
copy.clear_site_data = @clear_site_data
|
|
172
|
+
copy.expect_certificate_transparency = @expect_certificate_transparency
|
|
154
173
|
copy.referrer_policy = @referrer_policy
|
|
155
174
|
copy.hpkp = @hpkp
|
|
156
175
|
copy.hpkp_report_host = @hpkp_report_host
|
|
@@ -183,6 +202,7 @@ module SecureHeaders
|
|
|
183
202
|
XDownloadOptions.validate_config!(@x_download_options)
|
|
184
203
|
XPermittedCrossDomainPolicies.validate_config!(@x_permitted_cross_domain_policies)
|
|
185
204
|
ClearSiteData.validate_config!(@clear_site_data)
|
|
205
|
+
ExpectCertificateTransparency.validate_config!(@expect_certificate_transparency)
|
|
186
206
|
PublicKeyPins.validate_config!(@hpkp)
|
|
187
207
|
Cookie.validate_config!(@cookies)
|
|
188
208
|
end
|
|
@@ -262,7 +282,7 @@ module SecureHeaders
|
|
|
262
282
|
end
|
|
263
283
|
end
|
|
264
284
|
|
|
265
|
-
# Public: Precompute the header names and values for this
|
|
285
|
+
# Public: Precompute the header names and values for this configuration.
|
|
266
286
|
# Ensures that headers generated at configure time, not on demand.
|
|
267
287
|
#
|
|
268
288
|
# Returns the cached headers
|
|
@@ -2,7 +2,6 @@ module SecureHeaders
|
|
|
2
2
|
class ClearSiteDataConfigError < StandardError; end
|
|
3
3
|
class ClearSiteData
|
|
4
4
|
HEADER_NAME = "Clear-Site-Data".freeze
|
|
5
|
-
TYPES = "types".freeze
|
|
6
5
|
|
|
7
6
|
# Valid `types`
|
|
8
7
|
CACHE = "cache".freeze
|
|
@@ -22,9 +21,9 @@ module SecureHeaders
|
|
|
22
21
|
when nil, OPT_OUT, []
|
|
23
22
|
# noop
|
|
24
23
|
when Array
|
|
25
|
-
[HEADER_NAME,
|
|
24
|
+
[HEADER_NAME, make_header_value(config)]
|
|
26
25
|
when true
|
|
27
|
-
[HEADER_NAME,
|
|
26
|
+
[HEADER_NAME, make_header_value(ALL_TYPES)]
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
29
|
|
|
@@ -36,16 +35,20 @@ module SecureHeaders
|
|
|
36
35
|
unless config.all? { |t| t.is_a?(String) }
|
|
37
36
|
raise ClearSiteDataConfigError.new("types must be Strings")
|
|
38
37
|
end
|
|
39
|
-
|
|
40
|
-
begin
|
|
41
|
-
JSON.dump(config)
|
|
42
|
-
rescue JSON::GeneratorError, Encoding::UndefinedConversionError
|
|
43
|
-
raise ClearSiteDataConfigError.new("types must serializable by JSON")
|
|
44
|
-
end
|
|
45
38
|
else
|
|
46
39
|
raise ClearSiteDataConfigError.new("config must be an Array of Strings or `true`")
|
|
47
40
|
end
|
|
48
41
|
end
|
|
42
|
+
|
|
43
|
+
# Public: Transform a Clear-Site-Data config (an Array of Strings) into a
|
|
44
|
+
# String that can be used as the value for the Clear-Site-Data header.
|
|
45
|
+
#
|
|
46
|
+
# types - An Array of String of types of data to clear.
|
|
47
|
+
#
|
|
48
|
+
# Returns a String of quoted values that are comma separated.
|
|
49
|
+
def make_header_value(types)
|
|
50
|
+
types.map { |t| "\"#{t}\""}.join(", ")
|
|
51
|
+
end
|
|
49
52
|
end
|
|
50
53
|
end
|
|
51
54
|
end
|
|
@@ -59,8 +59,6 @@ module SecureHeaders
|
|
|
59
59
|
def normalize_child_frame_src
|
|
60
60
|
if @config.frame_src && @config.child_src && @config.frame_src != @config.child_src
|
|
61
61
|
Kernel.warn("#{Kernel.caller.first}: [DEPRECATION] both :child_src and :frame_src supplied and do not match. This can lead to inconsistent behavior across browsers.")
|
|
62
|
-
elsif @config.frame_src
|
|
63
|
-
Kernel.warn("#{Kernel.caller.first}: [DEPRECATION] :frame_src is deprecated, use :child_src instead. Provided: #{@config.frame_src}.")
|
|
64
62
|
end
|
|
65
63
|
|
|
66
64
|
if supported_directives.include?(:child_src)
|
|
@@ -216,6 +214,8 @@ module SecureHeaders
|
|
|
216
214
|
@supported_directives ||= if VARIATIONS[@parsed_ua.browser]
|
|
217
215
|
if @parsed_ua.browser == "Firefox" && ((@parsed_ua.version || FALLBACK_VERSION) >= VERSION_46)
|
|
218
216
|
VARIATIONS["FirefoxTransitional"]
|
|
217
|
+
elsif @parsed_ua.browser == "Safari" && ((@parsed_ua.version || FALLBACK_VERSION) >= VERSION_10)
|
|
218
|
+
VARIATIONS["SafariTransitional"]
|
|
219
219
|
else
|
|
220
220
|
VARIATIONS[@parsed_ua.browser]
|
|
221
221
|
end
|