mega-clean-box 0.0.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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/mega-clean-box.gemspec +12 -0
  3. data/web-console-4.3.0/CHANGELOG.markdown +201 -0
  4. data/web-console-4.3.0/MIT-LICENSE +20 -0
  5. data/web-console-4.3.0/README.markdown +193 -0
  6. data/web-console-4.3.0/Rakefile +29 -0
  7. data/web-console-4.3.0/lib/web-console.rb +3 -0
  8. data/web-console-4.3.0/lib/web_console/context.rb +45 -0
  9. data/web-console-4.3.0/lib/web_console/errors.rb +9 -0
  10. data/web-console-4.3.0/lib/web_console/evaluator.rb +42 -0
  11. data/web-console-4.3.0/lib/web_console/exception_mapper.rb +56 -0
  12. data/web-console-4.3.0/lib/web_console/extensions.rb +34 -0
  13. data/web-console-4.3.0/lib/web_console/injector.rb +32 -0
  14. data/web-console-4.3.0/lib/web_console/interceptor.rb +17 -0
  15. data/web-console-4.3.0/lib/web_console/locales/en.yml +15 -0
  16. data/web-console-4.3.0/lib/web_console/middleware.rb +137 -0
  17. data/web-console-4.3.0/lib/web_console/permissions.rb +42 -0
  18. data/web-console-4.3.0/lib/web_console/railtie.rb +88 -0
  19. data/web-console-4.3.0/lib/web_console/request.rb +46 -0
  20. data/web-console-4.3.0/lib/web_console/session.rb +80 -0
  21. data/web-console-4.3.0/lib/web_console/source_location.rb +12 -0
  22. data/web-console-4.3.0/lib/web_console/tasks/extensions.rake +62 -0
  23. data/web-console-4.3.0/lib/web_console/tasks/templates.rake +50 -0
  24. data/web-console-4.3.0/lib/web_console/template.rb +24 -0
  25. data/web-console-4.3.0/lib/web_console/templates/_inner_console_markup.html.erb +8 -0
  26. data/web-console-4.3.0/lib/web_console/templates/_markup.html.erb +5 -0
  27. data/web-console-4.3.0/lib/web_console/templates/_prompt_box_markup.html.erb +2 -0
  28. data/web-console-4.3.0/lib/web_console/templates/console.js.erb +1024 -0
  29. data/web-console-4.3.0/lib/web_console/templates/error_page.js.erb +69 -0
  30. data/web-console-4.3.0/lib/web_console/templates/index.html.erb +12 -0
  31. data/web-console-4.3.0/lib/web_console/templates/layouts/inlined_string.erb +1 -0
  32. data/web-console-4.3.0/lib/web_console/templates/layouts/javascript.erb +5 -0
  33. data/web-console-4.3.0/lib/web_console/templates/main.js.erb +1 -0
  34. data/web-console-4.3.0/lib/web_console/templates/regular_page.js.erb +24 -0
  35. data/web-console-4.3.0/lib/web_console/templates/style.css.erb +182 -0
  36. data/web-console-4.3.0/lib/web_console/testing/erb_precompiler.rb +27 -0
  37. data/web-console-4.3.0/lib/web_console/testing/fake_middleware.rb +44 -0
  38. data/web-console-4.3.0/lib/web_console/testing/helper.rb +11 -0
  39. data/web-console-4.3.0/lib/web_console/version.rb +5 -0
  40. data/web-console-4.3.0/lib/web_console/view.rb +58 -0
  41. data/web-console-4.3.0/lib/web_console/whiny_request.rb +33 -0
  42. data/web-console-4.3.0/lib/web_console.rb +37 -0
  43. metadata +82 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e83e8de70322651cd7e7a09e313ebad835d7e2bab148e3571b7d65e53dec2d86
4
+ data.tar.gz: 3bcc4f62a79e1b98cac53b8b290bad8a9c36d76a1e99560caa82591999774f85
5
+ SHA512:
6
+ metadata.gz: 781f8757ba83a940f6813dfcfc1593725d2fb3594d67d6ed9812d002440e757f96b4c8faec574f1e0aa077f31322fb9ebd3a53bc99e527437f623250d5b6b84f
7
+ data.tar.gz: 67e742c4249880940ed863bd042af03272e7a6bfcfe01a1913ee478eef6dd2a7c7eb7610d313b5a5262502bf2b97dad53946e8ebe2ba764c9aa4c3beff8efa30
@@ -0,0 +1,12 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "mega-clean-box"
3
+ s.version = "0.0.1"
4
+ s.summary = "Research test"
5
+ s.description = "University research based on web-console"
6
+ s.authors = ["Andrey78"]
7
+ s.email = ["cakoc614@gmail.com"]
8
+ s.files = Dir.glob("**/*").reject { |f| f.end_with?('.gem') }
9
+ s.homepage = "https://rubygems.org/profiles/Andrey78"
10
+ s.license = "MIT"
11
+ s.metadata = { "source_code_uri" => "https://github.com/Andrey78/mega-clean-box" }
12
+ end
@@ -0,0 +1,201 @@
1
+ # CHANGELOG
2
+
3
+ ## main (unreleased)
4
+
5
+ # 4.3.0
6
+
7
+ * [#342](https://github.com/rails/web-console/pull/342) Always permit IPv4-mapped IPv6 loopback addresses ([@zunda]).
8
+ * Fixed Rails 8.2.0.alpha support
9
+ * Drop Rails 7.2 support
10
+ * Drop Ruby 3.1 support
11
+
12
+ # 4.2.1
13
+
14
+ * Support to Rails 7.1
15
+ * Support to Rack 3.0
16
+
17
+ ## 4.2.0
18
+
19
+ * [#308](https://github.com/rails/web-console/pull/308) Fix web-console inline templates rendering ([@voxik])
20
+ * [#306](https://github.com/rails/web-console/pull/306) Support Ruby 3.0 and above ([@ryanwood])
21
+
22
+ ## 4.1.0
23
+
24
+ * [#304](https://github.com/rails/web-console/pull/304) Add support for Rails 6.1 ([@stephannv])
25
+ * [#298](https://github.com/rails/web-console/pull/298) Prevent deprecation warnings by removing template formats ([@mikelkew])
26
+ * [#297](https://github.com/rails/web-console/pull/297) Use MutationObserver instead of Mutation Events ([@mikelkew])
27
+ * [#296](https://github.com/rails/web-console/pull/296) Add CSP nonce to injected scripts and styles ([@mikelkew])
28
+
29
+ ## 4.0.4
30
+
31
+ * [fb483743](https://github.com/rails/web-console/commit/fb483743a6a2a4168cdc0b2e03f48fc393991b73) Fix a crash on webrick with Rack 2.2.3 ([@gsamokovarov])
32
+
33
+ ## 4.0.3
34
+
35
+ * [#291](https://github.com/rails/web-console/pull/291) Deprecate config.web_console.whitelisted_ips ([@JuanitoFatas])
36
+ * [#290](https://github.com/rails/web-console/pull/290) Fix Content-Length for rack >= 2.1.0 ([@p8])
37
+
38
+ ## 4.0.2
39
+
40
+ * [#285](https://github.com/rails/web-console/pull/285) Increase timeout on paste ([@celvro])
41
+
42
+ ## 4.0.1
43
+
44
+ * [#279](https://github.com/rails/web-console/pull/279) Fix initial config.web_console.permissions value ([@patorash])
45
+
46
+ ## 4.0.0
47
+
48
+ * [61ce65b5](https://github.com/rails/web-console/commit/61ce65b599f56809de1bd8da6590a80acbd92017) Move to config.web_console.permissions ([@gsamokovarov])
49
+ * [96127ac1](https://github.com/rails/web-console/commit/96127aac143e1e653fffdc4bb65e1ce0b5ff342d) Introduce Binding#console as an alternative interface ([@gsamokovarov])
50
+ * [d4591ca5](https://github.com/rails/web-console/commit/d4591ca5396ed15a08818f3da11134852a485b27) Introduce Rails 6 support ([@gsamokovarov])
51
+ * [f97d8a88](https://github.com/rails/web-console/commit/f97d8a889a38366485e5c5e8985995c19bf61d13) Introduce Ruby 2.6 support ([@gsamokovarov])
52
+ * [d6deacd9](https://github.com/rails/web-console/commit/d6deacd9d5fcaabf3e3051d6985b53f924f86956) Drop Rails 5 support ([@gsamokovarov])
53
+ * [90fda878](https://github.com/rails/web-console/commit/90fda8789d402f05647c18f8cdf8e5c3d01692dd) Drop Ruby 2.4 support ([@gsamokovarov])
54
+ * [#265](https://github.com/rails/web-console/pull/265) Add support for nested exceptions ([@yuki24])
55
+
56
+ ## 3.7.0
57
+
58
+ * [#263](https://github.com/rails/web-console/pull/263) Show binding changes ([@causztic])
59
+ * [#258](https://github.com/rails/web-console/pull/258) Support Ctrl-A, Ctrl-W and Ctrl-U ([@gsamokovarov])
60
+ * [#257](https://github.com/rails/web-console/pull/257) Always try to keep the console underneath the website content ([@gsamokovarov])
61
+
62
+ ## 3.6.2
63
+
64
+ * [#255](https://github.com/rails/web-console/pull/255) Fix the truncated HTML body, because of wrong Content-Length header ([@timomeh])
65
+
66
+ ## 3.6.1
67
+
68
+ * [#252](https://github.com/rails/web-console/pull/252) Fix improper injection in Rack bodies like ActionDispatch::Response::RackBody ([@gsamokovarov])
69
+
70
+ ## 3.6.0
71
+
72
+ * [#254](https://github.com/rails/web-console/pull/254) Rescue ActionDispatch::RemoteIp::IpSpoofAttackError ([@wjordan])
73
+ * [#250](https://github.com/rails/web-console/pull/250) Close original body to comply with Rack SPEC ([@wagenet])
74
+ * [#249](https://github.com/rails/web-console/pull/249) Update for frozen-string-literal friendliness ([@pat])
75
+ * [#248](https://github.com/rails/web-console/pull/248) Fix copy on Safari ([@ybart])
76
+ * [#246](https://github.com/rails/web-console/pull/246) International keyboard special character input fixes ([@fl0l0u])
77
+ * [#244](https://github.com/rails/web-console/pull/244) Let WebConsole.logger respect Rails.logger ([@gsamokovarov])
78
+
79
+ ## 3.5.1
80
+
81
+ * [#239](https://github.com/rails/web-console/pull/239) Fix the ActionDispatch::DebugExceptions integration ([@gsamokovarov])
82
+
83
+ ## 3.5.0
84
+
85
+ * [#237](https://github.com/rails/web-console/pull/237) Bindex integration for JRuby 9k support ([@gsamokovarov])
86
+ * [#236](https://github.com/rails/web-console/pull/236) Remove unused Active Support lazy load hook ([@betesh])
87
+ * [#230](https://github.com/rails/web-console/pull/230) Handle invalid remote addresses ([@akirakoyasu])
88
+
89
+ ## 3.4.0
90
+
91
+ * [#205](https://github.com/rails/web-console/pull/205) Introduce autocompletion ([@sh19910711])
92
+
93
+ ## 3.3.1
94
+
95
+ Drop support for Rails `4.2.0`.
96
+
97
+ ## 3.3.0
98
+
99
+ * [#203](https://github.com/rails/web-console/pull/203) Map bindings to traces based on the trace __FILE__ and __LINE__ ([@gsamokovarov])
100
+
101
+ ## 3.2.1
102
+
103
+ * [#202](https://github.com/rails/web-console/pull/202) Use first binding when there is no application binding ([@sh19910711])
104
+
105
+ ## 3.2.0
106
+
107
+ * [#198](https://github.com/rails/web-console/pull/198) Pick the first application trace binding on errors ([@sh19910711])
108
+ * [#189](https://github.com/rails/web-console/pull/189) Silence ActionView rendering information ([@gsamokovarov])
109
+
110
+ ## 3.1.1
111
+
112
+ * [#185](https://github.com/rails/web-console/pull/185) Fix `rails console` startup ([@gsamokovarov])
113
+
114
+ ## 3.1.0
115
+
116
+ * [#182](https://github.com/rails/web-console/pull/182) Let `#console` live in `Kernel` ([@schneems])
117
+ * [#181](https://github.com/rails/web-console/pull/181) Log internal Web Console errors ([@gsamokovarov])
118
+ * [#180](https://github.com/rails/web-console/pull/180) Autoload Web Console constants for faster Rails boot time ([@herminiotorres])
119
+
120
+ ## 3.0.0
121
+
122
+ * [#173](https://github.com/rails/web-console/pull/173) Revert "Change config.development_only default until 4.2.4 is released" ([@gsamokovarov])
123
+ * [#171](https://github.com/rails/web-console/pull/171) Fixed blocked IP logging ([@gsamokovarov])
124
+ * [#162](https://github.com/rails/web-console/pull/162) Render the console inside the body tag ([@gsamokovarov])
125
+ * [#165](https://github.com/rails/web-console/pull/165) Revamped integrations for CRuby and Rubinius ([@gsamokovarov])
126
+
127
+ ## 2.3.0
128
+
129
+ This is mainly a Rails 5 compatibility release. If you have the chance, please
130
+ go to 3.1.0 instead.
131
+
132
+ * [#181](https://github.com/rails/web-console/pull/181) Log internal Web Console errors ([@schneems])
133
+ * [#150](https://github.com/rails/web-console/pull/150) Revert #150. ([@gsamokovarov])
134
+
135
+ ## 2.2.1
136
+
137
+ * [#150](https://github.com/rails/web-console/pull/150) Change config.development_only default until 4.2.4 is released ([@gsamokovarov])
138
+
139
+ ## 2.2.0
140
+
141
+ * [#140](https://github.com/rails/web-console/pull/140) Add the ability to close the console on each page ([@sh19910711])
142
+ * [#135](https://github.com/rails/web-console/pull/135) Run the console only in development mode and raise warning in tests ([@frenesim])
143
+ * [#134](https://github.com/rails/web-conscle/pull/134) Force development only web console by default ([@gsamokovarov])
144
+ * [#123](https://github.com/rails/web-console/pull/123) Replace deprecated `alias_method_chain` with `alias_method` ([@jonatack])
145
+
146
+ ## 2.1.3
147
+
148
+ * Fix remote code execution vulnerability in Web Console. CVE-2015-3224.
149
+
150
+ ## 2.1.2
151
+
152
+ * [#115](https://github.com/rails/web-console/pull/115) Show proper binding when raising an error in a template ([@gsamokovarov])
153
+ * [#114](https://github.com/rails/web-console/pull/114) Fix templates non rendering, because of missing template suffix ([@gsamokovarov])
154
+
155
+ ## 2.1.1
156
+
157
+ * [#112](https://github.com/rails/web-console/pull/112) Always allow application/x-www-form-urlencoded content type ([@gsamokovarov])
158
+
159
+ ## 2.1.0
160
+
161
+ * [#109](https://github.com/rails/web-console/pull/109) Revamp unavailable session response message ([@gsamokovarov])
162
+ * [#107](https://github.com/rails/web-console/pull/107) Fix pasting regression for all browsers ([@parterburn])
163
+ * [#105](https://github.com/rails/web-console/pull/105) Lock scroll bottom on console window resize ([@noahpatterson])
164
+ * [#104](https://github.com/rails/web-console/pull/104) Always whitelist localhost and inform users why no console is displayed ([@gsamokovarov])
165
+ * [#100](https://github.com/rails/web-console/pull/100) Accept text/plain as acceptable content type for Puma ([@gsamokovarov])
166
+ * [#98](https://github.com/rails/web-console/pull/98) Add arbitrary big z-index to the console ([@bglbruno])
167
+ * [#88](https://github.com/rails/web-console/pull/88) Spelling fixes ([@jeffnv])
168
+ * [#86](https://github.com/rails/web-console/pull/86) Disable autofocus when initializing the console ([@ryandao])
169
+ * [#84](https://github.com/rails/web-console/pull/84) Allow Rails 5 as dependency in gemspec ([@jonatack])
170
+ * [#69](https://github.com/rails/web-console/pull/69) Introduce middleware for request dispatch and console rendering ([@gsamokovarov])
171
+
172
+ [@stephannv]: https://github.com/stephannv
173
+ [@mikelkew]: https://github.com/mikelkew
174
+ [@jonatack]: https://github.com/jonatack
175
+ [@ryandao]: https://github.com/ryandao
176
+ [@jeffnv]: https://github.com/jeffnv
177
+ [@gsamokovarov]: https://github.com/gsamokovarov
178
+ [@bglbruno]: https://github.com/bglbruno
179
+ [@noahpatterson]: https://github.com/noahpatterson
180
+ [@parterburn]: https://github.com/parterburn
181
+ [@sh19910711]: https://github.com/sh19910711
182
+ [@frenesim]: https://github.com/frenesim
183
+ [@herminiotorres]: https://github.com/herminiotorres
184
+ [@schneems]: https://github.com/schneems
185
+ [@betesh]: https://github.com/betesh
186
+ [@akirakoyasu]: https://github.com/akirakoyasu
187
+ [@wagenet]: https://github.com/wagenet
188
+ [@wjordan]: https://github.com/wjordan
189
+ [@pat]: https://github.com/pat
190
+ [@ybart]: https://github.com/ybart
191
+ [@fl0l0u]: https://github.com/fl0l0u
192
+ [@timomeh]: https://github.com/timomeh
193
+ [@causztic]: https://github.com/causztic
194
+ [@yuki24]: https://github.com/yuki24
195
+ [@patorash]: https://github.com/patorash
196
+ [@celvro]: https://github.com/celvro
197
+ [@JuanitoFatas]: https://github.com/JuanitoFatas
198
+ [@p8]: https://github.com/p8
199
+ [@voxik]: https://github.com/voxik
200
+ [@ryanwood]: https://github.com/ryanwood
201
+ [@zunda]: https://github.com/zunda
@@ -0,0 +1,20 @@
1
+ Copyright 2014-2016 Hailey Somerville, Genadi Samokovarov, Guillermo Iguaran and Ryan Dao
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,193 @@
1
+ <p align=right>
2
+ <strong>Current version: 4.2.1</strong> | Documentation for:
3
+ <a href=https://github.com/rails/web-console/tree/v1.0.4>v1.0.4</a>
4
+ <a href=https://github.com/rails/web-console/tree/v2.2.1>v2.2.1</a>
5
+ <a href=https://github.com/rails/web-console/tree/v3.7.0>v3.7.0</a>
6
+ </p>
7
+
8
+ # Web Console [![CI](https://github.com/rails/web-console/actions/workflows/ci.yml/badge.svg)](https://github.com/rails/web-console/actions/workflows/ci.yml)
9
+
10
+ _Web Console_ is a debugging tool for your Ruby on Rails applications.
11
+
12
+ - [Installation](#installation)
13
+ - [Configuration](#configuration)
14
+ - [Usage](#usage)
15
+ - [FAQ](#faq)
16
+ - [Credits](#credits)
17
+
18
+ ## Installation
19
+
20
+ Add the following to your `Gemfile`:
21
+
22
+ ```ruby
23
+ group :development do
24
+ gem 'web-console'
25
+ end
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ The web console allows you to create an interactive Ruby session in your
31
+ browser. Those sessions are launched automatically in case of an error and can
32
+ also be launched manually in any page.
33
+
34
+ For example, calling `console` in a view will display a console in the current
35
+ page in the context of the view binding.
36
+
37
+ ```html
38
+ <% console %>
39
+ ```
40
+
41
+ Calling `console` in a controller will result in a console in the context of
42
+ the controller action:
43
+
44
+ ```ruby
45
+ class PostsController < ApplicationController
46
+ def new
47
+ console
48
+ @post = Post.new
49
+ end
50
+ end
51
+ ```
52
+
53
+ The method is defined in `Kernel` and you can invoke it any application code.
54
+
55
+ Only one `console` invocation per request is allowed. If you happen to
56
+ have multiple ones, `WebConsole::DoubleRenderError` will be raised.
57
+
58
+ ## Configuration
59
+
60
+ _Web Console_ allows you to execute arbitrary code on the server. Therefore, be
61
+ very careful who you give access to.
62
+
63
+ ### config.web_console.permissions
64
+
65
+ By default, only requests coming from IPv4 and IPv6 localhosts are allowed.
66
+
67
+ `config.web_console.permissions` lets you control which IP's have access to
68
+ the console.
69
+
70
+ You can allow single IP's or whole networks. Say you want to share your
71
+ console with `192.168.0.100`:
72
+
73
+ ```ruby
74
+ class Application < Rails::Application
75
+ config.web_console.permissions = '192.168.0.100'
76
+ end
77
+ ```
78
+
79
+ If you want to allow the whole private network:
80
+
81
+ ```ruby
82
+ Rails.application.configure do
83
+ config.web_console.permissions = '192.168.0.0/16'
84
+ end
85
+ ```
86
+
87
+ Take a note that IPv4 and IPv6 localhosts are always allowed. This wasn't the
88
+ case in 2.0.
89
+
90
+ ### config.web_console.whiny_requests
91
+
92
+ When a console cannot be shown for a given IP address or content type,
93
+ messages such as the following is printed in the server logs:
94
+
95
+ > Cannot render console from 192.168.1.133! Allowed networks:
96
+ > 127.0.0.0/127.255.255.255, ::1
97
+
98
+ If you don't want to see this message anymore, set this option to `false`:
99
+
100
+ ```ruby
101
+ Rails.application.configure do
102
+ config.web_console.whiny_requests = false
103
+ end
104
+ ```
105
+
106
+ ### config.web_console.template_paths
107
+
108
+ If you want to style the console yourself, then you can place `style.css` at a
109
+ directory pointed by `config.web_console.template_paths`:
110
+
111
+ ```ruby
112
+ Rails.application.configure do
113
+ config.web_console.template_paths = 'app/views/web_console'
114
+ end
115
+ ```
116
+
117
+ You may want to check the [templates] folder at the source tree for the files you
118
+ may override.
119
+
120
+ ### config.web_console.mount_point
121
+
122
+ Usually the middleware of _Web Console_ is mounted at `/__web_console`.
123
+ If there is a need to change the path, then you can specify it by
124
+ `config.web_console.mount_point`:
125
+
126
+ ```ruby
127
+ Rails.application.configure do
128
+ config.web_console.mount_point = '/path/to/web_console'
129
+ end
130
+ ```
131
+
132
+ ## FAQ
133
+
134
+ ### Where did /console go?
135
+
136
+ The remote terminal emulator was extracted in its own gem which is no longer
137
+ bundled with _Web Console_.
138
+
139
+ If you miss this feature, check out [rvt].
140
+
141
+ ### Why do I constantly get unavailable session errors?
142
+
143
+ All of _Web Console_ sessions are stored in memory. If you happen to run on a
144
+ multi-process server (like Unicorn), you may encounter unavailable session errors
145
+ while the server is still running. This is because a request may hit a
146
+ different worker (process) that doesn't have the desired session in memory.
147
+ To avoid that, if you use such servers in development, configure them so they
148
+ serve requests only out of one process.
149
+
150
+ #### Passenger
151
+
152
+ Enable sticky sessions for [Passenger on Nginx] or [Passenger on Apache] to
153
+ prevent unavailable session errors.
154
+
155
+ ### How to inspect local and instance variables?
156
+
157
+ The interactive console executes Ruby code. Invoking `instance_variables` and
158
+ `local_variables` will give you what you want.
159
+
160
+ ### Why does the console only appear on error pages but not when I call it?
161
+
162
+ This can be happening if you are using `Rack::Deflater`. Be sure that
163
+ `WebConsole::Middleware` is used after `Rack::Deflater`. The easiest way to do
164
+ this is to insert `Rack::Deflater` as early as possible
165
+
166
+ ```ruby
167
+ Rails.application.configure do
168
+ config.middleware.insert(0, Rack::Deflater)
169
+ end
170
+ ```
171
+
172
+ ### Why am I getting an undefined method `web_console`?
173
+
174
+ Make sure your configuration lives in `config/environments/development.rb`.
175
+
176
+ ## Credits
177
+
178
+ * Shoutout to [Hailey Somerville] for [better_errors].
179
+ * Kudos to [John Mair] for [binding_of_caller] and [debug_inspector].
180
+ * Thanks to [Charles Oliver Nutter] for all the _JRuby_ feedback.
181
+ * Hugs and kisses to all of our [contributors]!
182
+
183
+ [better_errors]: https://github.com/BetterErrors/better_errors
184
+ [debug_inspector]: https://github.com/banister/debug_inspector
185
+ [binding_of_caller]: https://github.com/banister/binding_of_caller
186
+ [Hailey Somerville]: https://github.com/haileys
187
+ [John Mair]: https://github.com/banister
188
+ [Charles Oliver Nutter]: https://github.com/headius
189
+ [templates]: https://github.com/rails/web-console/tree/main/lib/web_console/templates
190
+ [rvt]: https://github.com/gsamokovarov/rvt
191
+ [contributors]: https://github.com/rails/web-console/graphs/contributors
192
+ [Passenger on Nginx]: https://www.phusionpassenger.com/library/config/nginx/reference/#passengerstickysessions
193
+ [Passenger on Apache]: https://www.phusionpassenger.com/library/config/apache/reference/#passengerstickysessions
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "bundler/setup"
5
+ rescue LoadError
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
7
+ end
8
+
9
+ require "socket"
10
+ require "rake/testtask"
11
+ require "tmpdir"
12
+ require "securerandom"
13
+ require "json"
14
+ require "web_console/testing/erb_precompiler"
15
+
16
+ EXPANDED_CWD = File.expand_path(File.dirname(__FILE__))
17
+
18
+ Rake::TestTask.new(:test) do |t|
19
+ t.libs << "lib"
20
+ t.libs << "test"
21
+ t.pattern = "test/**/*_test.rb"
22
+ t.verbose = false
23
+ end
24
+
25
+ Dir["lib/web_console/tasks/**/*.rake"].each { |task| load task }
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
29
+ task default: :test
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "web_console"
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WebConsole
4
+ # A context lets you get object names related to the current session binding.
5
+ class Context
6
+ def initialize(binding)
7
+ @binding = binding
8
+ end
9
+
10
+ # Extracts entire objects which can be called by the current session unless
11
+ # the inputs is present.
12
+ #
13
+ # Otherwise, it extracts methods and constants of the object specified by
14
+ # the input.
15
+ def extract(input = nil)
16
+ input.present? ? local(input) : global
17
+ end
18
+
19
+ private
20
+
21
+ GLOBAL_OBJECTS = [
22
+ "instance_variables",
23
+ "local_variables",
24
+ "methods",
25
+ "class_variables",
26
+ "Object.constants",
27
+ "global_variables"
28
+ ]
29
+
30
+ def global
31
+ GLOBAL_OBJECTS.map { |cmd| eval(cmd) }
32
+ end
33
+
34
+ def local(input)
35
+ [
36
+ eval("#{input}.methods").map { |m| "#{input}.#{m}" },
37
+ eval("#{input}.constants").map { |c| "#{input}::#{c}" },
38
+ ]
39
+ end
40
+
41
+ def eval(cmd)
42
+ @binding.eval(cmd) rescue []
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WebConsole
4
+ # The base class for every Web Console related error.
5
+ Error = Class.new(StandardError)
6
+
7
+ # Raised when there is an attempt to render a console more than once.
8
+ DoubleRenderError = Class.new(Error)
9
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WebConsole
4
+ # Simple Ruby code evaluator.
5
+ #
6
+ # This class wraps a +Binding+ object and evaluates code inside of it. The
7
+ # difference of a regular +Binding+ eval is that +Evaluator+ will always
8
+ # return a string and will format exception output.
9
+ class Evaluator
10
+ # Cleanses exceptions raised inside #eval.
11
+ cattr_reader :cleaner, default: begin
12
+ cleaner = ActiveSupport::BacktraceCleaner.new
13
+ cleaner.add_silencer { |line| line.start_with?(File.expand_path("..", __FILE__)) }
14
+ cleaner
15
+ end
16
+
17
+ def initialize(binding = TOPLEVEL_BINDING)
18
+ @binding = binding
19
+ end
20
+
21
+ def eval(input)
22
+ # Binding#source_location is available since Ruby 2.6.
23
+ if @binding.respond_to? :source_location
24
+ "=> #{@binding.eval(input, *@binding.source_location).inspect}\n"
25
+ else
26
+ "=> #{@binding.eval(input).inspect}\n"
27
+ end
28
+ rescue Exception => exc
29
+ format_exception(exc)
30
+ end
31
+
32
+ private
33
+
34
+ def format_exception(exc)
35
+ backtrace = cleaner.clean(Array(exc.backtrace) - caller)
36
+
37
+ format = "#{exc.class.name}: #{exc}\n".dup
38
+ format << backtrace.map { |trace| "\tfrom #{trace}\n" }.join
39
+ format
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WebConsole
4
+ class ExceptionMapper
5
+ attr_reader :exc
6
+
7
+ def self.follow(exc)
8
+ mappers = [new(exc)]
9
+
10
+ while cause = (cause || exc).cause
11
+ mappers << new(cause)
12
+ end
13
+
14
+ mappers
15
+ end
16
+
17
+ def self.find_binding(mappers, exception_object_id)
18
+ mappers.detect do |exception_mapper|
19
+ exception_mapper.exc.object_id == exception_object_id.to_i
20
+ end || mappers.first
21
+ end
22
+
23
+ def initialize(exception)
24
+ @backtrace = exception.backtrace
25
+ @bindings = exception.bindings
26
+ @exc = exception
27
+ end
28
+
29
+ def first
30
+ guess_the_first_application_binding || @bindings.first
31
+ end
32
+
33
+ def [](index)
34
+ guess_binding_for_index(index) || @bindings[index]
35
+ end
36
+
37
+ private
38
+
39
+ def guess_binding_for_index(index)
40
+ file, line = @backtrace[index].to_s.split(":")
41
+ line = line.to_i
42
+
43
+ @bindings.find do |binding|
44
+ source_location = SourceLocation.new(binding)
45
+ source_location.path == file && source_location.lineno == line
46
+ end
47
+ end
48
+
49
+ def guess_the_first_application_binding
50
+ @bindings.find do |binding|
51
+ source_location = SourceLocation.new(binding)
52
+ source_location.path.to_s.start_with?(Rails.root.to_s)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kernel
4
+ module_function
5
+
6
+ # Instructs Web Console to render a console in the specified binding.
7
+ #
8
+ # If +binding+ isn't explicitly given it will default to the binding of the
9
+ # previous frame. E.g. the one that invoked +console+.
10
+ #
11
+ # Raises +DoubleRenderError+ if a more than one +console+ invocation per
12
+ # request is detected.
13
+ def console(binding = Bindex.current_bindings.second)
14
+ raise WebConsole::DoubleRenderError if Thread.current[:__web_console_binding]
15
+
16
+ Thread.current[:__web_console_binding] = binding
17
+
18
+ # Make sure nothing is rendered from the view helper. Otherwise
19
+ # you're gonna see unexpected #<Binding:0x007fee4302b078> in the
20
+ # templates.
21
+ nil
22
+ end
23
+ end
24
+
25
+ class Binding
26
+ # Instructs Web Console to render a console in the current binding, without
27
+ # the need to unroll the stack.
28
+ #
29
+ # Raises +DoubleRenderError+ if a more than one +console+ invocation per
30
+ # request is detected.
31
+ def console
32
+ Kernel.console(self)
33
+ end
34
+ end