Skip to content

Commit becb8df

Browse files
committed
Merge branch 'feature-7.2' into hash-generation-testing
2 parents 32d3eb0 + 95a938d commit becb8df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+593
-462
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/build.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
name: Build + Test
2-
on: [pull_request]
2+
on: [pull_request, push]
3+
4+
permissions:
5+
contents: read
36

47
jobs:
58
build:
69
name: Build + Test
710
runs-on: ubuntu-latest
811
strategy:
912
matrix:
10-
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
13+
ruby: [ '2.7', '3.0', '3.1', '3.2', '3.4', '4.0' ]
1114

1215
steps:
13-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1417
- name: Set up Ruby ${{ matrix.ruby }}
15-
uses: ruby/setup-ruby@v1
18+
uses: ruby/setup-ruby@d697be2f83c6234b20877c3b5eac7a7f342f0d0c #v1.269.0 tag
1619
with:
1720
ruby-version: ${{ matrix.ruby }}
21+
bundler-cache: true
1822
- name: Build and test with Rake
1923
run: |
20-
gem install bundler
21-
bundle install --jobs 4 --retry 3 --without guard
22-
bundle exec rspec spec
2324
bundle exec rubocop
24-
25+
bundle exec rspec spec
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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

.rubocop.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
inherit_gem:
22
rubocop-github:
33
- config/default.yml
4-
require: rubocop-performance
4+
plugins: rubocop-performance
5+
6+
AllCops:
7+
TargetRubyVersion: 2.6
8+
9+
# Disable cops that are not consistently available across all Ruby versions
10+
Lint/RedundantCopDisableDirective:
11+
Enabled: false

.ruby-gemset

Lines changed: 0 additions & 1 deletion
This file was deleted.

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.6.6
1+
3.1.6

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 6.5.0
2+
3+
- CSP: Remove source expression deduplication. (@lgarron) https://github.com/github/secure_headers/pull/499
4+
5+
## 6.4.0
6+
7+
- CSP: Add support for trusted-types, require-trusted-types-for directive (@JackMc): https://github.com/github/secure_headers/pull/486
8+
9+
## 6.3.4
10+
11+
- CSP: Do not deduplicate alternate schema source expressions (@keithamus): https://github.com/github/secure_headers/pull/478
12+
113
## 6.3.3
214

315
Fix hash generation for indented helper methods (@rahearn)
@@ -58,7 +70,7 @@ NOTE: this version is a breaking change due to the removal of HPKP. Remove the H
5870

5971
## 5.0.0
6072

61-
Well this is a little embarassing. 4.0 was supposed to set the secure/httponly/samesite=lax attributes on cookies by default but it didn't. Now it does. - See the [upgrading to 5.0](docs/upgrading-to-5-0.md) guide.
73+
Well this is a little embarrassing. 4.0 was supposed to set the secure/httponly/samesite=lax attributes on cookies by default but it didn't. Now it does. - See the [upgrading to 5.0](docs/upgrading-to-5-0.md) guide.
6274

6375
## 4.0.1
6476

@@ -182,7 +194,7 @@ end
182194

183195
## 3.4.0 the frame-src/child-src transition for Firefox.
184196

185-
Handle the `child-src`/`frame-src` transition semi-intelligently across versions. I think the code best descibes the behavior here:
197+
Handle the `child-src`/`frame-src` transition semi-intelligently across versions. I think the code best describes the behavior here:
186198

187199
```ruby
188200
if supported_directives.include?(:child_src)

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ source "https://rubygems.org"
33

44
gemspec
55

6+
gem "benchmark-ips"
7+
68
group :test do
79
gem "coveralls"
810
gem "json"

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Secure Headers ![Build + Test](https://github.com/github/secure_headers/workflows/Build%20+%20Test/badge.svg?branch=main)
1+
# Secure Headers [![Build + Test](https://github.com/github/secure_headers/actions/workflows/build.yml/badge.svg)](https://github.com/github/secure_headers/actions/workflows/build.yml)
22

3-
**main branch represents 6.x line**. See the [upgrading to 4.x doc](docs/upgrading-to-4-0.md), [upgrading to 5.x doc](docs/upgrading-to-5-0.md), or [upgrading to 6.x doc](docs/upgrading-to-6-0.md) for instructions on how to upgrade. Bug fixes should go in the 5.x branch for now.
3+
**main branch represents 7.x line**. See the [upgrading to 4.x doc](docs/upgrading-to-4-0.md), [upgrading to 5.x doc](docs/upgrading-to-5-0.md), [upgrading to 6.x doc](docs/upgrading-to-6-0.md) or [upgrading to 7.x doc](docs/upgrading-to-7-0.md) for instructions on how to upgrade. Bug fixes should go in the `6.x` branch for now.
44

55
The gem will automatically apply several headers that are related to security. This includes:
66
- Content Security Policy (CSP) - Helps detect/prevent XSS, mixed-content, and other classes of attack. [CSP 2 Specification](https://www.w3.org/TR/CSP2/)
@@ -11,11 +11,11 @@ The gem will automatically apply several headers that are related to security.
1111
- X-Frame-Options (XFO) - Prevents your content from being framed and potentially clickjacked. [X-Frame-Options Specification](https://tools.ietf.org/html/rfc7034)
1212
- X-XSS-Protection - [Cross site scripting heuristic filter for IE/Chrome](https://msdn.microsoft.com/en-us/library/dd565647\(v=vs.85\).aspx)
1313
- X-Content-Type-Options - [Prevent content type sniffing](https://msdn.microsoft.com/library/gg622941\(v=vs.85\).aspx)
14-
- X-Download-Options - [Prevent file downloads opening](https://msdn.microsoft.com/library/jj542450(v=vs.85).aspx)
15-
- 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)
16-
- Referrer-Policy - [Referrer Policy draft](https://w3c.github.io/webappsec-referrer-policy/)
17-
- 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/).
18-
- Clear-Site-Data - Clearing browser data for origin. [Clear-Site-Data specification](https://w3c.github.io/webappsec-clear-site-data/).
14+
- x-download-options - [Prevent file downloads opening](https://msdn.microsoft.com/library/jj542450(v=vs.85).aspx)
15+
- 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)
16+
- referrer-policy - [Referrer Policy draft](https://w3c.github.io/webappsec-referrer-policy/)
17+
- 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/).
18+
- clear-site-data - Clearing browser data for origin. [clear-site-data specification](https://w3c.github.io/webappsec-clear-site-data/).
1919

2020
It can also mark all http cookies with the Secure, HttpOnly and SameSite attributes. This is on default but can be turned off by using `config.cookies = SecureHeaders::OPT_OUT`.
2121

@@ -62,7 +62,6 @@ SecureHeaders::Configuration.default do |config|
6262
# directive values: these values will directly translate into source directives
6363
default_src: %w('none'),
6464
base_uri: %w('self'),
65-
block_all_mixed_content: true, # see https://www.w3.org/TR/mixed-content/
6665
child_src: %w('self'), # if child-src isn't supported, the value for frame-src will be set.
6766
connect_src: %w(wss:),
6867
font_src: %w('self' data:),
@@ -92,18 +91,21 @@ SecureHeaders::Configuration.default do |config|
9291
end
9392
```
9493

94+
### Deprecated Configuration Values
95+
* `block_all_mixed_content` - this value is deprecated in favor of `upgrade_insecure_requests`. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/block-all-mixed-content for more information.
96+
9597
## Default values
9698

9799
All headers except for PublicKeyPins and ClearSiteData have a default value. The default set of headers is:
98100

99101
```
100-
Content-Security-Policy: default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline'
101-
Strict-Transport-Security: max-age=631138519
102-
X-Content-Type-Options: nosniff
103-
X-Download-Options: noopen
104-
X-Frame-Options: sameorigin
105-
X-Permitted-Cross-Domain-Policies: none
106-
X-Xss-Protection: 1; mode=block
102+
content-security-policy: default-src 'self' https:; font-src 'self' https: data:; img-src 'self' https: data:; object-src 'none'; script-src https:; style-src 'self' https: 'unsafe-inline'
103+
strict-transport-security: max-age=631138519
104+
x-content-type-options: nosniff
105+
x-download-options: noopen
106+
x-frame-options: sameorigin
107+
x-permitted-cross-domain-policies: none
108+
x-xss-protection: 0
107109
```
108110

109111
## API configurations

docs/hashes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ console.log(1)
5858
```
5959

6060
```
61-
Content-Security-Policy: ...
61+
content-security-policy: ...
6262
script-src 'sha256-yktKiAsZWmc8WpOyhnmhQoDf9G2dAZvuBBC+V0LGQhg=' ... ;
6363
style-src 'sha256-SLp6LO3rrKDJwsG9uJUxZapb4Wp2Zhj6Bu3l+d9rnAY=' 'sha256-HSGHqlRoKmHAGTAJ2Rq0piXX4CnEbOl1ArNd6ejp2TE=' ...;
6464
```

0 commit comments

Comments
 (0)