slimmer 18.0.0 → 18.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/slimmer/processors/nonce_inserter.rb +21 -0
- data/lib/slimmer/skin.rb +1 -0
- data/lib/slimmer/version.rb +1 -1
- data/lib/slimmer.rb +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ed01a6ffcd005b8c3c535e3c470111fc7fbc8616fa8cb4de03c167ac76c91e9
|
4
|
+
data.tar.gz: 630246d90121b56ebe60511dd04a1f2fbf83ef7bf124bbd17be473d49976c599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a2e20be60419f1aecb3630bc1d26029ad2c216b30f3b1308a56a6779d8e7d420e9e1b68adb24ccf4a5b8fed8efbe86c75a4ab8b6e8572e310305a4ae3c09456
|
7
|
+
data.tar.gz: 2ae4731e6714cf0ebb47706b8a6723ae113e86fae9cafdd293e6b5c817a7df1faae9163a82f87539897a67c78b9f3c274e8491cd5bd5f7d1190e7cab15a14e4b
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Slimmer::Processors
|
2
|
+
class NonceInserter
|
3
|
+
def initialize(env)
|
4
|
+
# As Rails is an optional dependency of this gem quietly do nothing if Rails
|
5
|
+
# classes don't exist.
|
6
|
+
@nonce = if defined?(ActionDispatch::Request)
|
7
|
+
ActionDispatch::Request.new(env).content_security_policy_nonce
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def filter(_src, dest)
|
12
|
+
return unless @nonce
|
13
|
+
|
14
|
+
# Add the nonce attribute to script elements that don't have a src attribute
|
15
|
+
# we expect those with src to be on a CSP host allow list
|
16
|
+
dest.css("script:not([src])").each do |script|
|
17
|
+
script["nonce"] = @nonce
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/slimmer/skin.rb
CHANGED
@@ -104,6 +104,7 @@ module Slimmer
|
|
104
104
|
template_wrapper_id = "wrapper" # All templates in Static use `#wrapper`
|
105
105
|
|
106
106
|
processors = [
|
107
|
+
Processors::NonceInserter.new(source_request.env), # for security, this needs to be run before any application HTML is inserted
|
107
108
|
Processors::TitleInserter.new,
|
108
109
|
Processors::TagMover.new,
|
109
110
|
Processors::ConditionalCommentMover.new,
|
data/lib/slimmer/version.rb
CHANGED
data/lib/slimmer.rb
CHANGED
@@ -38,6 +38,7 @@ module Slimmer
|
|
38
38
|
autoload :ConditionalCommentMover, "slimmer/processors/conditional_comment_mover"
|
39
39
|
autoload :FeedbackURLSwapper, "slimmer/processors/feedback_url_swapper"
|
40
40
|
autoload :MetadataInserter, "slimmer/processors/metadata_inserter"
|
41
|
+
autoload :NonceInserter, "slimmer/processors/nonce_inserter"
|
41
42
|
autoload :HeaderContextInserter, "slimmer/processors/header_context_inserter"
|
42
43
|
autoload :InsideHeaderInserter, "slimmer/processors/inside_header_inserter"
|
43
44
|
autoload :SearchPathSetter, "slimmer/processors/search_path_setter"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 18.
|
4
|
+
version: 18.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - '='
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 4.
|
173
|
+
version: 4.9.0
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - '='
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 4.
|
180
|
+
version: 4.9.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: webmock
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- lib/slimmer/processors/header_context_inserter.rb
|
217
217
|
- lib/slimmer/processors/inside_header_inserter.rb
|
218
218
|
- lib/slimmer/processors/metadata_inserter.rb
|
219
|
+
- lib/slimmer/processors/nonce_inserter.rb
|
219
220
|
- lib/slimmer/processors/search_parameter_inserter.rb
|
220
221
|
- lib/slimmer/processors/search_path_setter.rb
|
221
222
|
- lib/slimmer/processors/search_remover.rb
|
@@ -250,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
251
|
- !ruby/object:Gem::Version
|
251
252
|
version: '0'
|
252
253
|
requirements: []
|
253
|
-
rubygems_version: 3.
|
254
|
+
rubygems_version: 3.4.4
|
254
255
|
signing_key:
|
255
256
|
specification_version: 4
|
256
257
|
summary: Thinner than the skinner
|