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: 3fbb8c67d7e707a85e9fe19dd21cc8156bb43468
4
- data.tar.gz: 6fac38bd16e2eb8a9310d518a345a4cc6b6a8ca2
3
+ metadata.gz: ac91612e7415a9d939bd442cf2b7d41d46dad68b
4
+ data.tar.gz: 0acf835ae3a831959761e6e03816cc8407175c9a
5
5
  SHA512:
6
- metadata.gz: 6c4bab74231007906d44b51b09a4b669f5e5749163d2493efc2056ac15de8715f2681ac598b446d461dbce13fe0f9fd0d31864484a8c44e0098f30fd56e8edc3
7
- data.tar.gz: 4765f8d6ecfeb229cdcb0fff0beb3328bcb17dd39e8a8deb6704b4997c5eef3962de4ff91ce53c4dac040df5edae22312493a05195423efd1683cb71cf37a19d
6
+ metadata.gz: df4a26937564cc02148927e728987f6e56d1878b8f27ca542ce16aec9298cec3827f867c362cd3a52e7e034391db11e04887d6b58e1435925fe227bdded90eaa
7
+ data.tar.gz: ef5894135e4e49ad2514eb7eaa7cbc4800781d8d2423b574f5436e59995993cf1aed10bb8492aa9310152d214803531c76814fd252b72fa8a3483486d951b859
@@ -1,6 +1,7 @@
1
- require "rack/livereload"
1
+ require 'rack/livereload'
2
2
 
3
- class Rack::LiveReload
4
- VERSION = '0.3.17'
3
+ module Rack
4
+ class LiveReload
5
+ VERSION = '0.3.18'.freeze
6
+ end
5
7
  end
6
-
@@ -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
 
@@ -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
-
@@ -1,5 +1,5 @@
1
- <% if defined?(SecureHeaders) %>
2
- <script type="text/javascript" nonce="<%= content_security_policy_script_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.17
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-19 00:00:00.000000000 Z
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