safer_rails_console 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e01eee1304d4e5158bd4e8b8e2be33f5959a31ae76cd644dc59c317b6c93215
4
- data.tar.gz: d2a649b163a108192a09217d4c304aec465fc889f40708fc61f40e6ecc6bbb9e
3
+ metadata.gz: dfda1cdba8b3b5ef2f7a7b4e8e5ca283a00782bdba859f6ceb5f6fc01a115600
4
+ data.tar.gz: e87adf560badb9cd83c0cb8196dfc5e28d4d10f6bfdbfb320b508653f17e2035
5
5
  SHA512:
6
- metadata.gz: 8ee6fd8693d76f321dea94000557460ad5397ad7043d232b3f31faaadbb5a1feb89da29c212f2d9a49dd3bf2deab13c275c607818ccf7802bb39cd8abc13ef50
7
- data.tar.gz: eeb1f37f6eee21057501de3607a6bc35bc6c9b9b19897eafcb30400caab1d827d10e2fc81eb79d6c7ace8a0dcf662116f74cd339da97a3a82779c00c95a9f33c
6
+ metadata.gz: 51e857275609c4b0597cec7ab9a08f88032b5479e77e94d5b57be9607de5d5d62cd62ab120ea7f3cedb0fdbec7ad751d4190a004b2f8f6bd28c0bee3daf95f14
7
+ data.tar.gz: 508b19ab2a19979b6c18a9177f224b8706730770a364e09eccd8a5270f52e20459bf8cf8c287d48b10d3c63ba7e6df8aca2598d01180b7623b1bc93361f85625
data/.circleci/config.yml CHANGED
@@ -2,14 +2,14 @@ version: 2.1
2
2
  jobs:
3
3
  lint:
4
4
  docker:
5
- - image: cimg/ruby:3.1.5
5
+ - image: cimg/ruby:3.1.6
6
6
  working_directory: ~/safer_rails_console
7
7
  steps:
8
8
  - checkout
9
9
  - restore_cache:
10
10
  keys:
11
- - v2-gems-ruby-3.1.5-{{ checksum "safer_rails_console.gemspec" }}-{{ checksum "Gemfile" }}
12
- - v2-gems-ruby-3.1.5-
11
+ - v2-gems-ruby-3.1.6-{{ checksum "safer_rails_console.gemspec" }}-{{ checksum "Gemfile" }}
12
+ - v2-gems-ruby-3.1.6-
13
13
  - run:
14
14
  name: Install Gems
15
15
  command: |
@@ -18,7 +18,7 @@ jobs:
18
18
  bundle clean
19
19
  fi
20
20
  - save_cache:
21
- key: v2-gems-ruby-3.1.5-{{ checksum "safer_rails_console.gemspec" }}-{{ checksum "Gemfile" }}
21
+ key: v2-gems-ruby-3.1.6-{{ checksum "safer_rails_console.gemspec" }}-{{ checksum "Gemfile" }}
22
22
  paths:
23
23
  - "vendor/bundle"
24
24
  - "gemfiles/vendor/bundle"
@@ -82,11 +82,15 @@ workflows:
82
82
  matrix:
83
83
  parameters:
84
84
  ruby_version:
85
- - 3.1.4
86
- - 3.2.2
87
- - 3.3.0
85
+ - 3.1.6
86
+ - 3.2.6
87
+ - 3.3.6
88
88
  gemfile:
89
89
  - gemfiles/6.1.gemfile
90
90
  - gemfiles/7.0.gemfile
91
91
  - gemfiles/7.1.gemfile
92
92
  - gemfiles/7.2.gemfile
93
+ - gemfiles/8.0.gemfile
94
+ exclude:
95
+ - ruby_version: 3.1.6
96
+ gemfile: gemfiles/8.0.gemfile
data/Appraisals CHANGED
@@ -15,3 +15,7 @@ end
15
15
  appraise '7.2' do
16
16
  gem 'rails', '~> 7.2.0'
17
17
  end
18
+
19
+ appraise '8.0' do
20
+ gem 'rails', '~> 8.0.0'
21
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.11.0
4
+ - Add support for Rails 8.0. **Thanks [@olivier-thatch](https://github.com/olivier-thatch)**
5
+
3
6
  ## v0.10.0
4
7
  - Drop support for Ruby 3.0.
5
8
  - Add support for Rails 7.2. **Thanks [@kwent](https://github.com/kwent)**
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 8.0.0"
6
+
7
+ gemspec path: "../"
@@ -24,7 +24,19 @@ module SaferRailsConsole
24
24
  raise error
25
25
  end
26
26
 
27
- module PostgreSQLAdapterPatch
27
+ # Patch for the PostgreSQL database adapter for Rails 8.0 and above.
28
+ module PostgreSQLAdapteRailsPatch
29
+ def internal_execute(...)
30
+ super
31
+ rescue StandardError => e
32
+ # rubocop:disable Layout/LineLength
33
+ SaferRailsConsole::Patches::Sandbox::AutoRollback.handle_and_reraise_exception(e, 'PG::ReadOnlySqlTransaction')
34
+ # rubocop:enable Layout/LineLength
35
+ end
36
+ end
37
+
38
+ # Patch for the PostgreSQL database adapter for Rails 6.x and 7.x.
39
+ module LegacyPostgreSQLAdapteRailsPatch
28
40
  def execute_and_clear(...)
29
41
  super
30
42
  rescue StandardError => e
@@ -35,10 +47,24 @@ module SaferRailsConsole
35
47
  end
36
48
 
37
49
  if defined?(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
38
- ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(PostgreSQLAdapterPatch)
50
+ if SaferRailsConsole::RailsVersion.eight_or_above?
51
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(PostgreSQLAdapteRailsPatch)
52
+ elsif SaferRailsConsole::RailsVersion.six_or_above?
53
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(LegacyPostgreSQLAdapteRailsPatch)
54
+ end
55
+ end
56
+
57
+ # Patch for the MySQL database adapter for Rails 8.0 and above.
58
+ module MySQLAdapterRailsPatch
59
+ def internal_execute(...)
60
+ super
61
+ rescue StandardError => e
62
+ SaferRailsConsole::Patches::Sandbox::AutoRollback.handle_and_reraise_exception(e, 'READ ONLY transaction')
63
+ end
39
64
  end
40
65
 
41
- module MySQLPatch
66
+ # Patch for the MySQL database adapter for Rails 6.x and 7.x.
67
+ module LegacyMySQLAdapterRails67Patch
42
68
  def execute_and_free(...)
43
69
  super
44
70
  rescue StandardError => e
@@ -47,7 +73,11 @@ module SaferRailsConsole
47
73
  end
48
74
 
49
75
  if defined?(::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter)
50
- ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.prepend(MySQLPatch)
76
+ if SaferRailsConsole::RailsVersion.eight_or_above?
77
+ ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.prepend(MySQLAdapterRailsPatch)
78
+ elsif SaferRailsConsole::RailsVersion.six_or_above?
79
+ ::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.prepend(LegacyMySQLAdapterRails67Patch)
80
+ end
51
81
  end
52
82
  end
53
83
  end
@@ -16,6 +16,12 @@ module SaferRailsConsole
16
16
 
17
17
  @six_or_above = SaferRailsConsole::RailsVersion::RAILS_VERSION >= ::Gem::Version.new('6.0.0')
18
18
  end
19
+
20
+ def eight_or_above?
21
+ return @eight_or_above if defined?(@eight_or_above)
22
+
23
+ @eight_or_above = SaferRailsConsole::RailsVersion::RAILS_VERSION >= ::Gem::Version.new('8.0.0')
24
+ end
19
25
  end
20
26
  end
21
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SaferRailsConsole
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.0'
5
5
  end
@@ -47,5 +47,5 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency 'rspec_junit_formatter'
48
48
  spec.add_development_dependency 'salsify_rubocop', '~> 1.27.0'
49
49
 
50
- spec.add_runtime_dependency 'rails', '>= 6.1', '< 7.3'
50
+ spec.add_runtime_dependency 'rails', '>= 6.1', '< 8.1'
51
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safer_rails_console
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify, Inc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-12 00:00:00.000000000 Z
11
+ date: 2024-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -173,7 +173,7 @@ dependencies:
173
173
  version: '6.1'
174
174
  - - "<"
175
175
  - !ruby/object:Gem::Version
176
- version: '7.3'
176
+ version: '8.1'
177
177
  type: :runtime
178
178
  prerelease: false
179
179
  version_requirements: !ruby/object:Gem::Requirement
@@ -183,7 +183,7 @@ dependencies:
183
183
  version: '6.1'
184
184
  - - "<"
185
185
  - !ruby/object:Gem::Version
186
- version: '7.3'
186
+ version: '8.1'
187
187
  description: This gem makes Rails console sessions less dangerous in specified environments
188
188
  by warning, color-coding, auto-sandboxing, and allowing read-only external connections
189
189
  (disables job queueing, non-GET requests, etc.)
@@ -211,6 +211,7 @@ files:
211
211
  - gemfiles/7.0.gemfile
212
212
  - gemfiles/7.1.gemfile
213
213
  - gemfiles/7.2.gemfile
214
+ - gemfiles/8.0.gemfile
214
215
  - lib/safer_rails_console.rb
215
216
  - lib/safer_rails_console/colors.rb
216
217
  - lib/safer_rails_console/console.rb