govuk_app_config 1.17.0 → 1.18.1
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/CHANGELOG.md +9 -0
- data/govuk_app_config.gemspec +1 -0
- data/lib/govuk_app_config.rb +5 -2
- data/lib/govuk_app_config/govuk_content_security_policy.rb +46 -105
- data/lib/govuk_app_config/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a50c0d77a0aae41136b1099a036a761c3e1a965ecb0184879f8f722d40786108
|
|
4
|
+
data.tar.gz: 87d38200558b9f2b945910ee6447cb150d53e83ad06005e0fa5c439ef70eb79d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af87829f8bf53a26b7df8b612e3a113c5d14ac0b3f09609bb62751c8376b20c81b37958702f43a9829d5c20ccaaf784c2b0e09ad9a5da034e323e2db228af7b2
|
|
7
|
+
data.tar.gz: 7786abef8b8319af18b79779e98f721c3526947d804534ef6f78c4b47b14e380997052de3f3fa10e8d4d4f661855fce1fa466894b7d8eab447ea54d12f75ad82
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# 1.18.1
|
|
2
|
+
|
|
3
|
+
* Fix incorrect report_uri= method usage in content security policy
|
|
4
|
+
|
|
5
|
+
# 1.18.0
|
|
6
|
+
|
|
7
|
+
* Use Rails DSL to configure content security policy, allowing apps to modify
|
|
8
|
+
the policy and use nonce features.
|
|
9
|
+
|
|
1
10
|
# 1.17.0
|
|
2
11
|
|
|
3
12
|
* Tweak our CSP to work with 'dev.gov.uk'
|
data/govuk_app_config.gemspec
CHANGED
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.add_dependency "unicorn", "~> 5.4.0"
|
|
29
29
|
|
|
30
30
|
spec.add_development_dependency "bundler", "~> 1.15"
|
|
31
|
+
spec.add_development_dependency "rails", "~> 5"
|
|
31
32
|
spec.add_development_dependency "rake", "~> 10.0"
|
|
32
33
|
spec.add_development_dependency "rspec", "~> 3.6.0"
|
|
33
34
|
spec.add_development_dependency "rspec-its", "~> 1.2.0"
|
data/lib/govuk_app_config.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require "govuk_app_config/version"
|
|
2
|
-
require "govuk_app_config/govuk_content_security_policy"
|
|
3
2
|
require "govuk_app_config/govuk_statsd"
|
|
4
3
|
require "govuk_app_config/govuk_error"
|
|
5
4
|
require "govuk_app_config/govuk_logging"
|
|
@@ -9,4 +8,8 @@ require "govuk_app_config/govuk_healthcheck"
|
|
|
9
8
|
require "govuk_app_config/govuk_unicorn"
|
|
10
9
|
require "govuk_app_config/govuk_xray"
|
|
11
10
|
require "govuk_app_config/configure"
|
|
12
|
-
|
|
11
|
+
|
|
12
|
+
if defined?(Rails)
|
|
13
|
+
require "govuk_app_config/railtie"
|
|
14
|
+
require "govuk_app_config/govuk_content_security_policy"
|
|
15
|
+
end
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
module GovukContentSecurityPolicy
|
|
2
2
|
# Generate a Content Security Policy (CSP) directive.
|
|
3
3
|
#
|
|
4
|
-
#
|
|
5
|
-
# Extracted in a separate module to allow comments.
|
|
6
|
-
#
|
|
7
4
|
# See https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP for more CSP info.
|
|
8
5
|
#
|
|
9
6
|
# The resulting policy should be checked with:
|
|
@@ -12,131 +9,75 @@ module GovukContentSecurityPolicy
|
|
|
12
9
|
# - https://cspvalidator.org
|
|
13
10
|
|
|
14
11
|
GOVUK_DOMAINS = [
|
|
15
|
-
"'self'",
|
|
16
12
|
'*.publishing.service.gov.uk',
|
|
17
13
|
"*.#{ENV['GOVUK_APP_DOMAIN_EXTERNAL'] || ENV['GOVUK_APP_DOMAIN'] || 'dev.gov.uk'}"
|
|
18
|
-
].uniq.
|
|
19
|
-
|
|
20
|
-
GOOGLE_ANALYTICS_DOMAINS = "www.google-analytics.com ssl.google-analytics.com stats.g.doubleclick.net".freeze
|
|
14
|
+
].uniq.freeze
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
GOOGLE_ANALYTICS_DOMAINS = %w(www.google-analytics.com
|
|
17
|
+
ssl.google-analytics.com
|
|
18
|
+
stats.g.doubleclick.net).freeze
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
# the publishing domain
|
|
27
|
-
#
|
|
20
|
+
def self.build_policy(policy)
|
|
28
21
|
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/default-src
|
|
29
|
-
|
|
30
|
-
"default-src https",
|
|
31
|
-
GOVUK_DOMAINS
|
|
32
|
-
]
|
|
22
|
+
policy.default_src :https, :self, *GOVUK_DOMAINS
|
|
33
23
|
|
|
34
|
-
# Allow images from the current domain, Google Analytics (the tracking pixel),
|
|
35
|
-
# and publishing domains.
|
|
36
24
|
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/img-src
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"data:",
|
|
44
|
-
|
|
45
|
-
GOVUK_DOMAINS,
|
|
46
|
-
GOOGLE_ANALYTICS_DOMAINS,
|
|
25
|
+
policy.img_src :self,
|
|
26
|
+
:data, # Base64 encoded images
|
|
27
|
+
*GOVUK_DOMAINS,
|
|
28
|
+
*GOOGLE_ANALYTICS_DOMAINS, # Tracking pixels
|
|
29
|
+
# Some content still links to an old domain we used to use
|
|
30
|
+
"assets.digital.cabinet-office.gov.uk"
|
|
47
31
|
|
|
48
|
-
# Some content still links to an old domain we used to use
|
|
49
|
-
"assets.digital.cabinet-office.gov.uk",
|
|
50
|
-
]
|
|
51
|
-
|
|
52
|
-
# script-src determines the scripts that the browser can load
|
|
53
|
-
#
|
|
54
32
|
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"*.ytimg.com",
|
|
68
|
-
"www.youtube.com",
|
|
69
|
-
|
|
70
|
-
# Allow all inline scripts until we can conclusively document all the inline scripts we use,
|
|
71
|
-
# and there's a better way to filter out junk reports
|
|
72
|
-
"'unsafe-inline'"
|
|
73
|
-
]
|
|
33
|
+
policy.script_src :self,
|
|
34
|
+
*GOVUK_DOMAINS,
|
|
35
|
+
*GOOGLE_ANALYTICS_DOMAINS,
|
|
36
|
+
# Allow JSONP call to Verify to check whether the user is logged in
|
|
37
|
+
"www.signin.service.gov.uk",
|
|
38
|
+
# Allow YouTube Embeds (Govspeak turns YouTube links into embeds)
|
|
39
|
+
"*.ytimg.com",
|
|
40
|
+
"www.youtube.com",
|
|
41
|
+
# Allow all inline scripts until we can conclusively
|
|
42
|
+
# document all the inline scripts we use,
|
|
43
|
+
# and there's a better way to filter out junk reports
|
|
44
|
+
:unsafe_inline
|
|
74
45
|
|
|
75
|
-
# Allow styles from own domain and publishing domains.
|
|
76
|
-
#
|
|
77
46
|
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
# Also allow "unsafe-inline" styles, because we use the `style=""` attribute on some HTML elements
|
|
83
|
-
"'unsafe-inline'"
|
|
84
|
-
]
|
|
47
|
+
policy.style_src :self,
|
|
48
|
+
*GOVUK_DOMAINS,
|
|
49
|
+
# We use the `style=""` attribute on some HTML elements
|
|
50
|
+
:unsafe_inline
|
|
85
51
|
|
|
86
|
-
# Allow fonts to be loaded from data-uri's (this is the old way of doing things)
|
|
87
|
-
# or from the publishing asset domains.
|
|
88
|
-
#
|
|
89
|
-
# https://www.staging.publishing.service.gov.uk/apply-for-a-licence/test-licence/westminster/apply-1
|
|
90
|
-
#
|
|
91
52
|
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/font-src
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
]
|
|
53
|
+
policy.font_src :self,
|
|
54
|
+
*GOVUK_DOMAINS,
|
|
55
|
+
:data # Used by some legacy fonts
|
|
96
56
|
|
|
97
57
|
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/connect-src
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
# https://www.staging.publishing.service.gov.uk/government/organisations/hm-revenue-customs/contact/child-benefit
|
|
106
|
-
"www.tax.service.gov.uk",
|
|
107
|
-
|
|
108
|
-
# Allow connecting to Verify to check whether the user is logged in
|
|
109
|
-
# https://github.com/alphagov/government-frontend/blob/71aca4df9b74366618a5a93acdb5cd2715f94f49/app/assets/javascripts/modules/track-radio-group.js
|
|
110
|
-
# https://www.staging.publishing.service.gov.uk/log-in-file-self-assessment-tax-return/sign-in/prove-identity
|
|
111
|
-
"www.signin.service.gov.uk",
|
|
112
|
-
]
|
|
58
|
+
policy.connect_src :self,
|
|
59
|
+
*GOVUK_DOMAINS,
|
|
60
|
+
*GOOGLE_ANALYTICS_DOMAINS,
|
|
61
|
+
# Allow connecting to web chat from HMRC contact pages
|
|
62
|
+
"www.tax.service.gov.uk",
|
|
63
|
+
# Allow connecting to Verify to check whether the user is logged in
|
|
64
|
+
"www.signin.service.gov.uk"
|
|
113
65
|
|
|
114
66
|
# Disallow all <object>, <embed>, and <applet> elements
|
|
115
67
|
#
|
|
116
68
|
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/object-src
|
|
117
|
-
|
|
118
|
-
"object-src 'none'"
|
|
119
|
-
]
|
|
120
|
-
|
|
121
|
-
policies << [
|
|
122
|
-
"frame-src",
|
|
69
|
+
policy.object_src :none
|
|
123
70
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
]
|
|
71
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-src
|
|
72
|
+
policy.frame_src :self, *GOVUK_DOMAINS, "www.youtube.com" # Allow youtube embeds
|
|
127
73
|
|
|
128
|
-
|
|
74
|
+
# AWS Lambda function that filters out junk reports.
|
|
75
|
+
policy.report_uri "https://jhpno0hk6b.execute-api.eu-west-2.amazonaws.com/production" if Rails.env.production?
|
|
129
76
|
end
|
|
130
77
|
|
|
131
78
|
def self.configure
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if Rails.env.production?
|
|
136
|
-
reporting = "report-uri https://jhpno0hk6b.execute-api.eu-west-2.amazonaws.com/production"
|
|
137
|
-
Rails.application.config.action_dispatch.default_headers['Content-Security-Policy-Report-Only'] = self.build + " " + reporting
|
|
138
|
-
else
|
|
139
|
-
Rails.application.config.action_dispatch.default_headers['Content-Security-Policy'] = self.build
|
|
140
|
-
end
|
|
79
|
+
Rails.application.config.content_security_policy_report_only = true if Rails.env.production?
|
|
80
|
+
|
|
81
|
+
Rails.application.config.content_security_policy(&method(:build_policy))
|
|
141
82
|
end
|
|
142
83
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: govuk_app_config
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.18.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GOV.UK Dev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-06-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aws-xray-sdk
|
|
@@ -94,6 +94,20 @@ dependencies:
|
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '1.15'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: rails
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '5'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '5'
|
|
97
111
|
- !ruby/object:Gem::Dependency
|
|
98
112
|
name: rake
|
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|