dial 0.2.3 → 0.2.4
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +12 -3
- data/lib/dial/configuration.rb +3 -2
- data/lib/dial/constants.rb +2 -0
- data/lib/dial/middleware/panel.rb +14 -3
- data/lib/dial/middleware/ruby_stat.rb +1 -1
- data/lib/dial/middleware.rb +7 -5
- data/lib/dial/railtie.rb +0 -1
- data/lib/dial/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c21506e3c567f79104e394c2ab2fc1c29d433ef9e9e27f201d8fe3e6bdc2227f
|
4
|
+
data.tar.gz: 5a8a65aa3fcdd52d59508ebac6bb12bfa156d6f577793f7c05ac8eb14d5409b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c20d37444e2d186490ea5e75d30c2a6940d56adbff21c91d01a448d96b4b7b6baa0ead5da5305a1398dcd8e916f5a9dab60c2d0d101404a1377a998fe2d2d91c
|
7
|
+
data.tar.gz: 525eef47d8136c0c34ddc0c8460637370e87ea13d43c8d83e1c3b4c9dc992b192414f570a0258a9ffd16206a235611a5450982c3a9cf474f12552c16ef646613
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -39,12 +39,21 @@ mount Dial::Engine, at: "/" if Rails.env.development?
|
|
39
39
|
# config/initializers/dial.rb
|
40
40
|
|
41
41
|
Dial.configure do |config|
|
42
|
-
config.vernier_interval = 100
|
43
|
-
config.vernier_allocation_interval = 10_000
|
44
|
-
config.prosopite_ignore_queries += [/pg_sleep/i]
|
42
|
+
config.vernier_interval = 100
|
43
|
+
config.vernier_allocation_interval = 10_000
|
44
|
+
config.prosopite_ignore_queries += [/pg_sleep/i]
|
45
45
|
end
|
46
46
|
```
|
47
47
|
|
48
|
+
### Options
|
49
|
+
|
50
|
+
Option | Description | Default
|
51
|
+
- | - | -
|
52
|
+
`vernier_interval` | Sets the `interval` option for vernier. | `200`
|
53
|
+
`vernier_allocation_interval` | Sets the `allocation_interval` option for vernier. | `20_000`
|
54
|
+
`prosopite_ignore_queries` | Sets the `ignore_queries` option for prosopite. | `[/schema_migrations/i]`
|
55
|
+
`content_security_policy_nonce` | Sets the content security policy nonce to use when inserting Dial's script. Can be a string, or a Proc which receives `env` and response `headers` as arguments and returns the nonce. | Rails generated nonce or `nil`
|
56
|
+
|
48
57
|
## Development
|
49
58
|
|
50
59
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake test` to run the
|
data/lib/dial/configuration.rb
CHANGED
@@ -15,14 +15,15 @@ module Dial
|
|
15
15
|
vernier_interval: VERNIER_INTERVAL,
|
16
16
|
vernier_allocation_interval: VERNIER_ALLOCATION_INTERVAL,
|
17
17
|
prosopite_ignore_queries: PROSOPITE_IGNORE_QUERIES,
|
18
|
+
content_security_policy_nonce: -> (env, _headers) { env[NONCE] || "" },
|
18
19
|
}
|
19
20
|
|
20
21
|
@options.keys.each do |key|
|
21
|
-
define_singleton_method
|
22
|
+
define_singleton_method key do
|
22
23
|
@options[key]
|
23
24
|
end
|
24
25
|
|
25
|
-
define_singleton_method
|
26
|
+
define_singleton_method "#{key}=" do |value|
|
26
27
|
@options[key] = value
|
27
28
|
end
|
28
29
|
end
|
data/lib/dial/constants.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rack"
|
4
|
+
require "action_dispatch"
|
4
5
|
|
5
6
|
require_relative "version"
|
6
7
|
|
@@ -10,6 +11,7 @@ module Dial
|
|
10
11
|
HTTP_ACCEPT = "HTTP_ACCEPT"
|
11
12
|
CONTENT_TYPE = ::Rack::CONTENT_TYPE
|
12
13
|
CONTENT_LENGTH = ::Rack::CONTENT_LENGTH
|
14
|
+
NONCE = ::ActionDispatch::ContentSecurityPolicy::Request::NONCE
|
13
15
|
REQUEST_TIMING = "dial_request_timing"
|
14
16
|
|
15
17
|
FILE_STALE_SECONDS = 60 * 60
|
@@ -5,7 +5,7 @@ require "uri"
|
|
5
5
|
module Dial
|
6
6
|
class Panel
|
7
7
|
class << self
|
8
|
-
def html env, profile_out_filename, query_logs, ruby_vm_stat, gc_stat, gc_stat_heap, server_timing
|
8
|
+
def html env, headers, profile_out_filename, query_logs, ruby_vm_stat, gc_stat, gc_stat_heap, server_timing
|
9
9
|
<<~HTML
|
10
10
|
<style>#{style}</style>
|
11
11
|
|
@@ -69,7 +69,9 @@ module Dial
|
|
69
69
|
</div>
|
70
70
|
</div>
|
71
71
|
|
72
|
-
<script
|
72
|
+
<script nonce="#{configured_nonce env, headers}">
|
73
|
+
#{script}
|
74
|
+
</script>
|
73
75
|
HTML
|
74
76
|
end
|
75
77
|
|
@@ -171,7 +173,7 @@ module Dial
|
|
171
173
|
end
|
172
174
|
|
173
175
|
def formatted_rails_route_info env
|
174
|
-
|
176
|
+
begin
|
175
177
|
::Rails.application.routes.recognize_path env[::Rack::PATH_INFO], method: env[::Rack::REQUEST_METHOD]
|
176
178
|
rescue ::ActionController::RoutingError
|
177
179
|
{}
|
@@ -253,6 +255,15 @@ module Dial
|
|
253
255
|
HTML
|
254
256
|
end.join
|
255
257
|
end
|
258
|
+
|
259
|
+
def configured_nonce env, headers
|
260
|
+
config_nonce = Dial._configuration.content_security_policy_nonce
|
261
|
+
if config_nonce.instance_of? Proc
|
262
|
+
config_nonce.call env, headers
|
263
|
+
else
|
264
|
+
config_nonce
|
265
|
+
end
|
266
|
+
end
|
256
267
|
end
|
257
268
|
end
|
258
269
|
end
|
data/lib/dial/middleware.rb
CHANGED
@@ -51,10 +51,12 @@ module Dial
|
|
51
51
|
body = String.new.tap do |str|
|
52
52
|
rack_body.each { |chunk| str << chunk }
|
53
53
|
rack_body.close if rack_body.respond_to? :close
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
|
55
|
+
str.sub! "</body>", <<~HTML
|
56
|
+
#{Panel.html env, headers, profile_out_filename, query_logs, ruby_vm_stat, gc_stat, gc_stat_heap, server_timing}
|
57
|
+
</body>
|
58
|
+
HTML
|
59
|
+
end
|
58
60
|
|
59
61
|
headers[CONTENT_LENGTH] = body.bytesize.to_s
|
60
62
|
|
@@ -86,7 +88,7 @@ module Dial
|
|
86
88
|
|
87
89
|
def clear_query_logs!
|
88
90
|
[].tap do |query_logs|
|
89
|
-
File.open
|
91
|
+
File.open "#{query_log_dir_pathname}/#{PROSOPITE_LOG_FILENAME}", "r+" do |file|
|
90
92
|
entry = section = count = nil
|
91
93
|
file.each_line do |line|
|
92
94
|
entry, section, count = process_query_log_line line, entry, section, count
|
data/lib/dial/railtie.rb
CHANGED
data/lib/dial/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Young
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-03-03 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: railties
|