rails_error_dashboard 0.14.1 → 0.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8dc068309c56704b429f7798ce4c3c83b628853179ebc2695c50fa684d2fae9
4
- data.tar.gz: 64e3a06e8b60ce8f4c3fe649ca750f228a16e64405b7e239b8440f53e74e536d
3
+ metadata.gz: 93c0e9e0f21298eb85db1d661793709d60158c5f2c6f85b164da36b4593525ee
4
+ data.tar.gz: 37bae1ddaca2d502e434e0b4e6e95f6c755619598dec20f08495ce13fd0c286a
5
5
  SHA512:
6
- metadata.gz: b8605107393952d4e308ebb23f5c1a58ac88dafc9a9664c2429ddb83777a450cb148c1890b25495166a51238d954320bdfcba4b2ef265fe63e8ffea960fb91df
7
- data.tar.gz: 4ab62e966ce41257abefdb37e6e3f14a6ae732754cac9ef6c4a4ed37af14982f825e90dac17e8681274959d11ec74bf403458a96ee3069af5919def63b7d77e5
6
+ metadata.gz: 9c6be20b1be293c069516ed0f5f6fc19e46203224bb9aaad6be1c645f45ebb3455e03e6b3fef8d8738e4cc658dc928cd56c9f2d403d270ec6caaaa74411074b7
7
+ data.tar.gz: 7c1c344be4398b47faf98de6a9be675f41a86878b49404d76b73d1a5be91f046ded677c70ebb9c1f4118e8736873ea491edcfed07b6520465049b9ecb3e1066b
@@ -314,6 +314,15 @@ module RailsErrorDashboard
314
314
  expected_password = RailsErrorDashboard.configuration.dashboard_password
315
315
  next false if expected_username.nil? || expected_password.nil?
316
316
 
317
+ # A blank credential must deny everyone too: "" would equal an empty login.
318
+ next false if RailsErrorDashboard::Configuration.blank_credential?(expected_username) ||
319
+ RailsErrorDashboard::Configuration.blank_credential?(expected_password)
320
+
321
+ # The boot check refuses the published credentials outside development
322
+ # and test, but it is skipped while SECRET_KEY_BASE_DUMMY is set. Refuse
323
+ # them here as well, so that variable left set at runtime reopens nothing.
324
+ next false if RailsErrorDashboard.configuration.refuse_default_credentials?
325
+
317
326
  # Non-short-circuit & on purpose: both comparisons always run, so the
318
327
  # response time does not reveal which half was wrong.
319
328
  ActiveSupport::SecurityUtils.secure_compare(username.to_s, expected_username.to_s) &
@@ -23,7 +23,7 @@ ja:
23
23
  '30': 30日間
24
24
  '90': 90日間
25
25
  frame_category:
26
- app: 自分のコード
26
+ app: アプリケーションコード
27
27
  gem: Gem
28
28
  framework: Rails フレームワーク
29
29
  ruby_core: Ruby コア
@@ -520,7 +520,7 @@ ja:
520
520
  user_agent: 'User Agent:'
521
521
  ip_address: 'IP アドレス:'
522
522
  replay: 'リクエストの再現:'
523
- raw_user_agent: User Agent の生データ
523
+ raw_user_agent: User Agent 文字列
524
524
  duration_seconds: "%{value}秒"
525
525
  duration_ms: "%{value}ミリ秒"
526
526
  copy_curl: curl としてコピー
@@ -530,7 +530,7 @@ ja:
530
530
  snapshot: 'スナップショット:'
531
531
  snapshot_captured_html: '%{time} に取得'
532
532
  snapshot_stale: より前の発生から取得 — それ以降の発生はコンテキストを伴いませんでした
533
- snapshot_fidelity_lite: 縮小された取得 (storm 保護によりコンテキストの payload が破棄されました)
533
+ snapshot_fidelity_lite: 限定的な情報取得(storm 保護によりコンテキストの payload を省略)
534
534
  snapshot_fidelity_minimal: storm 中にカウントされました — コンテキストは取得されていません
535
535
  snapshot_fidelity_partial: 混在したスナップショット — 一部のフィールドは以前の発生時のものです
536
536
  snapshot_unknown: RED がスナップショットの出所を記録する前に取得されました
@@ -667,10 +667,10 @@ ja:
667
667
  backtrace: Backtrace
668
668
  backtrace:
669
669
  label: 'Backtrace:'
670
- frame_counts: "(自分のコード%{app}件、フレームワーク/gem %{framework}件)"
670
+ frame_counts: "(アプリケーションコード%{app}件、フレームワーク/gem %{framework}件)"
671
671
  copy_full: Backtrace 全体をコピー
672
672
  copy_full_title: Backtrace 全体をコピー
673
- your_code: 自分のコード
673
+ your_code: アプリケーションコード
674
674
  framework_code: フレームワーク・gem のコード
675
675
  frames:
676
676
  other: "%{count}フレーム"
@@ -2,6 +2,12 @@
2
2
 
3
3
  module RailsErrorDashboard
4
4
  class Configuration
5
+ # The built-in Basic auth credentials. They are published (README, demo,
6
+ # gemspec), so outside development and test they are refused unless
7
+ # ERROR_DASHBOARD_PASSWORD explicitly supplies the password.
8
+ DEFAULT_DASHBOARD_USERNAME = "gandalf"
9
+ DEFAULT_DASHBOARD_PASSWORD = "youshallnotpass"
10
+
5
11
  # Dashboard authentication (always required)
6
12
  attr_accessor :dashboard_username
7
13
  attr_accessor :dashboard_password
@@ -269,8 +275,8 @@ module RailsErrorDashboard
269
275
 
270
276
  def initialize
271
277
  # Default values - Authentication is ALWAYS required
272
- @dashboard_username = ENV.fetch("ERROR_DASHBOARD_USER", "gandalf")
273
- @dashboard_password = ENV.fetch("ERROR_DASHBOARD_PASSWORD", "youshallnotpass")
278
+ @dashboard_username = ENV.fetch("ERROR_DASHBOARD_USER", DEFAULT_DASHBOARD_USERNAME)
279
+ @dashboard_password = ENV.fetch("ERROR_DASHBOARD_PASSWORD", DEFAULT_DASHBOARD_PASSWORD)
274
280
  @authenticate_with = nil
275
281
 
276
282
  @user_model = nil # Auto-detect if not set
@@ -536,12 +542,16 @@ module RailsErrorDashboard
536
542
  # (GHSA-qhgm-3pxf-mvc6). Every future environment name a team invents is
537
543
  # now refused by default and has to be added here on purpose.
538
544
  #
539
- # Skip during asset precompilation (SECRET_KEY_BASE_DUMMY=1) — ENV vars aren't available at build time
540
- if default_credentials? &&
541
- defined?(Rails) && Rails.respond_to?(:env) &&
542
- !Rails.env.development? && !Rails.env.test? &&
543
- ENV["SECRET_KEY_BASE_DUMMY"].blank?
544
- errors << "Default or blank credentials cannot be used in #{Rails.env}. Only development and test may run on the built-in credentials. Set ERROR_DASHBOARD_USER and ERROR_DASHBOARD_PASSWORD environment variables, or use authenticate_with for custom auth."
545
+ # Skip during asset precompilation (SECRET_KEY_BASE_DUMMY=1) — ENV vars aren't available at build time.
546
+ # The login refuses the same credentials on its own, so SECRET_KEY_BASE_DUMMY
547
+ # left set at runtime does not reopen them.
548
+ if refuse_default_credentials? && ENV["SECRET_KEY_BASE_DUMMY"].blank?
549
+ reason = if credentials_problem == :blank
550
+ "the dashboard username or password is blank"
551
+ else
552
+ "the dashboard password is the published default and was not set by ERROR_DASHBOARD_PASSWORD"
553
+ end
554
+ errors << "Default or blank credentials cannot be used in #{Rails.env}: #{reason}. Only development and test may run on the built-in credentials. Set ERROR_DASHBOARD_USER and ERROR_DASHBOARD_PASSWORD environment variables and make sure the initializer does not overwrite them, or use authenticate_with for custom auth."
545
555
  end
546
556
 
547
557
  # Validate sampling_rate (must be between 0.0 and 1.0)
@@ -925,23 +935,65 @@ module RailsErrorDashboard
925
935
  list.empty? ? nil : list
926
936
  end
927
937
 
928
- # Check if using default or blank demo credentials with basic auth
938
+ # Why the Basic auth credentials cannot be trusted outside development and
939
+ # test, or nil when they can.
929
940
  #
930
- # Returns false if the user explicitly set ENV vars (even to the same default values),
931
- # because that's a deliberate choice. Only blocks when credentials are untouched defaults
932
- # or blank.
941
+ # - :blank - the username or password is empty or whitespace. An explicitly
942
+ # empty variable is not a choice: a compose file passing an unset variable
943
+ # through produces exactly that, and "" would match an empty login.
944
+ # - :published_password - the password is the published default and did not
945
+ # come from ERROR_DASHBOARD_PASSWORD. Setting that variable, even to the
946
+ # default, is a deliberate choice (the live demo runs that way). It has to
947
+ # be THAT variable: setting only ERROR_DASHBOARD_USER used to leave the
948
+ # password on the published default, and an initializer can hardcode it.
933
949
  #
934
- # @return [Boolean] true if basic auth is active with untouched default or blank credentials
935
- def default_credentials?
936
- return false unless authenticate_with.nil?
950
+ # Both compare values the way the login does, with to_s: a Symbol holding the
951
+ # published password logs in just the same.
952
+ #
953
+ # @return [Symbol, nil]
954
+ def credentials_problem
955
+ return :blank if self.class.blank_credential?(dashboard_username) ||
956
+ self.class.blank_credential?(dashboard_password)
957
+
958
+ if dashboard_password.to_s == DEFAULT_DASHBOARD_PASSWORD &&
959
+ ENV["ERROR_DASHBOARD_PASSWORD"] != DEFAULT_DASHBOARD_PASSWORD
960
+ return :published_password
961
+ end
937
962
 
938
- # If user explicitly set ENV vars, respect their choice
939
- return false if ENV.key?("ERROR_DASHBOARD_USER") || ENV.key?("ERROR_DASHBOARD_PASSWORD")
963
+ nil
964
+ end
940
965
 
941
- default = dashboard_username == "gandalf" && dashboard_password == "youshallnotpass"
942
- blank = dashboard_username.to_s.strip.empty? || dashboard_password.to_s.strip.empty?
966
+ # True for a credential that cannot be a secret: nil, empty, or only
967
+ # whitespace, including Unicode whitespace such as a no-break space, which
968
+ # String#strip leaves in place. The boot check and the login both use it.
969
+ #
970
+ # @return [Boolean]
971
+ def self.blank_credential?(value)
972
+ value.to_s.blank?
973
+ end
974
+
975
+ # Check if basic auth is active with blank credentials or the published
976
+ # default password (see #credentials_problem)
977
+ #
978
+ # Basic auth is active whenever authenticate_with is falsy, not only nil:
979
+ # the login falls back to it for `false` too, which is what
980
+ # `Rails.env.production? && -> { ... }` evaluates to in staging.
981
+ #
982
+ # @return [Boolean]
983
+ def default_credentials?
984
+ !authenticate_with && !credentials_problem.nil?
985
+ end
986
+
987
+ # True where default_credentials? has to stop the dashboard: anywhere that is
988
+ # not local development or test. The boot check and the login both use it,
989
+ # so the login still refuses when the boot check was skipped.
990
+ #
991
+ # @return [Boolean]
992
+ def refuse_default_credentials?
993
+ return false unless default_credentials?
994
+ return false unless defined?(Rails) && Rails.respond_to?(:env)
943
995
 
944
- default || blank
996
+ !Rails.env.development? && !Rails.env.test?
945
997
  end
946
998
 
947
999
  # Resolve the effective issue tracker provider (auto-detect from git_repository_url).
@@ -1,3 +1,3 @@
1
1
  module RailsErrorDashboard
2
- VERSION = "0.14.1"
2
+ VERSION = "0.14.2"
3
3
  end
@@ -171,14 +171,19 @@ namespace :error_dashboard do
171
171
  if config.authenticate_with
172
172
  puts "OK (custom authentication)"
173
173
  checks_passed += 1
174
- elsif config.dashboard_username == "gandalf" && config.dashboard_password == "youshallnotpass"
175
- if Rails.env.production?
176
- puts "WARNING - using default credentials in production!"
174
+ elsif (problem = config.credentials_problem)
175
+ # Same rule and environment allowlist as the boot check in validate!
176
+ label = problem == :blank ? "blank credentials" : "default credentials"
177
+ if config.refuse_default_credentials?
178
+ puts "WARNING - #{label} outside development and test!"
177
179
  checks_failed += 1
178
180
  else
179
- puts "OK (default credentials - change before production)"
181
+ puts "OK (#{label} - change before production)"
180
182
  warnings += 1
181
183
  end
184
+ elsif config.dashboard_password == RailsErrorDashboard::Configuration::DEFAULT_DASHBOARD_PASSWORD
185
+ puts "OK (the published default password, set explicitly by ERROR_DASHBOARD_PASSWORD)"
186
+ warnings += 1
182
187
  else
183
188
  puts "OK (custom credentials)"
184
189
  checks_passed += 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_error_dashboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anjan Jagirdar
@@ -599,7 +599,7 @@ metadata:
599
599
  funding_uri: https://github.com/sponsors/AnjanJ
600
600
  post_install_message: |
601
601
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
602
- RED (Rails Error Dashboard) v0.14.1
602
+ RED (Rails Error Dashboard) v0.14.2
603
603
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
604
604
 
605
605
  First install: