pgbus 0.9.6 → 0.9.7
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a8282d1403685f1543b1df1394cc6199e9f9182f697db151c4d6cd22f20018b9
|
|
4
|
+
data.tar.gz: 83ff9056787cd40b38a8724a55cb2e23b670f446a37f9612c38a561ea1120c37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4095c65e96196ba5cb87d4e1df86c4066d5534610ff210c919f4b1f4d26d97005025add8d4ac97a8f153a2a340f0fa20cf66fdca79f8695bd30b537a899eb404
|
|
7
|
+
data.tar.gz: cba33628e71e9670d991abaf75c34ac53152e3a721734a13dca8bed262bcc2bda931f0721767395829c3f4e415245564d11f7e927608699f9bba76cb29485089
|
|
@@ -109,11 +109,12 @@ module Pgbus
|
|
|
109
109
|
def pgbus_parse_message(message)
|
|
110
110
|
return {} unless message
|
|
111
111
|
|
|
112
|
-
case message
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
parsed = case message
|
|
113
|
+
when Hash then message
|
|
114
|
+
when String then JSON.parse(message)
|
|
115
|
+
else {}
|
|
116
|
+
end
|
|
117
|
+
Pgbus::Web::PayloadFilter.filter(parsed)
|
|
117
118
|
rescue JSON::ParserError
|
|
118
119
|
{}
|
|
119
120
|
end
|
|
@@ -121,7 +122,8 @@ module Pgbus
|
|
|
121
122
|
def pgbus_json_preview(json_string, max_length: 120)
|
|
122
123
|
return "—" unless json_string
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
filtered = Pgbus::Web::PayloadFilter.filter_json(json_string)
|
|
126
|
+
text = filtered.is_a?(String) ? filtered : JSON.generate(filtered)
|
|
125
127
|
text.length > max_length ? "#{text[0...max_length]}..." : text
|
|
126
128
|
end
|
|
127
129
|
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
<div class="rounded-lg bg-white dark:bg-gray-800 shadow ring-1 ring-gray-200 dark:ring-gray-700 p-6 mb-6">
|
|
42
42
|
<h2 class="text-sm font-medium text-gray-500 mb-2"><%= t("pgbus.jobs.show.payload") %></h2>
|
|
43
|
-
<pre class="text-xs text-gray-600 bg-gray-50 dark:bg-gray-900 rounded p-4 overflow-x-auto"><%= JSON.pretty_generate(
|
|
43
|
+
<pre class="text-xs text-gray-600 bg-gray-50 dark:bg-gray-900 rounded p-4 overflow-x-auto"><%= JSON.pretty_generate(pgbus_parse_message(@job["payload"])) %></pre>
|
|
44
44
|
</div>
|
|
45
45
|
|
|
46
46
|
<div class="flex space-x-2">
|
data/lib/pgbus/configuration.rb
CHANGED
|
@@ -109,7 +109,8 @@ module Pgbus
|
|
|
109
109
|
# Web dashboard
|
|
110
110
|
attr_accessor :web_auth, :web_refresh_interval, :web_per_page, :web_live_updates, :web_data_source,
|
|
111
111
|
:insights_default_minutes, :base_controller_class, :return_to_app_url,
|
|
112
|
-
:metrics_enabled
|
|
112
|
+
:metrics_enabled,
|
|
113
|
+
:dashboard_filter_parameters, :dashboard_filter_sensitive
|
|
113
114
|
|
|
114
115
|
# Streams (turbo-rails replacement, SSE-based)
|
|
115
116
|
attr_accessor :streams_enabled, :streams_path, :streams_queue_prefix, :streams_signed_name_secret,
|
|
@@ -220,6 +221,8 @@ module Pgbus
|
|
|
220
221
|
@base_controller_class = "::ActionController::Base"
|
|
221
222
|
@return_to_app_url = nil
|
|
222
223
|
@metrics_enabled = true
|
|
224
|
+
@dashboard_filter_parameters = nil # nil = auto-detect from Rails, then fall back to defaults
|
|
225
|
+
@dashboard_filter_sensitive = true
|
|
223
226
|
|
|
224
227
|
@streams_enabled = true
|
|
225
228
|
@streams_path = nil
|
data/lib/pgbus/version.rb
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Pgbus
|
|
6
|
+
module Web
|
|
7
|
+
module PayloadFilter
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
DEFAULT_FILTER_PATTERNS = [
|
|
11
|
+
:password, :passphrase, :secret, :token, :authorization,
|
|
12
|
+
:api_key, :private_key, :access_key, :secret_key,
|
|
13
|
+
/(_|-)key$/
|
|
14
|
+
].freeze
|
|
15
|
+
|
|
16
|
+
FILTERED = "[FILTERED]"
|
|
17
|
+
|
|
18
|
+
def filter(value)
|
|
19
|
+
return value unless Pgbus.configuration.dashboard_filter_sensitive
|
|
20
|
+
|
|
21
|
+
case value
|
|
22
|
+
when Hash
|
|
23
|
+
parameter_filter.filter(value)
|
|
24
|
+
when Array
|
|
25
|
+
value.map { |element| filter(element) }
|
|
26
|
+
else
|
|
27
|
+
value
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def filter_json(value)
|
|
32
|
+
return value unless Pgbus.configuration.dashboard_filter_sensitive
|
|
33
|
+
|
|
34
|
+
case value
|
|
35
|
+
when nil then nil
|
|
36
|
+
when Hash, Array
|
|
37
|
+
JSON.generate(filter(value))
|
|
38
|
+
when String
|
|
39
|
+
parsed = JSON.parse(value)
|
|
40
|
+
JSON.generate(filter(parsed))
|
|
41
|
+
else
|
|
42
|
+
value
|
|
43
|
+
end
|
|
44
|
+
rescue JSON::ParserError
|
|
45
|
+
value
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def parameter_filter
|
|
49
|
+
patterns = Pgbus.configuration.dashboard_filter_parameters ||
|
|
50
|
+
rails_filter_parameters ||
|
|
51
|
+
DEFAULT_FILTER_PATTERNS
|
|
52
|
+
ActiveSupport::ParameterFilter.new(patterns)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def rails_filter_parameters
|
|
56
|
+
return unless defined?(Rails) &&
|
|
57
|
+
Rails.respond_to?(:application) &&
|
|
58
|
+
Rails.application.respond_to?(:config) &&
|
|
59
|
+
Rails.application.config.respond_to?(:filter_parameters)
|
|
60
|
+
|
|
61
|
+
params = Rails.application.config.filter_parameters
|
|
62
|
+
params if params.is_a?(Array) && params.any?
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private_class_method :parameter_filter, :rails_filter_parameters
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pgbus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mikael Henriksson
|
|
@@ -356,6 +356,7 @@ files:
|
|
|
356
356
|
- lib/pgbus/web/authentication.rb
|
|
357
357
|
- lib/pgbus/web/data_source.rb
|
|
358
358
|
- lib/pgbus/web/metrics_serializer.rb
|
|
359
|
+
- lib/pgbus/web/payload_filter.rb
|
|
359
360
|
- lib/pgbus/web/stream_app.rb
|
|
360
361
|
- lib/pgbus/web/streamer.rb
|
|
361
362
|
- lib/pgbus/web/streamer/connection.rb
|