web-console 3.5.1 → 4.2.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 +5 -5
- data/CHANGELOG.markdown +91 -8
- data/MIT-LICENSE +1 -1
- data/README.markdown +41 -38
- data/Rakefile +14 -12
- data/lib/web-console.rb +3 -1
- data/lib/web_console/context.rb +8 -6
- data/lib/web_console/errors.rb +2 -0
- data/lib/web_console/evaluator.rb +14 -5
- data/lib/web_console/exception_mapper.rb +33 -10
- data/lib/web_console/extensions.rb +12 -23
- data/lib/web_console/injector.rb +32 -0
- data/lib/web_console/interceptor.rb +17 -0
- data/lib/web_console/middleware.rb +21 -24
- data/lib/web_console/permissions.rb +42 -0
- data/lib/web_console/railtie.rb +36 -19
- data/lib/web_console/request.rb +8 -20
- data/lib/web_console/session.rb +13 -9
- data/lib/web_console/source_location.rb +17 -0
- data/lib/web_console/tasks/extensions.rake +15 -13
- data/lib/web_console/tasks/templates.rake +9 -13
- data/lib/web_console/template.rb +4 -3
- data/lib/web_console/templates/console.js.erb +140 -38
- data/lib/web_console/templates/error_page.js.erb +7 -8
- data/lib/web_console/templates/index.html.erb +4 -0
- data/lib/web_console/templates/layouts/inlined_string.erb +1 -1
- data/lib/web_console/templates/layouts/javascript.erb +1 -1
- data/lib/web_console/templates/regular_page.js.erb +24 -0
- data/lib/web_console/templates/style.css.erb +182 -33
- data/lib/web_console/testing/erb_precompiler.rb +5 -3
- data/lib/web_console/testing/fake_middleware.rb +14 -9
- data/lib/web_console/testing/helper.rb +3 -1
- data/lib/web_console/version.rb +3 -1
- data/lib/web_console/view.rb +11 -3
- data/lib/web_console/whiny_request.rb +7 -5
- data/lib/web_console.rb +17 -8
- metadata +17 -15
- data/lib/web_console/response.rb +0 -23
- data/lib/web_console/whitelist.rb +0 -44
data/lib/web_console/view.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WebConsole
|
2
4
|
class View < ActionView::Base
|
3
5
|
# Execute a block only on error pages.
|
@@ -8,6 +10,11 @@ module WebConsole
|
|
8
10
|
yield if Thread.current[:__web_console_exception].present?
|
9
11
|
end
|
10
12
|
|
13
|
+
# Execute a block only on regular, non-error, pages.
|
14
|
+
def only_on_regular_page(*args)
|
15
|
+
yield if Thread.current[:__web_console_binding].present?
|
16
|
+
end
|
17
|
+
|
11
18
|
# Render JavaScript inside a script tag and a closure.
|
12
19
|
#
|
13
20
|
# This one lets write JavaScript that will automatically get wrapped in a
|
@@ -15,7 +22,8 @@ module WebConsole
|
|
15
22
|
# leaking globals, unless you explicitly want to.
|
16
23
|
def render_javascript(template)
|
17
24
|
assign(template: template)
|
18
|
-
|
25
|
+
assign(nonce: @env["action_dispatch.content_security_policy_nonce"])
|
26
|
+
render(template: template, layout: "layouts/javascript")
|
19
27
|
end
|
20
28
|
|
21
29
|
# Render inlined string to be used inside of JavaScript code.
|
@@ -23,7 +31,7 @@ module WebConsole
|
|
23
31
|
# The inlined string is returned as an actual JavaScript string. You
|
24
32
|
# don't need to wrap the result yourself.
|
25
33
|
def render_inlined_string(template)
|
26
|
-
render(template: template, layout:
|
34
|
+
render(template: template, layout: "layouts/inlined_string")
|
27
35
|
end
|
28
36
|
|
29
37
|
# Custom ActionView::Base#render wrapper which silences all the log
|
@@ -31,7 +39,7 @@ module WebConsole
|
|
31
39
|
#
|
32
40
|
# Helps to keep the Rails logs clean during errors.
|
33
41
|
def render(*)
|
34
|
-
if logger = WebConsole.logger
|
42
|
+
if (logger = WebConsole.logger) && logger.respond_to?(:silence)
|
35
43
|
WebConsole.logger.silence { super }
|
36
44
|
else
|
37
45
|
super
|
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WebConsole
|
2
4
|
# Noisy wrapper around +Request+.
|
3
5
|
#
|
4
|
-
# If any calls to +
|
6
|
+
# If any calls to +permitted?+ and +acceptable_content_type?+
|
5
7
|
# return false, an info log message will be displayed in users' logs.
|
6
8
|
class WhinyRequest < SimpleDelegator
|
7
|
-
def
|
8
|
-
whine_unless request.
|
9
|
+
def permitted?
|
10
|
+
whine_unless request.permitted? do
|
9
11
|
"Cannot render console from #{request.strict_remote_ip}! " \
|
10
|
-
"Allowed networks: #{request.
|
12
|
+
"Allowed networks: #{request.permissions}"
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
@@ -21,7 +23,7 @@ module WebConsole
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def logger
|
24
|
-
env[
|
26
|
+
env["action_dispatch.logger"] || WebConsole.logger
|
25
27
|
end
|
26
28
|
|
27
29
|
def request
|
data/lib/web_console.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/dependencies/autoload"
|
4
|
+
require "active_support/logger"
|
3
5
|
|
4
6
|
module WebConsole
|
5
7
|
extend ActiveSupport::Autoload
|
@@ -8,21 +10,28 @@ module WebConsole
|
|
8
10
|
autoload :Evaluator
|
9
11
|
autoload :ExceptionMapper
|
10
12
|
autoload :Session
|
11
|
-
autoload :
|
13
|
+
autoload :Injector
|
14
|
+
autoload :Interceptor
|
12
15
|
autoload :Request
|
13
16
|
autoload :WhinyRequest
|
14
|
-
autoload :
|
17
|
+
autoload :Permissions
|
15
18
|
autoload :Template
|
16
19
|
autoload :Middleware
|
17
20
|
autoload :Context
|
21
|
+
autoload :SourceLocation
|
18
22
|
|
19
|
-
autoload_at
|
23
|
+
autoload_at "web_console/errors" do
|
20
24
|
autoload :Error
|
21
25
|
autoload :DoubleRenderError
|
22
26
|
end
|
23
27
|
|
24
|
-
|
25
|
-
|
28
|
+
def self.logger
|
29
|
+
(defined?(Rails.logger) && Rails.logger) || (@logger ||= ActiveSupport::Logger.new($stderr))
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.deprecator
|
33
|
+
@deprecator ||= ActiveSupport::Deprecation.new("5.0", "WebConsole")
|
34
|
+
end
|
26
35
|
end
|
27
36
|
|
28
|
-
require
|
37
|
+
require "web_console/railtie"
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web-console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Hailey Somerville
|
8
8
|
- Genadi Samokovarov
|
9
9
|
- Guillermo Iguaran
|
10
10
|
- Ryan Dao
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2023-09-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: railties
|
@@ -19,42 +19,42 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 6.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 6.0.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: activemodel
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
36
|
+
version: 6.0.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 6.0.0
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: actionview
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: 6.0.0
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
57
|
+
version: 6.0.0
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bindex
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,7 +71,7 @@ dependencies:
|
|
71
71
|
version: 0.4.0
|
72
72
|
description:
|
73
73
|
email:
|
74
|
-
-
|
74
|
+
- hailey@hailey.lol
|
75
75
|
- gsamokovarov@gmail.com
|
76
76
|
- guilleiguaran@gmail.com
|
77
77
|
- daoduyducduong@gmail.com
|
@@ -90,12 +90,15 @@ files:
|
|
90
90
|
- lib/web_console/evaluator.rb
|
91
91
|
- lib/web_console/exception_mapper.rb
|
92
92
|
- lib/web_console/extensions.rb
|
93
|
+
- lib/web_console/injector.rb
|
94
|
+
- lib/web_console/interceptor.rb
|
93
95
|
- lib/web_console/locales/en.yml
|
94
96
|
- lib/web_console/middleware.rb
|
97
|
+
- lib/web_console/permissions.rb
|
95
98
|
- lib/web_console/railtie.rb
|
96
99
|
- lib/web_console/request.rb
|
97
|
-
- lib/web_console/response.rb
|
98
100
|
- lib/web_console/session.rb
|
101
|
+
- lib/web_console/source_location.rb
|
99
102
|
- lib/web_console/tasks/extensions.rake
|
100
103
|
- lib/web_console/tasks/templates.rake
|
101
104
|
- lib/web_console/template.rb
|
@@ -108,6 +111,7 @@ files:
|
|
108
111
|
- lib/web_console/templates/layouts/inlined_string.erb
|
109
112
|
- lib/web_console/templates/layouts/javascript.erb
|
110
113
|
- lib/web_console/templates/main.js.erb
|
114
|
+
- lib/web_console/templates/regular_page.js.erb
|
111
115
|
- lib/web_console/templates/style.css.erb
|
112
116
|
- lib/web_console/testing/erb_precompiler.rb
|
113
117
|
- lib/web_console/testing/fake_middleware.rb
|
@@ -115,7 +119,6 @@ files:
|
|
115
119
|
- lib/web_console/version.rb
|
116
120
|
- lib/web_console/view.rb
|
117
121
|
- lib/web_console/whiny_request.rb
|
118
|
-
- lib/web_console/whitelist.rb
|
119
122
|
homepage: https://github.com/rails/web-console
|
120
123
|
licenses:
|
121
124
|
- MIT
|
@@ -128,15 +131,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
131
|
requirements:
|
129
132
|
- - ">="
|
130
133
|
- !ruby/object:Gem::Version
|
131
|
-
version: 2.
|
134
|
+
version: '2.5'
|
132
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
136
|
requirements:
|
134
137
|
- - ">="
|
135
138
|
- !ruby/object:Gem::Version
|
136
139
|
version: '0'
|
137
140
|
requirements: []
|
138
|
-
|
139
|
-
rubygems_version: 2.6.11
|
141
|
+
rubygems_version: 3.4.10
|
140
142
|
signing_key:
|
141
143
|
specification_version: 4
|
142
144
|
summary: A debugging tool for your Ruby on Rails applications.
|
data/lib/web_console/response.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module WebConsole
|
2
|
-
# A response object that writes content before the closing </body> tag, if
|
3
|
-
# possible.
|
4
|
-
#
|
5
|
-
# The object quacks like Rack::Response.
|
6
|
-
class Response < Struct.new(:body, :status, :headers)
|
7
|
-
def write(content)
|
8
|
-
raw_body = Array(body).first.to_s
|
9
|
-
|
10
|
-
if position = raw_body.rindex('</body>')
|
11
|
-
raw_body.insert(position, content)
|
12
|
-
else
|
13
|
-
raw_body << content
|
14
|
-
end
|
15
|
-
|
16
|
-
self.body = raw_body
|
17
|
-
end
|
18
|
-
|
19
|
-
def finish
|
20
|
-
Rack::Response.new(body, status, headers).finish
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'ipaddr'
|
2
|
-
|
3
|
-
module WebConsole
|
4
|
-
# Whitelist of allowed networks that can access Web Console.
|
5
|
-
#
|
6
|
-
# Networks are represented by standard IPAddr and can be either IPv4 or IPv6
|
7
|
-
# networks.
|
8
|
-
class Whitelist
|
9
|
-
# IPv4 and IPv6 localhost should be always whitelisted.
|
10
|
-
ALWAYS_WHITELISTED_NETWORKS = %w( 127.0.0.0/8 ::1 )
|
11
|
-
|
12
|
-
def initialize(networks = nil)
|
13
|
-
@networks = normalize_networks(networks).map(&method(:coerce_network_to_ipaddr)).uniq
|
14
|
-
end
|
15
|
-
|
16
|
-
def include?(network)
|
17
|
-
@networks.any? { |whitelist| whitelist.include?(network.to_s) }
|
18
|
-
rescue IPAddr::InvalidAddressError
|
19
|
-
false
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_s
|
23
|
-
@networks.map(&method(:human_readable_ipaddr)).join(', ')
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def normalize_networks(networks)
|
29
|
-
Array(networks).concat(ALWAYS_WHITELISTED_NETWORKS)
|
30
|
-
end
|
31
|
-
|
32
|
-
def coerce_network_to_ipaddr(network)
|
33
|
-
if network.is_a?(IPAddr)
|
34
|
-
network
|
35
|
-
else
|
36
|
-
IPAddr.new(network)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def human_readable_ipaddr(ipaddr)
|
41
|
-
ipaddr.to_range.to_s.split('..').uniq.join('/')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|