leifcr-rack-livereload 0.3.17 → 0.3.18
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac91612e7415a9d939bd442cf2b7d41d46dad68b
|
4
|
+
data.tar.gz: 0acf835ae3a831959761e6e03816cc8407175c9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df4a26937564cc02148927e728987f6e56d1878b8f27ca542ce16aec9298cec3827f867c362cd3a52e7e034391db11e04887d6b58e1435925fe227bdded90eaa
|
7
|
+
data.tar.gz: ef5894135e4e49ad2514eb7eaa7cbc4800781d8d2423b574f5436e59995993cf1aed10bb8492aa9310152d214803531c76814fd252b72fa8a3483486d951b859
|
data/lib/rack-livereload.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rack/livereload'
|
2
|
-
|
2
|
+
require 'rack/request'
|
3
3
|
module Rack
|
4
4
|
class LiveReload
|
5
5
|
class BodyProcessor
|
@@ -86,6 +86,10 @@ module Rack
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def template
|
89
|
+
if defined?(SecureHeaders)
|
90
|
+
req = Rack::Request.new(@env)
|
91
|
+
@options[:nonce] = SecureHeaders.content_security_policy_script_nonce(req)
|
92
|
+
end
|
89
93
|
ERB.new(::File.read(::File.expand_path('../../../../skel/livereload.html.erb', __FILE__)))
|
90
94
|
end
|
91
95
|
|
data/rack-livereload.gemspec
CHANGED
@@ -33,8 +33,8 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_development_dependency "guard-cucumber"
|
34
34
|
s.add_development_dependency "guard-livereload"
|
35
35
|
s.add_development_dependency "webmock"
|
36
|
+
s.add_development_dependency "secure_headers"
|
36
37
|
s.add_development_dependency "nokogiri", ("< 1.6" if RUBY_VERSION < "1.9") # Nokogiri >= 1.6 requires Ruby >= 1.9
|
37
38
|
s.add_development_dependency 'appraisal', '~> 0.4'
|
38
39
|
s.add_runtime_dependency "rack"
|
39
40
|
end
|
40
|
-
|
data/skel/livereload.html.erb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
<% if
|
2
|
-
<script type="text/javascript" nonce="<%=
|
1
|
+
<% if @options[:nonce] %>
|
2
|
+
<script type="text/javascript" nonce="<%= @options[:nonce] %>">
|
3
3
|
RACK_LIVERELOAD_PORT = <%= @options[:live_reload_port] %>;
|
4
4
|
</script>
|
5
5
|
<% else %>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
describe "Rack::LiveReload::BodyProcessor - with secure" do
|
5
|
+
let(:processor) { Rack::LiveReload::BodyProcessor.new(body, options) }
|
6
|
+
let(:body) { [ page_html ] }
|
7
|
+
let(:options) { {} }
|
8
|
+
let(:page_html) { '<head></head>' }
|
9
|
+
let(:processor_result) do
|
10
|
+
if !processor.processed?
|
11
|
+
processor.process!(env)
|
12
|
+
end
|
13
|
+
|
14
|
+
processor
|
15
|
+
end
|
16
|
+
|
17
|
+
subject { processor }
|
18
|
+
|
19
|
+
context 'text/html' do
|
20
|
+
before do
|
21
|
+
processor.stubs(:use_vendored?).returns(true)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:host) { 'host' }
|
25
|
+
let(:env) { { 'HTTP_HOST' => host } }
|
26
|
+
|
27
|
+
let(:processed_body) { processor_result.new_body.join('') }
|
28
|
+
let(:length) { processor_result.content_length }
|
29
|
+
|
30
|
+
let(:page_html) { '<head></head>' }
|
31
|
+
|
32
|
+
context 'vendored' do
|
33
|
+
it 'should add the vendored livereload js script tag' do
|
34
|
+
require 'secure_headers'
|
35
|
+
SecureHeaders::Configuration.default
|
36
|
+
|
37
|
+
expect(processed_body).to include("script")
|
38
|
+
expect(processed_body).to include("nonce")
|
39
|
+
expect(processed_body).to include(Rack::LiveReload::BodyProcessor::LIVERELOAD_JS_PATH)
|
40
|
+
|
41
|
+
expect(length.to_s).to eq(processed_body.length.to_s)
|
42
|
+
|
43
|
+
expect(Rack::LiveReload::BodyProcessor::LIVERELOAD_JS_PATH).not_to include(host)
|
44
|
+
Object.send(:remove_const, :SecureHeaders)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leifcr-rack-livereload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bintz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: secure_headers
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: nokogiri
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -266,6 +280,7 @@ files:
|
|
266
280
|
- rack-livereload.gemspec
|
267
281
|
- skel/livereload.html.erb
|
268
282
|
- spec/rack/livereload/body_processor_spec.rb
|
283
|
+
- spec/rack/livereload/body_processor_with_secure_headers_spec.rb
|
269
284
|
- spec/rack/livereload/processing_skip_analyzer_spec.rb
|
270
285
|
- spec/rack/livereload_spec.rb
|
271
286
|
- spec/spec_helper.rb
|