safer_rails_console 0.3.0 → 0.4.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: e9f52ef5501b4906fd7f43c3a5dc3a8157dacba7da2d5cd996d1028f8d97f5fe
4
- data.tar.gz: 5d0e92eef385a29a45fb2f24eeb994bc9b5539d7ba2c01ab067bc2a35777f08f
3
+ metadata.gz: 5f61723272246766a45a0702be74e266718e55035ce8ccfa8a1c4eaab6618d28
4
+ data.tar.gz: d5d421c94e15b1fb9bfbd8d532d24ed95c9f76c8250e8620257bb95071f5e801
5
5
  SHA512:
6
- metadata.gz: d7ce0f981844828f22da23738147ca9bd35355feb5ab20971381ae0407bde0b7da3c57c2630f88aa8a382afc6a70f90fcfb818e604671a124255e921c45478ec
7
- data.tar.gz: 6ad946fb0b38d899890ef70aa5d83f15078f07782eeb56221549d5f40962f88b4db8f5e2e0dee2782c40a29922a1d273de8c722a8f75ba81282608ad275a02d9
6
+ metadata.gz: 8da50a1178203391fcc23bdd42f9970aa1ebe140cc5be1f3916a7b71ab1eaef44189d37fcb0cb6345b00960a566d01f907a226fdd4392c649c59840b95029af1
7
+ data.tar.gz: 2a97efb1bfba5e451a5cee1cf23bf9a2a6ac8d9898c164f5f58c890bb80acd0dbacb1fdb332f69c7be2eee632f3343f96247bde00ab0057b15e8526a5ad89f0d
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
 
14
14
  # Appraisal gemfile.lock
15
15
  /gemfiles/*.gemfile.lock
16
+ out
@@ -9,26 +9,23 @@ before_install:
9
9
  - gem install bundler
10
10
 
11
11
  before_script:
12
- - cp spec/internal/database.yml.travis spec/internal/rails_4_2/config/database.yml
13
12
  - cp spec/internal/database.yml.travis spec/internal/rails_5_0/config/database.yml
14
13
  - cp spec/internal/database.yml.travis spec/internal/rails_5_1/config/database.yml
15
14
  - cp spec/internal/database.yml.travis spec/internal/rails_5_2/config/database.yml
15
+ - cp spec/internal/database.yml.travis spec/internal/rails_6_0/config/database.yml
16
16
 
17
17
  script:
18
18
  - bundle exec rubocop
19
19
  - bundle exec rspec
20
20
 
21
21
  rvm:
22
- - 2.2.10
23
- - 2.3.7
24
- - 2.4.4
25
- - 2.5.1
22
+ - 2.5.6
26
23
 
27
24
  gemfile:
28
- - gemfiles/4.2.gemfile
29
25
  - gemfiles/5.0.gemfile
30
26
  - gemfiles/5.1.gemfile
31
27
  - gemfiles/5.2.gemfile
28
+ - gemfiles/6.0.gemfile
32
29
 
33
30
  matrix:
34
31
  fast_finish: true
data/Appraisals CHANGED
@@ -1,7 +1,3 @@
1
- appraise '4.2' do
2
- gem 'rails', '~> 4.2.0'
3
- end
4
-
5
1
  appraise '5.0' do
6
2
  gem 'rails', '~> 5.0.0'
7
3
  end
@@ -11,5 +7,9 @@ appraise '5.1' do
11
7
  end
12
8
 
13
9
  appraise '5.2' do
14
- gem 'rails', '~>5.2.0'
10
+ gem 'rails', '~> 5.2.0'
11
+ end
12
+
13
+ appraise '6.0' do
14
+ gem 'rails', '~> 6.0.0'
15
15
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~>5.2.0"
5
+ gem "rails", "~> 5.2.0"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.2.0"
5
+ gem "rails", "~> 6.0.0"
6
6
 
7
7
  gemspec path: "../"
@@ -1,6 +1,10 @@
1
1
  include SaferRailsConsole::Colors
2
2
 
3
- app_name = ::Rails.application.class.parent.to_s.underscore.dasherize
3
+ app_name = if SaferRailsConsole::RailsVersion.six_or_above?
4
+ ::Rails.application.class.module_parent.to_s.underscore.dasherize
5
+ else
6
+ ::Rails.application.class.parent.to_s.underscore.dasherize
7
+ end
4
8
  env_name = SaferRailsConsole.environment_name
5
9
  status = ::Rails.application.sandbox ? 'read-only' : 'writable'
6
10
  color = SaferRailsConsole.prompt_color
@@ -15,37 +15,6 @@ module SaferRailsConsole
15
15
  end
16
16
 
17
17
  module Rails
18
- module CommandsTasks4
19
- def console
20
- require_command!('console')
21
- ::Rails::Console.singleton_class.prepend(::SaferRailsConsole::Patches::Boot::SandboxFlag::Rails::Console4)
22
- super
23
- end
24
- end
25
-
26
- module Console4
27
- def parse_arguments(arguments)
28
- options = {}
29
-
30
- OptionParser.new do |opt|
31
- ::SaferRailsConsole::Patches::Boot::SandboxFlag.console_options(opt, options)
32
- opt.on('--debugger', 'Enable the debugger.') { |v| options[:debugger] = v }
33
- opt.parse!(arguments)
34
- end
35
-
36
- if arguments.first && arguments.first[0] != '-'
37
- env = arguments.first
38
- options[:environment] = if available_environments.include? env
39
- env
40
- else
41
- %w(production development test).detect { |e| e =~ /^#{env}/ } || env
42
- end
43
- end
44
-
45
- options
46
- end
47
- end
48
-
49
18
  module CommandsTasks50
50
19
  def console
51
20
  require_command!('console')
@@ -72,13 +41,10 @@ module SaferRailsConsole
72
41
  end
73
42
  end
74
43
 
75
- if SaferRailsConsole::RailsVersion.four_two?
76
- require 'rails/commands/commands_tasks'
77
- ::Rails::CommandsTasks.prepend(SaferRailsConsole::Patches::Boot::SandboxFlag::Rails::CommandsTasks4)
78
- elsif SaferRailsConsole::RailsVersion.five_zero?
44
+ if SaferRailsConsole::RailsVersion.five_zero?
79
45
  require 'rails/commands/commands_tasks'
80
46
  ::Rails::CommandsTasks.prepend(SaferRailsConsole::Patches::Boot::SandboxFlag::Rails::CommandsTasks50)
81
- elsif SaferRailsConsole::RailsVersion.five_one? || SaferRailsConsole::RailsVersion.five_two?
47
+ elsif SaferRailsConsole::RailsVersion.five_one_or_above?
82
48
  require 'rails/command'
83
49
  require 'rails/commands/console/console_command'
84
50
  # Rails 5.1 and 5.2 defaults `sandbox` to `false`, but we need it to NOT have a default value and be `nil` when it is not user-specified
@@ -25,7 +25,7 @@ module SaferRailsConsole
25
25
  end
26
26
 
27
27
  if SaferRailsConsole::RailsVersion.supported?
28
- if SaferRailsConsole::RailsVersion.five_one? || SaferRailsConsole::RailsVersion.five_two?
28
+ if SaferRailsConsole::RailsVersion.five_one_or_above?
29
29
  require 'rails/commands/console/console_command'
30
30
  else
31
31
  require 'rails/commands/console'
@@ -22,14 +22,6 @@ module SaferRailsConsole
22
22
 
23
23
  module ActiveRecord
24
24
  module ConnectionAdapters
25
- module PostgreSQLAdapter42
26
- def execute_and_clear(sql, name, binds)
27
- super
28
- rescue => e
29
- SaferRailsConsole::Patches::Sandbox::AutoRollback.handle_and_reraise_exception(e)
30
- end
31
- end
32
-
33
25
  module PostgreSQLAdapter5
34
26
  def execute_and_clear(sql, name, binds, prepare: false)
35
27
  super
@@ -45,9 +37,5 @@ module SaferRailsConsole
45
37
  end
46
38
 
47
39
  if defined?(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
48
- if SaferRailsConsole::RailsVersion.four_two?
49
- ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(SaferRailsConsole::Patches::Sandbox::AutoRollback::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter42)
50
- else
51
- ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(SaferRailsConsole::Patches::Sandbox::AutoRollback::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter5)
52
- end
40
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(SaferRailsConsole::Patches::Sandbox::AutoRollback::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter5)
53
41
  end
@@ -6,12 +6,7 @@ module SaferRailsConsole
6
6
 
7
7
  class << self
8
8
  def supported?
9
- four_two? || five_zero? || five_one? || five_two?
10
- end
11
-
12
- def four_two?
13
- @is_four_two = Gem::Requirement.new('~> 4.2.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_four_two.nil?
14
- @is_four_two
9
+ five_zero? || five_one? || five_two? || six_zero?
15
10
  end
16
11
 
17
12
  def five_zero?
@@ -24,10 +19,25 @@ module SaferRailsConsole
24
19
  @is_five_one
25
20
  end
26
21
 
22
+ def five_one_or_above?
23
+ @is_five_one_or_above = SaferRailsConsole::RailsVersion::RAILS_VERSION >= ::Gem::Version.new('5.1.0') if @is_five_one_or_above.nil?
24
+ @is_five_one_or_above
25
+ end
26
+
27
27
  def five_two?
28
28
  @is_five_two = Gem::Requirement.new('~> 5.2.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_five_two.nil?
29
29
  @is_five_two
30
30
  end
31
+
32
+ def six_zero?
33
+ @is_six_zero = Gem::Requirement.new('~> 6.0.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_six_zero.nil?
34
+ @is_six_zero
35
+ end
36
+
37
+ def six_or_above?
38
+ @is_six_or_above = SaferRailsConsole::RailsVersion::RAILS_VERSION >= ::Gem::Version.new('6.0.0') if @is_six_or_above.nil?
39
+ @is_six_or_above
40
+ end
31
41
  end
32
42
  end
33
43
  end
@@ -1,3 +1,3 @@
1
1
  module SaferRailsConsole
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
@@ -31,14 +31,13 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ['lib']
32
32
 
33
33
  spec.add_development_dependency 'appraisal', '~> 2.2'
34
- spec.add_development_dependency 'bundler', '~> 1.15'
34
+ spec.add_development_dependency 'bundler', '~> 2.0'
35
35
  spec.add_development_dependency 'mixlib-shellout', '~> 2.2'
36
36
  spec.add_development_dependency 'overcommit', '~> 0.39.0'
37
- spec.add_development_dependency 'pg', '~> 0.21'
37
+ spec.add_development_dependency 'pg', '~> 1.1'
38
38
  spec.add_development_dependency 'rake', '~> 12.0'
39
39
  spec.add_development_dependency 'rspec', '~> 3.6'
40
40
  spec.add_development_dependency 'salsify_rubocop', '~> 0.48.0'
41
- spec.add_development_dependency 'sqlite3', '~> 1.3'
42
41
  spec.add_development_dependency 'wwtd', '~> 1.3'
43
- spec.add_runtime_dependency 'rails', '>= 4.2', '< 5.3'
42
+ spec.add_runtime_dependency 'rails', '>= 5.0', '< 6.1'
44
43
  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.3.0
4
+ version: 0.4.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: 2018-04-16 00:00:00.000000000 Z
11
+ date: 2019-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.15'
33
+ version: '2.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.15'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mixlib-shellout
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.21'
75
+ version: '1.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.21'
82
+ version: '1.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +122,6 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.48.0
125
- - !ruby/object:Gem::Dependency
126
- name: sqlite3
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '1.3'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '1.3'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: wwtd
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -156,20 +142,20 @@ dependencies:
156
142
  requirements:
157
143
  - - ">="
158
144
  - !ruby/object:Gem::Version
159
- version: '4.2'
145
+ version: '5.0'
160
146
  - - "<"
161
147
  - !ruby/object:Gem::Version
162
- version: '5.3'
148
+ version: '6.1'
163
149
  type: :runtime
164
150
  prerelease: false
165
151
  version_requirements: !ruby/object:Gem::Requirement
166
152
  requirements:
167
153
  - - ">="
168
154
  - !ruby/object:Gem::Version
169
- version: '4.2'
155
+ version: '5.0'
170
156
  - - "<"
171
157
  - !ruby/object:Gem::Version
172
- version: '5.3'
158
+ version: '6.1'
173
159
  description: This gem makes Rails console sessions less dangerous in specified environments
174
160
  by warning, color-coding, auto-sandboxing, and allowing read-only external connections
175
161
  (disables job queueing, non-GET requests, etc.)
@@ -192,10 +178,10 @@ files:
192
178
  - Rakefile
193
179
  - bin/console
194
180
  - bin/setup
195
- - gemfiles/4.2.gemfile
196
181
  - gemfiles/5.0.gemfile
197
182
  - gemfiles/5.1.gemfile
198
183
  - gemfiles/5.2.gemfile
184
+ - gemfiles/6.0.gemfile
199
185
  - lib/safer_rails_console.rb
200
186
  - lib/safer_rails_console/colors.rb
201
187
  - lib/safer_rails_console/console.rb
@@ -231,8 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
217
  - !ruby/object:Gem::Version
232
218
  version: '0'
233
219
  requirements: []
234
- rubyforge_project:
235
- rubygems_version: 2.7.6
220
+ rubygems_version: 3.0.3
236
221
  signing_key:
237
222
  specification_version: 4
238
223
  summary: Make rails console less dangerous!