railwatch 1.6.0 → 1.6.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 +4 -4
- data/AGENTS.md +9 -9
- data/CHANGELOG.md +83 -0
- data/README.md +8 -8
- data/app/controllers/railwatch/beacon_controller.rb +56 -6
- data/docs/ai-and-mcp.md +14 -14
- data/docs/configuration.md +73 -14
- data/docs/faq.md +3 -3
- data/docs/getting-started.md +30 -20
- data/docs/replacing-nightwatch.md +1 -1
- data/docs/replacing-sentry.md +5 -4
- data/docs/security.md +6 -6
- data/docs/self-hosting.md +3 -3
- data/docs/testing.md +1 -1
- data/docs/troubleshooting.md +1 -1
- data/lib/generators/railwatch/agents/agents_generator.rb +5 -4
- data/lib/generators/railwatch/agents/templates/agents_block.md.tt +1 -1
- data/lib/generators/railwatch/install/install_generator.rb +5 -5
- data/lib/generators/railwatch/install/templates/initializer.rb.tt +1 -1
- data/lib/generators/railwatch/install/templates/post-deploy +5 -2
- data/lib/generators/railwatch/install/templates/railwatch.ts +44 -7
- data/lib/puma/plugin/railwatch.rb +7 -0
- data/lib/railwatch/authentication.rb +1 -1
- data/lib/railwatch/configuration.rb +69 -7
- data/lib/railwatch/engine.rb +4 -1
- data/lib/railwatch/redactor.rb +6 -2
- data/lib/railwatch/sql_normalizer.rb +21 -19
- data/lib/railwatch/version.rb +1 -1
- data/lib/railwatch.rb +24 -0
- data/lib/tasks/railwatch_tasks.rake +6 -5
- data/llms.txt +4 -4
- metadata +4 -3
data/lib/railwatch/engine.rb
CHANGED
|
@@ -21,7 +21,7 @@ module Railwatch
|
|
|
21
21
|
Railwatch::Console.silence!
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
# The dashboard gate railwatch-
|
|
24
|
+
# The dashboard gate railwatch-sidecar's proxy applies. Same source
|
|
25
25
|
# Mission Control Jobs reads: railwatch.http_basic_auth_user and
|
|
26
26
|
# _password in Rails credentials, which `bin/rails
|
|
27
27
|
# railwatch:authentication:configure` writes. An initializer or env var
|
|
@@ -39,6 +39,9 @@ module Railwatch
|
|
|
39
39
|
next unless Railwatch.enabled?
|
|
40
40
|
|
|
41
41
|
Rails.logger.warn("[railwatch] #{Railwatch::JsonCompat.advice}") if Railwatch::JsonCompat.broken?
|
|
42
|
+
if (name = Railwatch.config.embedded_mode_env)
|
|
43
|
+
Rails.logger.warn("[railwatch] #{name} is ignored. #{Railwatch::Configuration::EMBEDDED_MODE_MIGRATION}")
|
|
44
|
+
end
|
|
42
45
|
end
|
|
43
46
|
end
|
|
44
47
|
|
data/lib/railwatch/redactor.rb
CHANGED
|
@@ -9,7 +9,9 @@ module Railwatch
|
|
|
9
9
|
# Credentials are often carried in vendor-specific headers that an app
|
|
10
10
|
# cannot enumerate ahead of time (X-Api-Key, Stripe-Signature,
|
|
11
11
|
# X-Auth-Token, and similar). Match credential-shaped name segments in
|
|
12
|
-
# addition to the exact configurable denylist.
|
|
12
|
+
# addition to the exact configurable denylist. Identity headers an
|
|
13
|
+
# authenticating proxy adds (X-Forwarded-Email, X-Remote-User, a client
|
|
14
|
+
# certificate) name a person, so they count too.
|
|
13
15
|
SENSITIVE_HEADER_NAME = %r{
|
|
14
16
|
(?:\A|-)
|
|
15
17
|
(?:
|
|
@@ -20,7 +22,9 @@ module Railwatch
|
|
|
20
22
|
security-?token|service-?token|identity-?token|id-?token|
|
|
21
23
|
csrf-?token|xsrf-?token|credential|
|
|
22
24
|
hmac(?:-?signature)?|jwt(?:-?(?:assertion|token))?|
|
|
23
|
-
webhook-?(?:hmac|secret|signature)|token|secret|signature
|
|
25
|
+
webhook-?(?:hmac|secret|signature)|token|secret|signature|
|
|
26
|
+
password|passwd|session-?id|subscription-?key|client-?cert|
|
|
27
|
+
(?:forwarded|remote)-?(?:user|email)
|
|
24
28
|
)
|
|
25
29
|
(?:-|\z)
|
|
26
30
|
}ix
|
|
@@ -141,10 +141,11 @@ module Railwatch
|
|
|
141
141
|
# default the notification does not carry: MySQL escapes (unless the
|
|
142
142
|
# session sets NO_BACKSLASH_ESCAPES), PostgreSQL does not (unless it
|
|
143
143
|
# sets standard_conforming_strings off, deprecated since 9.1), E''
|
|
144
|
-
# always does, SQLite never does. Scan with each dialect's default
|
|
145
|
-
#
|
|
146
|
-
#
|
|
147
|
-
# the
|
|
144
|
+
# always does, SQLite never does. Scan with each dialect's default.
|
|
145
|
+
# An unknown adapter is scanned both ways: where the readings agree
|
|
146
|
+
# nothing is lost, and where they disagree no single reading is
|
|
147
|
+
# safe (each exposes a value the other hides), so the rest of the
|
|
148
|
+
# statement is masked (#ambiguous_quoted_value_end).
|
|
148
149
|
#
|
|
149
150
|
# This deliberately no longer abandons the rest of the statement on
|
|
150
151
|
# seeing \'. That was safe but destroyed the shape, and on MySQL --
|
|
@@ -154,26 +155,16 @@ module Railwatch
|
|
|
154
155
|
# hashed into one query group. Values are masked either way; only
|
|
155
156
|
# the tail's shape was being thrown away.
|
|
156
157
|
backslash_escapes = mysql || unknown_adapter || explicit_escape_string
|
|
157
|
-
i
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
elsif bytes.getbyte(i) == 39
|
|
162
|
-
if bytes.getbyte(i + 1) == 39
|
|
163
|
-
i += 2
|
|
164
|
-
else
|
|
165
|
-
i += 1
|
|
166
|
-
break
|
|
167
|
-
end
|
|
168
|
-
else
|
|
169
|
-
i += 1
|
|
170
|
-
end
|
|
158
|
+
i = if unknown_adapter && !explicit_escape_string
|
|
159
|
+
ambiguous_quoted_value_end(bytes, i, 39)
|
|
160
|
+
else
|
|
161
|
+
skip_quoted_value(bytes, i, 39, backslash_escapes: backslash_escapes)
|
|
171
162
|
end
|
|
172
163
|
out << "?"
|
|
173
164
|
# When adapter metadata is unavailable, privacy wins over preserving
|
|
174
165
|
# ANSI quoted-identifier shape: this may be a MySQL-compatible string.
|
|
175
166
|
elsif mysql_ambiguous && byte == 34 # MySQL/Trilogy default: "..." is a string.
|
|
176
|
-
i = skip_quoted_value(bytes, i, 34, backslash_escapes: true)
|
|
167
|
+
i = mysql ? skip_quoted_value(bytes, i, 34, backslash_escapes: true) : ambiguous_quoted_value_end(bytes, i, 34)
|
|
177
168
|
out << "?"
|
|
178
169
|
elsif sqlite && byte == 34 # SQLite DQS is ambiguous; mask unless syntax proves identifier use.
|
|
179
170
|
close_at = quoted_identifier_end(bytes, i, 34)
|
|
@@ -218,6 +209,17 @@ module Railwatch
|
|
|
218
209
|
out.force_encoding(Encoding::UTF_8)
|
|
219
210
|
end
|
|
220
211
|
|
|
212
|
+
# Where a quoted value ends when the adapter is unknown, so whether a
|
|
213
|
+
# backslash escapes the quote after it is too. Where the two readings
|
|
214
|
+
# agree, that is the end. Where they disagree ('C:\' AND ssn = '1' ...)
|
|
215
|
+
# they pair every later quote differently, and whichever is wrong puts
|
|
216
|
+
# the next value outside quotes -- so the rest of the statement is masked.
|
|
217
|
+
def ambiguous_quoted_value_end(bytes, index, quote)
|
|
218
|
+
escaped = skip_quoted_value(bytes, index, quote, backslash_escapes: true)
|
|
219
|
+
standard = skip_quoted_value(bytes, index, quote, backslash_escapes: false)
|
|
220
|
+
escaped == standard ? escaped : bytes.bytesize
|
|
221
|
+
end
|
|
222
|
+
|
|
221
223
|
def skip_quoted_value(bytes, index, quote, backslash_escapes:)
|
|
222
224
|
length = bytes.bytesize
|
|
223
225
|
i = index + 1
|
data/lib/railwatch/version.rb
CHANGED
data/lib/railwatch.rb
CHANGED
|
@@ -321,6 +321,30 @@ module Railwatch
|
|
|
321
321
|
config.user(&block)
|
|
322
322
|
end
|
|
323
323
|
|
|
324
|
+
# The tenant hint for the browser client (startRailwatch({ tenant })),
|
|
325
|
+
# signed with the app's secret_key_base. The beacon takes no credential,
|
|
326
|
+
# so it believes only a tenant this app put in the page itself; a bare
|
|
327
|
+
# name a client sends is ignored. nil in, nil out.
|
|
328
|
+
def beacon_tenant_hint(tenant)
|
|
329
|
+
return nil if tenant.nil? || tenant.to_s.empty?
|
|
330
|
+
|
|
331
|
+
beacon_tenant_verifier.generate(tenant.to_s[0, 255], purpose: :railwatch_beacon_tenant)
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
# The tenant a signed hint names, or nil for anything this app did not sign.
|
|
335
|
+
def verified_beacon_tenant(hint)
|
|
336
|
+
return nil unless hint.is_a?(String) && !hint.empty?
|
|
337
|
+
|
|
338
|
+
tenant = beacon_tenant_verifier.verified(hint, purpose: :railwatch_beacon_tenant)
|
|
339
|
+
tenant.is_a?(String) ? tenant : nil
|
|
340
|
+
rescue StandardError
|
|
341
|
+
nil
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
def beacon_tenant_verifier
|
|
345
|
+
Rails.application.message_verifier("railwatch.beacon_tenant")
|
|
346
|
+
end
|
|
347
|
+
|
|
324
348
|
def fingerprint(&block)
|
|
325
349
|
config.fingerprint(&block)
|
|
326
350
|
end
|
|
@@ -30,9 +30,10 @@ module Railwatch
|
|
|
30
30
|
|
|
31
31
|
# Where this install's platform lives, derived from config.ingest_url:
|
|
32
32
|
# railwatch:token and railwatch:mcp point at the same host the gem already
|
|
33
|
-
# ships to, so a self-hosted app never gets told to visit railwatch.
|
|
33
|
+
# ships to, so a self-hosted app never gets told to visit app.railwatch.dev.
|
|
34
34
|
class Endpoints
|
|
35
|
-
|
|
35
|
+
# Railwatch Cloud; railwatch.rebulk.com is its old name and redirects.
|
|
36
|
+
HOSTED_HOSTS = %w[app.railwatch.dev railwatch.rebulk.com].freeze
|
|
36
37
|
|
|
37
38
|
def initialize(config)
|
|
38
39
|
@uri = URI.parse(config.ingest_url)
|
|
@@ -48,7 +49,7 @@ module Railwatch
|
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
def self_hosted?
|
|
51
|
-
@uri.host
|
|
52
|
+
!HOSTED_HOSTS.include?(@uri.host)
|
|
52
53
|
end
|
|
53
54
|
end
|
|
54
55
|
end
|
|
@@ -275,9 +276,9 @@ namespace :railwatch do
|
|
|
275
276
|
# The same shape as `mission_control:jobs:authentication:configure`: asks
|
|
276
277
|
# for a user and password and writes them to the current environment's
|
|
277
278
|
# credentials under `railwatch:`, which the engine reads at boot and
|
|
278
|
-
# railwatch-
|
|
279
|
+
# railwatch-sidecar's dashboard proxy checks.
|
|
279
280
|
# RAILS_ENV=production bin/rails railwatch:authentication:configure
|
|
280
|
-
desc "Configure HTTP Basic authentication for railwatch-
|
|
281
|
+
desc "Configure HTTP Basic authentication for railwatch-sidecar's dashboard (writes Rails credentials)"
|
|
281
282
|
task "authentication:configure" => :environment do
|
|
282
283
|
Railwatch::Authentication.configure
|
|
283
284
|
end
|
data/llms.txt
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
> every one of them into a single execution tree by `execution_id`/`trace_id`,
|
|
8
8
|
> and sends them from a background thread over HTTPS to a Railwatch server:
|
|
9
9
|
> Railwatch Cloud (the default), a self-hosted railwatch-rs, or the one the
|
|
10
|
-
> separate `railwatch-
|
|
10
|
+
> separate `railwatch-sidecar` gem runs next to Puma for an embedded dashboard
|
|
11
11
|
> at `/railwatch`. It replaces a separate APM and a separate error tracker
|
|
12
12
|
> with one gem and one configuration block, costs under a millisecond of CPU
|
|
13
13
|
> per request, and never writes to the application's primary database.
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
|
|
21
21
|
## Docs
|
|
22
22
|
|
|
23
|
-
- [README](README.md): what Railwatch is, where telemetry goes (Cloud, self-hosted, railwatch-
|
|
24
|
-
- [Getting started](docs/getting-started.md): the install and where its token comes from, embedded with the `railwatch-
|
|
25
|
-
- [Configuration](docs/configuration.md): every configuration option and its `RAILWATCH_*` environment variable, plus the full public facade, redaction, rejection, transport and buffering behaviour, the dashboard gate railwatch-
|
|
23
|
+
- [README](README.md): what Railwatch is, where telemetry goes (Cloud, self-hosted, railwatch-sidecar), the install, and where each document fits.
|
|
24
|
+
- [Getting started](docs/getting-started.md): the install and where its token comes from, embedded with the `railwatch-sidecar` gem, moving from 0.x embedded mode, the three optional lines, and deploying under Kamal, Docker/Heroku/Render, or no deploy tool at all.
|
|
25
|
+
- [Configuration](docs/configuration.md): every configuration option and its `RAILWATCH_*` environment variable, plus the full public facade, redaction, rejection, transport and buffering behaviour, the dashboard gate railwatch-sidecar uses, and the rake tasks.
|
|
26
26
|
- [Record types](docs/records.md): every record type the gem ships and every attribute on it, including RubyLLM calls (tokens, cost, finish reason, tool calls, workflows), sourced from the code that builds it.
|
|
27
27
|
- [Testing](docs/testing.md): the RSpec and Minitest matchers (`have_railwatch_queries`, `have_railwatch_n_plus_one`, `record_railwatch_span`, `record_railwatch_exception`, `have_railwatch_outgoing_requests`, `have_railwatch_http_in_transaction`) and a CI performance-gate recipe.
|
|
28
28
|
- [Production source maps](docs/source-maps.md): hidden Vite maps, private upload before publishing assets, safe opt-in deletion, resolved browser stacks and default issue grouping.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: railwatch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cole Robertson
|
|
@@ -77,6 +77,7 @@ files:
|
|
|
77
77
|
- lib/generators/railwatch/install/templates/initializer.rb.tt
|
|
78
78
|
- lib/generators/railwatch/install/templates/post-deploy
|
|
79
79
|
- lib/generators/railwatch/install/templates/railwatch.ts
|
|
80
|
+
- lib/puma/plugin/railwatch.rb
|
|
80
81
|
- lib/railwatch.rb
|
|
81
82
|
- lib/railwatch/attachments.rb
|
|
82
83
|
- lib/railwatch/authentication.rb
|
|
@@ -137,11 +138,11 @@ files:
|
|
|
137
138
|
- lib/railwatch/wire_fixtures.json
|
|
138
139
|
- lib/tasks/railwatch_tasks.rake
|
|
139
140
|
- llms.txt
|
|
140
|
-
homepage: https://railwatch.
|
|
141
|
+
homepage: https://railwatch.dev
|
|
141
142
|
licenses:
|
|
142
143
|
- MIT
|
|
143
144
|
metadata:
|
|
144
|
-
homepage_uri: https://railwatch.
|
|
145
|
+
homepage_uri: https://railwatch.dev
|
|
145
146
|
source_code_uri: https://github.com/Rebulk/railwatch
|
|
146
147
|
changelog_uri: https://github.com/Rebulk/railwatch/blob/main/CHANGELOG.md
|
|
147
148
|
documentation_uri: https://github.com/Rebulk/railwatch/blob/main/README.md
|