sendproof-core 0.1.0.alpha.1 → 0.1.0.alpha.2
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/lib/sendproof/configuration.rb +31 -0
- data/lib/sendproof/data_store.rb +3 -0
- data/lib/sendproof/handler.rb +3 -1
- data/lib/sendproof/journeys/code_document.rb +305 -0
- data/lib/sendproof/journeys.rb +121 -0
- data/lib/sendproof/middleware.rb +7 -3
- data/lib/sendproof/mongo/engine.rb +121 -24
- data/lib/sendproof/mongo/held_session.rb +67 -0
- data/lib/sendproof/mongo/store.rb +1 -0
- data/lib/sendproof/mongo.rb +1 -0
- data/lib/sendproof/mongoid/store.rb +15 -5
- data/lib/sendproof/preview_request.rb +4 -1
- data/lib/sendproof/preview_sessions.rb +257 -0
- data/lib/sendproof/preview_transport.rb +86 -9
- data/lib/sendproof/protocol.rb +2 -2
- data/lib/sendproof/provider.rb +8 -0
- data/lib/sendproof/stores/tables.rb +213 -0
- data/lib/sendproof/transaction_control.rb +3 -2
- data/lib/sendproof/ui/api.js +2 -1
- data/lib/sendproof/ui/app.css +612 -1
- data/lib/sendproof/ui/app.js +89 -13
- data/lib/sendproof/ui/bar-fit.js +91 -0
- data/lib/sendproof/ui/commands.js +27 -4
- data/lib/sendproof/ui/dialog.css +125 -0
- data/lib/sendproof/ui/dialog.js +191 -0
- data/lib/sendproof/ui/fields/lookup-source.js +5 -2
- data/lib/sendproof/ui/fields/lookup.js +3 -2
- data/lib/sendproof/ui/i18n.js +13 -2
- data/lib/sendproof/ui/icons.js +18 -0
- data/lib/sendproof/ui/index.html +1 -0
- data/lib/sendproof/ui/journeys/compare.js +225 -0
- data/lib/sendproof/ui/journeys/expressions.js +89 -0
- data/lib/sendproof/ui/journeys/index.js +7 -0
- data/lib/sendproof/ui/journeys/run.js +152 -0
- data/lib/sendproof/ui/journeys/steps.js +163 -0
- data/lib/sendproof/ui/journeys-code.js +193 -0
- data/lib/sendproof/ui/journeys-dialog-model.js +172 -0
- data/lib/sendproof/ui/journeys-dialogs.js +301 -0
- data/lib/sendproof/ui/journeys-model.js +259 -0
- data/lib/sendproof/ui/journeys-runs.js +109 -0
- data/lib/sendproof/ui/journeys-session.js +135 -0
- data/lib/sendproof/ui/journeys-view.js +961 -0
- data/lib/sendproof/ui/journeys.js +962 -0
- data/lib/sendproof/ui/locales/ar-journeys.js +468 -0
- data/lib/sendproof/ui/locales/ar.js +2 -0
- data/lib/sendproof/ui/locales/cs-journeys.js +468 -0
- data/lib/sendproof/ui/locales/cs.js +2 -0
- data/lib/sendproof/ui/locales/da-journeys.js +465 -0
- data/lib/sendproof/ui/locales/da.js +2 -0
- data/lib/sendproof/ui/locales/de-journeys.js +465 -0
- data/lib/sendproof/ui/locales/de.js +2 -0
- data/lib/sendproof/ui/locales/el-journeys.js +465 -0
- data/lib/sendproof/ui/locales/el.js +2 -0
- data/lib/sendproof/ui/locales/en-journeys.js +467 -0
- data/lib/sendproof/ui/locales/en.js +2 -0
- data/lib/sendproof/ui/locales/es-journeys.js +467 -0
- data/lib/sendproof/ui/locales/es.js +2 -0
- data/lib/sendproof/ui/locales/fa-journeys.js +465 -0
- data/lib/sendproof/ui/locales/fa.js +2 -0
- data/lib/sendproof/ui/locales/fi-journeys.js +465 -0
- data/lib/sendproof/ui/locales/fi.js +2 -0
- data/lib/sendproof/ui/locales/fr-journeys.js +467 -0
- data/lib/sendproof/ui/locales/fr.js +2 -0
- data/lib/sendproof/ui/locales/he-journeys.js +468 -0
- data/lib/sendproof/ui/locales/he.js +2 -0
- data/lib/sendproof/ui/locales/hi-journeys.js +465 -0
- data/lib/sendproof/ui/locales/hi.js +2 -0
- data/lib/sendproof/ui/locales/id-journeys.js +466 -0
- data/lib/sendproof/ui/locales/id.js +2 -0
- data/lib/sendproof/ui/locales/it-journeys.js +467 -0
- data/lib/sendproof/ui/locales/it.js +2 -0
- data/lib/sendproof/ui/locales/ja-journeys.js +466 -0
- data/lib/sendproof/ui/locales/ja.js +2 -0
- data/lib/sendproof/ui/locales/ko-journeys.js +465 -0
- data/lib/sendproof/ui/locales/ko.js +2 -0
- data/lib/sendproof/ui/locales/nb-journeys.js +465 -0
- data/lib/sendproof/ui/locales/nb.js +2 -0
- data/lib/sendproof/ui/locales/nl-journeys.js +465 -0
- data/lib/sendproof/ui/locales/nl.js +2 -0
- data/lib/sendproof/ui/locales/pl-journeys.js +468 -0
- data/lib/sendproof/ui/locales/pl.js +2 -0
- data/lib/sendproof/ui/locales/pt-BR-journeys.js +467 -0
- data/lib/sendproof/ui/locales/pt-BR.js +2 -0
- data/lib/sendproof/ui/locales/pt-PT-journeys.js +467 -0
- data/lib/sendproof/ui/locales/pt-PT.js +2 -0
- data/lib/sendproof/ui/locales/ru-journeys.js +468 -0
- data/lib/sendproof/ui/locales/ru.js +2 -0
- data/lib/sendproof/ui/locales/sv-journeys.js +465 -0
- data/lib/sendproof/ui/locales/sv.js +2 -0
- data/lib/sendproof/ui/locales/th-journeys.js +466 -0
- data/lib/sendproof/ui/locales/th.js +2 -0
- data/lib/sendproof/ui/locales/tr-journeys.js +468 -0
- data/lib/sendproof/ui/locales/tr.js +2 -0
- data/lib/sendproof/ui/locales/uk-journeys.js +468 -0
- data/lib/sendproof/ui/locales/uk.js +2 -0
- data/lib/sendproof/ui/locales/vi-journeys.js +466 -0
- data/lib/sendproof/ui/locales/vi.js +2 -0
- data/lib/sendproof/ui/locales/zh-Hans-journeys.js +466 -0
- data/lib/sendproof/ui/locales/zh-Hans.js +2 -0
- data/lib/sendproof/ui/locales/zh-Hant-journeys.js +466 -0
- data/lib/sendproof/ui/locales/zh-Hant.js +2 -0
- data/lib/sendproof/ui/manifest.json +349 -104
- data/lib/sendproof/ui/markdown.js +27 -2
- data/lib/sendproof/ui/request-editor.js +7 -1
- data/lib/sendproof/ui/result-states.js +2 -2
- data/lib/sendproof/ui/results.js +41 -14
- data/lib/sendproof/ui/router.js +25 -1
- data/lib/sendproof/ui/seeded-menu.js +2 -1
- data/lib/sendproof/ui/shortcuts-sheet.js +3 -1
- data/lib/sendproof/ui/shortcuts.js +6 -0
- data/lib/sendproof/ui/sidebar.js +54 -5
- data/lib/sendproof/ui/signin.js +6 -3
- data/lib/sendproof/ui/styles.css +8 -2
- data/lib/sendproof/ui/toast.js +29 -0
- data/lib/sendproof/ui/vendor/arazzo-runtime-expression.js +136 -0
- data/lib/sendproof/ui/vendor/json-pointer.js +48 -0
- data/lib/sendproof/ui/vendor/jsonpath-rfc9535.js +15 -0
- data/lib/sendproof/ui/view.js +11 -3
- data/lib/sendproof/ui/views.css +7 -0
- data/lib/sendproof/version.rb +2 -2
- data/lib/sendproof/workbench.rb +11 -1
- data/lib/sendproof.rb +2 -0
- metadata +55 -2
|
@@ -13,24 +13,44 @@ module Sendproof
|
|
|
13
13
|
# Result of draining the inner response body.
|
|
14
14
|
Response = Struct.new(:status, :headers, :body)
|
|
15
15
|
|
|
16
|
-
def initialize(app, config)
|
|
16
|
+
def initialize(app, config, sessions)
|
|
17
17
|
@app = app
|
|
18
18
|
@config = config
|
|
19
|
+
@sessions = sessions
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
# @param env [Hash] the Rack environment of the +/sendproof/_preview/...+ request
|
|
22
23
|
# @param prefix [Integer] index of the reserved prefix in PATH_INFO
|
|
23
24
|
# @return [Array] Rack response
|
|
24
25
|
def call(env, request, prefix)
|
|
26
|
+
id = env[PreviewSessions::HEADER]
|
|
27
|
+
return PreviewSessions.not_found if id && !Protocol.same_origin?(request)
|
|
28
|
+
|
|
29
|
+
if id
|
|
30
|
+
return denied(request) unless @config.authorized?(request)
|
|
31
|
+
|
|
32
|
+
return @sessions.with_session(request, id) { |session| preview(env, request, prefix, session) }
|
|
33
|
+
end
|
|
34
|
+
preview(env, request, prefix)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def preview(env, request, prefix, held = nil)
|
|
25
40
|
started = Clock.now
|
|
26
41
|
path = env["PATH_INFO"].to_s
|
|
27
|
-
rejection = precheck(env, request, path, prefix)
|
|
42
|
+
rejection = precheck(env, request, path, prefix, held)
|
|
28
43
|
return rejection if rejection.is_a?(Array)
|
|
29
44
|
|
|
30
45
|
rewritten = path[0, prefix] + path[(prefix + Protocol::PREFIX.length)..]
|
|
31
|
-
resolution =
|
|
46
|
+
resolution = if held && request.get?
|
|
47
|
+
@config.resolve_session_get(rewritten, env)
|
|
48
|
+
else
|
|
49
|
+
@config.resolve_target(request.request_method, rewritten, env)
|
|
50
|
+
end
|
|
32
51
|
return Protocol.problem(404, "The preview target was not found for this method.") if resolution.nil?
|
|
33
52
|
return Protocol.problem(409, "This operation is unavailable for preview.") if resolution == :ineligible
|
|
53
|
+
return execute_held(env, request, held, rewritten, started) if held
|
|
34
54
|
|
|
35
55
|
provider = @config.preview_provider
|
|
36
56
|
return Protocol.problem(503, "Preview requires one available preview provider.") unless provider
|
|
@@ -38,9 +58,7 @@ module Sendproof
|
|
|
38
58
|
execute(env, request, provider, rewritten, started)
|
|
39
59
|
end
|
|
40
60
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def precheck(env, request, path, prefix)
|
|
61
|
+
def precheck(env, request, path, prefix, held)
|
|
44
62
|
return Protocol.problem(400, "A Sendproof preview requires Prefer: tx=rollback.") unless Protocol.exact_preference?(env)
|
|
45
63
|
return Protocol.problem(405, "A preview requires a response body.") if request.head?
|
|
46
64
|
|
|
@@ -48,6 +66,8 @@ module Sendproof
|
|
|
48
66
|
if target.empty? || target.start_with?("//") || bench_target?(target) || !valid_target?(target)
|
|
49
67
|
return Protocol.problem(400, "The Sendproof preview target is invalid.")
|
|
50
68
|
end
|
|
69
|
+
return if held # The outer request already passed admission and ownership checks.
|
|
70
|
+
|
|
51
71
|
return Protocol.problem(403, "A preview must come from the application's own origin.") unless Protocol.same_origin?(request)
|
|
52
72
|
return denied(request) unless @config.authorized?(request)
|
|
53
73
|
|
|
@@ -145,6 +165,61 @@ module Sendproof
|
|
|
145
165
|
outcome(request, preview, response, failure, handler_failure, recorder, envelope)
|
|
146
166
|
end
|
|
147
167
|
|
|
168
|
+
# Each request gets a new recorder; only the stores' transactions and rewind points survive it.
|
|
169
|
+
def execute_held(env, request, held, rewritten, started)
|
|
170
|
+
recorder = Recorder.new(rollback: true, started:, include_sql_values: @config.sql_parameter_values?)
|
|
171
|
+
preview = PreviewRequest.new(recorder:, clock: Clock::Request.new(started), session_get: request.get?)
|
|
172
|
+
context = ProviderContext.new(env:, request:, config: @config)
|
|
173
|
+
sql = held.sql
|
|
174
|
+
preview.session = sql
|
|
175
|
+
Attribution.open(recorder)
|
|
176
|
+
Capture.with(recorder) do
|
|
177
|
+
sql.begin_step(held.next_step)
|
|
178
|
+
held.stores.each { |store| store.begin_step(held.next_step, recorder) }
|
|
179
|
+
begin
|
|
180
|
+
held.guards.each do |store|
|
|
181
|
+
store.begin_preview(context, recorder) if store.respond_to?(:begin_preview)
|
|
182
|
+
raise PreviewSessions::StoreEnded unless store.describe[:mode].to_s == "guard"
|
|
183
|
+
end
|
|
184
|
+
response, handler_failure = dispatch(env, rewritten, preview)
|
|
185
|
+
preview.clock.end_handler
|
|
186
|
+
ensure
|
|
187
|
+
finish_guards(held.guards, recorder)
|
|
188
|
+
end
|
|
189
|
+
held.stores.each { |store| store.capture_step(recorder) }
|
|
190
|
+
sql.finalize_capture(recorder) if sql.respond_to?(:finalize_capture)
|
|
191
|
+
raise recorder.fault if recorder.fault
|
|
192
|
+
|
|
193
|
+
if handler_failure || !preview.completed? || response.nil? || response.status >= 500 || recorder.blocked
|
|
194
|
+
held.undo_step
|
|
195
|
+
handler_failure ||= RuntimeError.new("The preview handler returned a server error.") if response && response.status >= 500
|
|
196
|
+
return outcome(request, preview, response, nil, handler_failure, recorder, nil)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
sql.keep_step
|
|
200
|
+
reply = serialize(response, sql, recorder.finish, preview, session: { id: held.id, step: held.next_step })
|
|
201
|
+
held.advance
|
|
202
|
+
reply
|
|
203
|
+
end
|
|
204
|
+
rescue PreviewSessions::StepUndone => error
|
|
205
|
+
held.undo_step
|
|
206
|
+
outcome(request, preview, nil, error, nil, recorder, nil)
|
|
207
|
+
ensure
|
|
208
|
+
skip_session_commit(env)
|
|
209
|
+
recorder.finish if recorder.active?
|
|
210
|
+
Attribution.close(recorder)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def finish_guards(guards, recorder)
|
|
214
|
+
failure = nil
|
|
215
|
+
guards.each do |store|
|
|
216
|
+
store.finish_preview(recorder) if store.respond_to?(:finish_preview)
|
|
217
|
+
rescue Exception => error # every guard gets its finish call even if another unwound
|
|
218
|
+
failure ||= error
|
|
219
|
+
end
|
|
220
|
+
raise failure if failure
|
|
221
|
+
end
|
|
222
|
+
|
|
148
223
|
# Runs the inner request. Returns the buffered response and any failure.
|
|
149
224
|
def dispatch(env, rewritten, preview)
|
|
150
225
|
inner = inner_env(env, rewritten, preview)
|
|
@@ -186,6 +261,7 @@ module Sendproof
|
|
|
186
261
|
inner["ORIGINAL_FULLPATH"] = full if env.key?("ORIGINAL_FULLPATH")
|
|
187
262
|
inner["rack.hijack?"] = false
|
|
188
263
|
inner.delete("HTTP_ACCEPT_ENCODING")
|
|
264
|
+
inner.delete(PreviewSessions::HEADER)
|
|
189
265
|
inner["HTTP_CACHE_CONTROL"] = "no-cache, no-store"
|
|
190
266
|
inner["rack.input"].rewind if inner["rack.input"].respond_to?(:rewind)
|
|
191
267
|
inner[ENV_KEY] = preview
|
|
@@ -278,13 +354,14 @@ module Sendproof
|
|
|
278
354
|
Protocol.problem(status, title, extra)
|
|
279
355
|
end
|
|
280
356
|
|
|
281
|
-
def serialize(response,
|
|
282
|
-
changes, truncated = Limits.snapshot_changes(
|
|
357
|
+
def serialize(response, provider_session, capture, preview, session: nil)
|
|
358
|
+
changes, truncated = Limits.snapshot_changes(provider_session.changes + capture.changes)
|
|
283
359
|
headers = response.headers.reject { |name, _| Protocol::PRIVATE_HEADERS.include?(name) || name.length > Limits::NAME }
|
|
284
360
|
.first(Limits::PARAMETERS).to_h { |name, value| [name, Limits.clip(value)] }
|
|
285
361
|
document = { status: response.status, headers:, body: read_body(response), changes:,
|
|
286
362
|
effects: capture.effects, logs: capture.logs, rolledBack: true }
|
|
287
|
-
document[:
|
|
363
|
+
document[:session] = session if session
|
|
364
|
+
document[:changesTruncated] = true if truncated || provider_session.changes_truncated? || capture.changes_truncated
|
|
288
365
|
document[:effectsTruncated] = true if capture.effects_truncated
|
|
289
366
|
document[:logsTruncated] = true if capture.logs_truncated
|
|
290
367
|
started = Clock.now
|
data/lib/sendproof/protocol.rb
CHANGED
|
@@ -50,8 +50,8 @@ module Sendproof
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
# A Rack response carrying an RFC 9457 problem document, never cacheable.
|
|
53
|
-
def problem(status, title, headers = {})
|
|
54
|
-
body = JSON.generate({ type: "about:blank", title:, status
|
|
53
|
+
def problem(status, title, headers = {}, **extensions)
|
|
54
|
+
body = JSON.generate({ type: "about:blank", title:, status:, **extensions })
|
|
55
55
|
[status, { "content-type" => "application/problem+json", "cache-control" => "no-store",
|
|
56
56
|
"content-length" => body.bytesize.to_s }.merge(headers), [body]]
|
|
57
57
|
end
|
data/lib/sendproof/provider.rb
CHANGED
|
@@ -12,6 +12,10 @@ module Sendproof
|
|
|
12
12
|
# A provider opens a rollback-only session on the connection the request handler will use,
|
|
13
13
|
# captures change snapshots, rolls back explicitly, and releases every resource on every
|
|
14
14
|
# failure path. Subclassing is optional; any object with these methods works.
|
|
15
|
+
#
|
|
16
|
+
# To support Preview sessions, implement +begin_held_preview(context)+. Its return value
|
|
17
|
+
# implements +begin_step(step)+, +keep_step+, +rewind(step)+ and +close+ alongside the capture
|
|
18
|
+
# methods. The core calls these on the same worker thread throughout the session.
|
|
15
19
|
class Provider
|
|
16
20
|
# @return [Boolean] whether this request can be previewed
|
|
17
21
|
def available?
|
|
@@ -73,9 +77,13 @@ module Sendproof
|
|
|
73
77
|
# A session with nothing to roll back.
|
|
74
78
|
class Session < PreviewSession
|
|
75
79
|
def rollback! = nil
|
|
80
|
+
def begin_step(_step); end
|
|
81
|
+
def keep_step; end
|
|
82
|
+
def rewind(_step); end
|
|
76
83
|
end
|
|
77
84
|
|
|
78
85
|
def begin_preview(_context) = Session.new
|
|
86
|
+
def begin_held_preview(_context) = Session.new
|
|
79
87
|
|
|
80
88
|
def begin_observation(_context) = Observation.new
|
|
81
89
|
end
|
|
@@ -18,6 +18,219 @@ module Sendproof
|
|
|
18
18
|
"source": "redis 7.4 COMMAND flags",
|
|
19
19
|
"default": "write",
|
|
20
20
|
"keyFormat": "Upper-case command name; a container command and its subcommand are joined with a vertical bar, as in OBJECT|ENCODING.",
|
|
21
|
+
"firstKeyNote": "Where a command's first key argument is, for the Db log entry target. A 1-based position in the arguments after the command name, so INCRBY key by is 1; a container command's subcommand counts as an argument, so OBJECT FREQ key is 2. A command that is not listed has its first key at position 1; 0 means no positional key. Generated from COMMAND INFO on Redis 7.4.12, keeping the entries that are not 1.",
|
|
22
|
+
"firstKey": {
|
|
23
|
+
"ACL": 0,
|
|
24
|
+
"ACL|CAT": 0,
|
|
25
|
+
"ACL|DELUSER": 0,
|
|
26
|
+
"ACL|DRYRUN": 0,
|
|
27
|
+
"ACL|GENPASS": 0,
|
|
28
|
+
"ACL|GETUSER": 0,
|
|
29
|
+
"ACL|HELP": 0,
|
|
30
|
+
"ACL|LIST": 0,
|
|
31
|
+
"ACL|LOAD": 0,
|
|
32
|
+
"ACL|LOG": 0,
|
|
33
|
+
"ACL|SAVE": 0,
|
|
34
|
+
"ACL|SETUSER": 0,
|
|
35
|
+
"ACL|USERS": 0,
|
|
36
|
+
"ACL|WHOAMI": 0,
|
|
37
|
+
"ASKING": 0,
|
|
38
|
+
"AUTH": 0,
|
|
39
|
+
"BGREWRITEAOF": 0,
|
|
40
|
+
"BGSAVE": 0,
|
|
41
|
+
"BITOP": 2,
|
|
42
|
+
"BLMPOP": 0,
|
|
43
|
+
"BZMPOP": 0,
|
|
44
|
+
"CLIENT": 0,
|
|
45
|
+
"CLIENT|CACHING": 0,
|
|
46
|
+
"CLIENT|GETNAME": 0,
|
|
47
|
+
"CLIENT|GETREDIR": 0,
|
|
48
|
+
"CLIENT|HELP": 0,
|
|
49
|
+
"CLIENT|ID": 0,
|
|
50
|
+
"CLIENT|INFO": 0,
|
|
51
|
+
"CLIENT|KILL": 0,
|
|
52
|
+
"CLIENT|LIST": 0,
|
|
53
|
+
"CLIENT|NO-EVICT": 0,
|
|
54
|
+
"CLIENT|NO-TOUCH": 0,
|
|
55
|
+
"CLIENT|PAUSE": 0,
|
|
56
|
+
"CLIENT|REPLY": 0,
|
|
57
|
+
"CLIENT|SETINFO": 0,
|
|
58
|
+
"CLIENT|SETNAME": 0,
|
|
59
|
+
"CLIENT|TRACKING": 0,
|
|
60
|
+
"CLIENT|TRACKINGINFO": 0,
|
|
61
|
+
"CLIENT|UNBLOCK": 0,
|
|
62
|
+
"CLIENT|UNPAUSE": 0,
|
|
63
|
+
"CLUSTER": 0,
|
|
64
|
+
"CLUSTER|ADDSLOTS": 0,
|
|
65
|
+
"CLUSTER|ADDSLOTSRANGE": 0,
|
|
66
|
+
"CLUSTER|BUMPEPOCH": 0,
|
|
67
|
+
"CLUSTER|COUNT-FAILURE-REPORTS": 0,
|
|
68
|
+
"CLUSTER|COUNTKEYSINSLOT": 0,
|
|
69
|
+
"CLUSTER|DELSLOTS": 0,
|
|
70
|
+
"CLUSTER|DELSLOTSRANGE": 0,
|
|
71
|
+
"CLUSTER|FAILOVER": 0,
|
|
72
|
+
"CLUSTER|FLUSHSLOTS": 0,
|
|
73
|
+
"CLUSTER|FORGET": 0,
|
|
74
|
+
"CLUSTER|GETKEYSINSLOT": 0,
|
|
75
|
+
"CLUSTER|HELP": 0,
|
|
76
|
+
"CLUSTER|INFO": 0,
|
|
77
|
+
"CLUSTER|KEYSLOT": 0,
|
|
78
|
+
"CLUSTER|LINKS": 0,
|
|
79
|
+
"CLUSTER|MEET": 0,
|
|
80
|
+
"CLUSTER|MYID": 0,
|
|
81
|
+
"CLUSTER|MYSHARDID": 0,
|
|
82
|
+
"CLUSTER|NODES": 0,
|
|
83
|
+
"CLUSTER|REPLICAS": 0,
|
|
84
|
+
"CLUSTER|REPLICATE": 0,
|
|
85
|
+
"CLUSTER|RESET": 0,
|
|
86
|
+
"CLUSTER|SAVECONFIG": 0,
|
|
87
|
+
"CLUSTER|SET-CONFIG-EPOCH": 0,
|
|
88
|
+
"CLUSTER|SETSLOT": 0,
|
|
89
|
+
"CLUSTER|SHARDS": 0,
|
|
90
|
+
"CLUSTER|SLAVES": 0,
|
|
91
|
+
"CLUSTER|SLOTS": 0,
|
|
92
|
+
"COMMAND": 0,
|
|
93
|
+
"COMMAND|COUNT": 0,
|
|
94
|
+
"COMMAND|DOCS": 0,
|
|
95
|
+
"COMMAND|GETKEYS": 0,
|
|
96
|
+
"COMMAND|GETKEYSANDFLAGS": 0,
|
|
97
|
+
"COMMAND|HELP": 0,
|
|
98
|
+
"COMMAND|INFO": 0,
|
|
99
|
+
"COMMAND|LIST": 0,
|
|
100
|
+
"CONFIG": 0,
|
|
101
|
+
"CONFIG|GET": 0,
|
|
102
|
+
"CONFIG|HELP": 0,
|
|
103
|
+
"CONFIG|RESETSTAT": 0,
|
|
104
|
+
"CONFIG|REWRITE": 0,
|
|
105
|
+
"CONFIG|SET": 0,
|
|
106
|
+
"DBSIZE": 0,
|
|
107
|
+
"DEBUG": 0,
|
|
108
|
+
"DISCARD": 0,
|
|
109
|
+
"ECHO": 0,
|
|
110
|
+
"EVAL": 0,
|
|
111
|
+
"EVALSHA": 0,
|
|
112
|
+
"EVALSHA_RO": 0,
|
|
113
|
+
"EVAL_RO": 0,
|
|
114
|
+
"EXEC": 0,
|
|
115
|
+
"FAILOVER": 0,
|
|
116
|
+
"FCALL": 0,
|
|
117
|
+
"FCALL_RO": 0,
|
|
118
|
+
"FLUSHALL": 0,
|
|
119
|
+
"FLUSHDB": 0,
|
|
120
|
+
"FUNCTION": 0,
|
|
121
|
+
"FUNCTION|DELETE": 0,
|
|
122
|
+
"FUNCTION|DUMP": 0,
|
|
123
|
+
"FUNCTION|FLUSH": 0,
|
|
124
|
+
"FUNCTION|HELP": 0,
|
|
125
|
+
"FUNCTION|KILL": 0,
|
|
126
|
+
"FUNCTION|LIST": 0,
|
|
127
|
+
"FUNCTION|LOAD": 0,
|
|
128
|
+
"FUNCTION|RESTORE": 0,
|
|
129
|
+
"FUNCTION|STATS": 0,
|
|
130
|
+
"HELLO": 0,
|
|
131
|
+
"INFO": 0,
|
|
132
|
+
"KEYS": 0,
|
|
133
|
+
"LASTSAVE": 0,
|
|
134
|
+
"LATENCY": 0,
|
|
135
|
+
"LATENCY|DOCTOR": 0,
|
|
136
|
+
"LATENCY|GRAPH": 0,
|
|
137
|
+
"LATENCY|HELP": 0,
|
|
138
|
+
"LATENCY|HISTOGRAM": 0,
|
|
139
|
+
"LATENCY|HISTORY": 0,
|
|
140
|
+
"LATENCY|LATEST": 0,
|
|
141
|
+
"LATENCY|RESET": 0,
|
|
142
|
+
"LMPOP": 0,
|
|
143
|
+
"LOLWUT": 0,
|
|
144
|
+
"MEMORY": 0,
|
|
145
|
+
"MEMORY|DOCTOR": 0,
|
|
146
|
+
"MEMORY|HELP": 0,
|
|
147
|
+
"MEMORY|MALLOC-STATS": 0,
|
|
148
|
+
"MEMORY|PURGE": 0,
|
|
149
|
+
"MEMORY|STATS": 0,
|
|
150
|
+
"MEMORY|USAGE": 2,
|
|
151
|
+
"MIGRATE": 3,
|
|
152
|
+
"MODULE": 0,
|
|
153
|
+
"MODULE|HELP": 0,
|
|
154
|
+
"MODULE|LIST": 0,
|
|
155
|
+
"MODULE|LOAD": 0,
|
|
156
|
+
"MODULE|LOADEX": 0,
|
|
157
|
+
"MODULE|UNLOAD": 0,
|
|
158
|
+
"MONITOR": 0,
|
|
159
|
+
"MULTI": 0,
|
|
160
|
+
"OBJECT": 0,
|
|
161
|
+
"OBJECT|ENCODING": 2,
|
|
162
|
+
"OBJECT|FREQ": 2,
|
|
163
|
+
"OBJECT|HELP": 0,
|
|
164
|
+
"OBJECT|IDLETIME": 2,
|
|
165
|
+
"OBJECT|REFCOUNT": 2,
|
|
166
|
+
"PFDEBUG": 2,
|
|
167
|
+
"PFSELFTEST": 0,
|
|
168
|
+
"PING": 0,
|
|
169
|
+
"PSUBSCRIBE": 0,
|
|
170
|
+
"PSYNC": 0,
|
|
171
|
+
"PUBLISH": 0,
|
|
172
|
+
"PUBSUB": 0,
|
|
173
|
+
"PUBSUB|CHANNELS": 0,
|
|
174
|
+
"PUBSUB|HELP": 0,
|
|
175
|
+
"PUBSUB|NUMPAT": 0,
|
|
176
|
+
"PUBSUB|NUMSUB": 0,
|
|
177
|
+
"PUBSUB|SHARDCHANNELS": 0,
|
|
178
|
+
"PUBSUB|SHARDNUMSUB": 0,
|
|
179
|
+
"PUNSUBSCRIBE": 0,
|
|
180
|
+
"QUIT": 0,
|
|
181
|
+
"RANDOMKEY": 0,
|
|
182
|
+
"READONLY": 0,
|
|
183
|
+
"READWRITE": 0,
|
|
184
|
+
"REPLCONF": 0,
|
|
185
|
+
"REPLICAOF": 0,
|
|
186
|
+
"RESET": 0,
|
|
187
|
+
"ROLE": 0,
|
|
188
|
+
"SAVE": 0,
|
|
189
|
+
"SCAN": 0,
|
|
190
|
+
"SCRIPT": 0,
|
|
191
|
+
"SCRIPT|DEBUG": 0,
|
|
192
|
+
"SCRIPT|EXISTS": 0,
|
|
193
|
+
"SCRIPT|FLUSH": 0,
|
|
194
|
+
"SCRIPT|HELP": 0,
|
|
195
|
+
"SCRIPT|KILL": 0,
|
|
196
|
+
"SCRIPT|LOAD": 0,
|
|
197
|
+
"SELECT": 0,
|
|
198
|
+
"SHUTDOWN": 0,
|
|
199
|
+
"SINTERCARD": 0,
|
|
200
|
+
"SLAVEOF": 0,
|
|
201
|
+
"SLOWLOG": 0,
|
|
202
|
+
"SLOWLOG|GET": 0,
|
|
203
|
+
"SLOWLOG|HELP": 0,
|
|
204
|
+
"SLOWLOG|LEN": 0,
|
|
205
|
+
"SLOWLOG|RESET": 0,
|
|
206
|
+
"SUBSCRIBE": 0,
|
|
207
|
+
"SWAPDB": 0,
|
|
208
|
+
"SYNC": 0,
|
|
209
|
+
"TIME": 0,
|
|
210
|
+
"UNSUBSCRIBE": 0,
|
|
211
|
+
"UNWATCH": 0,
|
|
212
|
+
"WAIT": 0,
|
|
213
|
+
"WAITAOF": 0,
|
|
214
|
+
"XGROUP": 0,
|
|
215
|
+
"XGROUP|CREATE": 2,
|
|
216
|
+
"XGROUP|CREATECONSUMER": 2,
|
|
217
|
+
"XGROUP|DELCONSUMER": 2,
|
|
218
|
+
"XGROUP|DESTROY": 2,
|
|
219
|
+
"XGROUP|HELP": 0,
|
|
220
|
+
"XGROUP|SETID": 2,
|
|
221
|
+
"XINFO": 0,
|
|
222
|
+
"XINFO|CONSUMERS": 2,
|
|
223
|
+
"XINFO|GROUPS": 2,
|
|
224
|
+
"XINFO|HELP": 0,
|
|
225
|
+
"XINFO|STREAM": 2,
|
|
226
|
+
"XREAD": 0,
|
|
227
|
+
"XREADGROUP": 0,
|
|
228
|
+
"ZDIFF": 0,
|
|
229
|
+
"ZINTER": 0,
|
|
230
|
+
"ZINTERCARD": 0,
|
|
231
|
+
"ZMPOP": 0,
|
|
232
|
+
"ZUNION": 0
|
|
233
|
+
},
|
|
21
234
|
"read": [
|
|
22
235
|
"BITCOUNT",
|
|
23
236
|
"BITFIELD_RO",
|
|
@@ -121,7 +121,7 @@ module Sendproof
|
|
|
121
121
|
# @param mysql [Boolean] whether the database is MySQL or MariaDB, which also commit implicitly
|
|
122
122
|
# @param safe_procedures [Array<String>] lower-cased names from {normalize_procedures}; any other
|
|
123
123
|
# +CALL+ is refused on MySQL and MariaDB
|
|
124
|
-
# @param reserved [String, nil]
|
|
124
|
+
# @param reserved [String, Regexp, nil] savepoints the provider owns: the handler may not release or roll
|
|
125
125
|
# back to it
|
|
126
126
|
# @return [Boolean] whether it can end or replace the preview transaction
|
|
127
127
|
def ends_transaction?(sql, mysql: false, safe_procedures: [], reserved: nil)
|
|
@@ -131,10 +131,11 @@ module Sendproof
|
|
|
131
131
|
# Why +sql+ would end or escape the preview transaction, or nil when it is safe.
|
|
132
132
|
# @return [String, nil]
|
|
133
133
|
def reason(sql, mysql: false, safe_procedures: [], reserved: nil)
|
|
134
|
+
reserved = Regexp.escape(reserved) if reserved.is_a?(String)
|
|
134
135
|
split(sql.to_s, mysql: mysql).each do |statement|
|
|
135
136
|
verb = statement.split.first.to_s.upcase
|
|
136
137
|
return "the handler's #{verb} would end the Preview transaction" if statement.match?(CONTROL) || statement.match?(SET_AUTOCOMMIT)
|
|
137
|
-
if reserved && statement.match?(/\A(?:RELEASE|ROLLBACK|SAVEPOINT)\b/i) && statement.match?(/(?<![\w$])
|
|
138
|
+
if reserved && statement.match?(/\A(?:RELEASE|ROLLBACK|SAVEPOINT)\b/i) && statement.match?(/(?<![\w$])#{reserved}(?![\w$])/i)
|
|
138
139
|
return "the Preview's own savepoint is reserved for Sendproof"
|
|
139
140
|
end
|
|
140
141
|
next unless mysql
|
data/lib/sendproof/ui/api.js
CHANGED
|
@@ -224,7 +224,8 @@ export async function execute(request, preview, basePath, signal, { observedSend
|
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
if (!response.ok || body?.rolledBack !== true || !Number.isInteger(body.status)) {
|
|
227
|
-
|
|
227
|
+
// The problem's `code` (session_not_found, session_failed…) says why, so a run can tell an ended session from a failed step.
|
|
228
|
+
throw Object.assign(new Error('Preview was not acknowledged as rolled back (HTTP ' + response.status + '). ' + (body?.title || '')), { status: response.status, code: typeof body?.code === 'string' ? body.code : undefined });
|
|
228
229
|
}
|
|
229
230
|
const type = Object.entries(body.headers || {}).find(([name]) => name.toLowerCase() === 'content-type')?.[1] || '';
|
|
230
231
|
const content = body.body == null ? '' :
|