rails-profiler 0.44.23 → 0.44.24
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 +12 -0
- data/lib/profiler/cluster/security.rb +9 -1
- data/lib/profiler/env_key_policy.rb +2 -1
- data/lib/profiler/middleware/cors_policy.rb +22 -0
- data/lib/profiler/peers.rb +1 -0
- data/lib/profiler/railtie.rb +7 -0
- data/lib/profiler/redaction.rb +10 -6
- data/lib/profiler/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1729fcad234995351945e11bd293601f63841d946c14e6e2fbc95f30f9caf2f6
|
|
4
|
+
data.tar.gz: b823de0bc5c361f1ca33bd11e9f971f44dde64db2edaf893041a94def6afd21e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f91e65367aa8085f1c000b8c7430683adaceb4a428cf7a136cdb599495fee5a0868df4f94bfab6398b564ad9e4c0b27059ca2940cc19f9fc79ff4f96e9386d4
|
|
7
|
+
data.tar.gz: 89e7752d3d1a346469c12ea74d1545e7c7f239a98a2b542892b3cb3962ac1b42584577f3b9aebdcc3610e16e23b4272336d42509803b01197ffa344cbe2304b9
|
data/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,18 @@ every commit of every tag interval is accounted for one way or the other.
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.44.24] - 2026-10-26
|
|
23
|
+
|
|
24
|
+
<!-- stamped -->
|
|
25
|
+
|
|
26
|
+
### Security
|
|
27
|
+
|
|
28
|
+
- **Secrets:** Refuse cluster secrets and peer tokens surrounded by spaces or newlines at boot, which break HTTP requests. `trailing` newlines cause `ArgumentError` in `Net::HTTP` and trailing spaces cause systematic 403 errors. Refs #74
|
|
29
|
+
- **Redaction:** Mask `peer_token` by value in captured data (headers, bodies, params) alongside `cluster_secret`, preventing credential leakage across profiles and logs. Refs #74. A secret or token padded with spaces stays masked.
|
|
30
|
+
- **Secrets:** A padded `cluster_secret` stays required (still refused) when `cluster_require_secret = false`, instead of silently disabling authentication. Refs #74
|
|
31
|
+
- **Environment:** Protect additional environment variables from override via the Env tab and MCP tools: `LOCALDOMAIN`, `RES_OPTIONS`, `HOSTALIASES`, `NODE_EXTRA_CA_CERTS` and `TMPDIR`. These variables control hostname resolution and certificate store location. Refs #74
|
|
32
|
+
- **CORS:** Warn at boot when `cors_allowed_origins` contains wildcard `"*"`, which allows any website to access the profiler if a visitor browses it. Recommend using specific origins instead. Refs #74
|
|
33
|
+
|
|
22
34
|
## [0.44.23] - 2026-10-25
|
|
23
35
|
|
|
24
36
|
<!-- stamped -->
|
|
@@ -20,7 +20,14 @@ module Profiler
|
|
|
20
20
|
# and no cluster_secret, the behaviour of 0.30.6.
|
|
21
21
|
def secret_required?
|
|
22
22
|
config = Profiler.configuration
|
|
23
|
-
config.cluster_require_secret || configured_secret?
|
|
23
|
+
config.cluster_require_secret || configured_secret? || padded_secret?
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# A secret that was meant to be set but is padded (a trailing newline from a file) stays
|
|
27
|
+
# required: dropping it would turn a configured secret into no authentication at all.
|
|
28
|
+
def padded_secret?
|
|
29
|
+
secret = Profiler.configuration.cluster_secret.to_s
|
|
30
|
+
!secret.strip.empty? && secret != secret.strip
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
def configured_secret?
|
|
@@ -31,6 +38,7 @@ module Profiler
|
|
|
31
38
|
def secret_problem
|
|
32
39
|
secret = Profiler.configuration.cluster_secret.to_s
|
|
33
40
|
return "No config.cluster_secret is configured" if secret.strip.empty?
|
|
41
|
+
return "config.cluster_secret is surrounded by spaces or newlines, which breaks HTTP requests" if secret != secret.strip
|
|
34
42
|
return nil if secret.strip.length >= MIN_SECRET_LENGTH
|
|
35
43
|
|
|
36
44
|
"config.cluster_secret is shorter than #{MIN_SECRET_LENGTH} characters, so it is ignored " \
|
|
@@ -21,7 +21,8 @@ module Profiler
|
|
|
21
21
|
# and which certificates it trusts, or the profiler's own read-only switch.
|
|
22
22
|
PROTECTED_KEYS = %w[
|
|
23
23
|
RAILS_ENV RACK_ENV DATABASE_URL SECRET_KEY_BASE RAILS_MASTER_KEY PROFILER_TEST_RUNNER_CHILD
|
|
24
|
-
PROFILER_MCP_READ_ONLY SSL_CERT_FILE SSL_CERT_DIR
|
|
24
|
+
PROFILER_MCP_READ_ONLY SSL_CERT_FILE SSL_CERT_DIR LOCALDOMAIN RES_OPTIONS HOSTALIASES
|
|
25
|
+
NODE_EXTRA_CA_CERTS TMPDIR
|
|
25
26
|
].freeze
|
|
26
27
|
# PG: libpq (PGHOST, PGPASSWORD, PGSERVICEFILE...). MYSQL_: the MySQL client (MYSQL_PWD,
|
|
27
28
|
# MYSQL_HOST...). OPENSSL_: OPENSSL_CONF and OPENSSL_MODULES can load a shared library.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Profiler
|
|
4
|
+
module Middleware
|
|
5
|
+
# Validation of CORS configuration at boot time.
|
|
6
|
+
module CorsPolicy
|
|
7
|
+
module_function
|
|
8
|
+
|
|
9
|
+
# Logged once at boot when cors_allowed_origins contains "*", which is dangerous.
|
|
10
|
+
def warn_about_configuration(logger)
|
|
11
|
+
return unless Profiler.configuration.extension_cors_enabled
|
|
12
|
+
return unless Array(Profiler.configuration.cors_allowed_origins).include?("*")
|
|
13
|
+
|
|
14
|
+
Profiler.log_warn(
|
|
15
|
+
"CORS: '*' (wildcard origin) is set in cors_allowed_origins, which allows any website to access " \
|
|
16
|
+
"the profiler if a visitor browses the profiler. Set cors_allowed_origins to specific origins instead.",
|
|
17
|
+
logger: logger
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/profiler/peers.rb
CHANGED
|
@@ -56,6 +56,7 @@ module Profiler
|
|
|
56
56
|
def token_problem
|
|
57
57
|
token = Profiler.configuration.peer_token.to_s
|
|
58
58
|
return "No config.peer_token is configured" if token.strip.empty?
|
|
59
|
+
return "config.peer_token is surrounded by spaces or newlines, which breaks HTTP requests" if token != token.strip
|
|
59
60
|
return nil if token.strip.length >= MIN_TOKEN_LENGTH
|
|
60
61
|
|
|
61
62
|
"config.peer_token is shorter than #{MIN_TOKEN_LENGTH} characters, so it is ignored as if none were configured"
|
data/lib/profiler/railtie.rb
CHANGED
|
@@ -123,6 +123,13 @@ module Profiler
|
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
+
initializer "profiler.warn_cors_configuration", after: :load_config_initializers do
|
|
127
|
+
next unless Profiler.configuration.enabled
|
|
128
|
+
|
|
129
|
+
require_relative "middleware/cors_policy"
|
|
130
|
+
Profiler::Middleware::CorsPolicy.warn_about_configuration(Rails.logger)
|
|
131
|
+
end
|
|
132
|
+
|
|
126
133
|
initializer "profiler.start_cluster_client" do
|
|
127
134
|
# Check slave? inside on_load, the app's own initializers (config/initializers/profiler.rb)
|
|
128
135
|
# set master_url AFTER railtie initializers run, so the check must happen after_initialize.
|
data/lib/profiler/redaction.rb
CHANGED
|
@@ -5,6 +5,7 @@ require "set"
|
|
|
5
5
|
require "rack/utils"
|
|
6
6
|
require "active_support/parameter_filter"
|
|
7
7
|
require_relative "cluster/security"
|
|
8
|
+
require_relative "peers"
|
|
8
9
|
|
|
9
10
|
module Profiler
|
|
10
11
|
# The single filter applied to everything the profiler captures: request
|
|
@@ -289,13 +290,16 @@ module Profiler
|
|
|
289
290
|
|
|
290
291
|
private
|
|
291
292
|
|
|
292
|
-
# Only
|
|
293
|
-
#
|
|
294
|
-
#
|
|
293
|
+
# Only secrets the cluster or peers would use (long enough once stripped): a
|
|
294
|
+
# shorter one is ignored, and masking "true" or "/" everywhere would hide the
|
|
295
|
+
# very data profiled. Padded values are refused for requests but stay masked.
|
|
295
296
|
def credential_values
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
[
|
|
297
|
+
secret = Profiler.configuration.cluster_secret.to_s.strip
|
|
298
|
+
token = Profiler.configuration.peer_token.to_s.strip
|
|
299
|
+
credentials = []
|
|
300
|
+
credentials << secret if secret.length >= Cluster::Security::MIN_SECRET_LENGTH
|
|
301
|
+
credentials << token if token.length >= Peers::MIN_TOKEN_LENGTH
|
|
302
|
+
credentials
|
|
299
303
|
end
|
|
300
304
|
|
|
301
305
|
def hide_in(value, credentials)
|
data/lib/profiler/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails-profiler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.44.
|
|
4
|
+
version: 0.44.24
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sébastien Duplessy
|
|
@@ -240,6 +240,7 @@ files:
|
|
|
240
240
|
- lib/profiler/mcp/tools/set_env_var.rb
|
|
241
241
|
- lib/profiler/middleware/capturing_body.rb
|
|
242
242
|
- lib/profiler/middleware/cors_middleware.rb
|
|
243
|
+
- lib/profiler/middleware/cors_policy.rb
|
|
243
244
|
- lib/profiler/middleware/profiler_middleware.rb
|
|
244
245
|
- lib/profiler/middleware/streamed_profile.rb
|
|
245
246
|
- lib/profiler/middleware/toolbar_injector.rb
|