safer_rails_console 0.9.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: 6caeae2629c2967125e660f9982a42cdcb8be7bfeda001ef4d749c48163327fe
4
- data.tar.gz: 479df9dd872a07f3af1e743e787acc6689587ff686badcd8de9da40592b545d4
3
+ metadata.gz: dfda1cdba8b3b5ef2f7a7b4e8e5ca283a00782bdba859f6ceb5f6fc01a115600
4
+ data.tar.gz: e87adf560badb9cd83c0cb8196dfc5e28d4d10f6bfdbfb320b508653f17e2035
5
5
  SHA512:
6
- metadata.gz: 689bfbb1b371f75543b4d724fc211c3da712f5c624df301446c83b327863ab9b24edfe50f824fbf4d287b645db334714c098c0643b62a5c8ae171992afc4da65
7
- data.tar.gz: f24a500572bb7fec95dca9c875566da11eb77d3e4ba11070ff561eb8b6dedcbeff4254fef29f97a2f9d9637d1bf16b6e04f2558cda04213332a9d223afd52ee2
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.0.6
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.0.6-{{ checksum "safer_rails_console.gemspec" }}-{{ checksum "Gemfile" }}
12
- - v2-gems-ruby-3.0.6-
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.0.6-{{ 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.0.6
86
- - 3.1.4
87
- - 3.2.2
88
- - 3.3.0
85
+ - 3.1.6
86
+ - 3.2.6
87
+ - 3.3.6
89
88
  gemfile:
90
89
  - gemfiles/6.1.gemfile
91
90
  - gemfiles/7.0.gemfile
92
91
  - gemfiles/7.1.gemfile
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/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ inherit_gem:
2
2
  salsify_rubocop: conf/rubocop_rails.yml
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 3.0
5
+ TargetRubyVersion: 3.1
6
6
  Exclude:
7
7
  - 'vendor/**/*'
8
8
  - 'gemfiles/**/*'
data/Appraisals CHANGED
@@ -11,3 +11,11 @@ end
11
11
  appraise '7.1' do
12
12
  gem 'rails', '~> 7.1.2'
13
13
  end
14
+
15
+ appraise '7.2' do
16
+ gem 'rails', '~> 7.2.0'
17
+ end
18
+
19
+ appraise '8.0' do
20
+ gem 'rails', '~> 8.0.0'
21
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
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
+
6
+ ## v0.10.0
7
+ - Drop support for Ruby 3.0.
8
+ - Add support for Rails 7.2. **Thanks [@kwent](https://github.com/kwent)**
9
+
3
10
  ## v0.9.0
4
11
  - Add MySql support
5
12
 
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 7.2.0"
6
+
7
+ gemspec path: "../"
@@ -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.9.0'
4
+ VERSION = '0.11.0'
5
5
  end
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
34
  spec.require_paths = ['lib']
35
35
 
36
- spec.required_ruby_version = '>= 3.0'
36
+ spec.required_ruby_version = '>= 3.1'
37
37
 
38
38
  spec.add_development_dependency 'appraisal', '~> 2.2'
39
39
  spec.add_development_dependency 'bundler', '~> 2.0'
@@ -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.2'
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.9.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-07-15 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.2'
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.2'
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.)
@@ -210,6 +210,8 @@ files:
210
210
  - gemfiles/6.1.gemfile
211
211
  - gemfiles/7.0.gemfile
212
212
  - gemfiles/7.1.gemfile
213
+ - gemfiles/7.2.gemfile
214
+ - gemfiles/8.0.gemfile
213
215
  - lib/safer_rails_console.rb
214
216
  - lib/safer_rails_console/colors.rb
215
217
  - lib/safer_rails_console/console.rb
@@ -239,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
241
  requirements:
240
242
  - - ">="
241
243
  - !ruby/object:Gem::Version
242
- version: '3.0'
244
+ version: '3.1'
243
245
  required_rubygems_version: !ruby/object:Gem::Requirement
244
246
  requirements:
245
247
  - - ">="