safer_rails_console 0.10.0 → 0.11.0
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/.circleci/config.yml +11 -7
- data/Appraisals +4 -0
- data/CHANGELOG.md +3 -0
- data/gemfiles/8.0.gemfile +7 -0
- data/lib/safer_rails_console/patches/sandbox/auto_rollback.rb +34 -4
- data/lib/safer_rails_console/rails_version.rb +6 -0
- data/lib/safer_rails_console/version.rb +1 -1
- data/safer_rails_console.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfda1cdba8b3b5ef2f7a7b4e8e5ca283a00782bdba859f6ceb5f6fc01a115600
|
4
|
+
data.tar.gz: e87adf560badb9cd83c0cb8196dfc5e28d4d10f6bfdbfb320b508653f17e2035
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
- 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.
|
12
|
-
- v2-gems-ruby-3.1.
|
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.
|
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.
|
86
|
-
- 3.2.
|
87
|
-
- 3.3.
|
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
data/CHANGELOG.md
CHANGED
@@ -24,7 +24,19 @@ module SaferRailsConsole
|
|
24
24
|
raise error
|
25
25
|
end
|
26
26
|
|
27
|
-
|
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
|
-
::
|
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
|
-
|
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
|
-
::
|
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
|
data/safer_rails_console.gemspec
CHANGED
@@ -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', '<
|
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.
|
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-
|
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: '
|
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: '
|
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
|