safer_rails_console 0.2.0 → 0.5.1

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
- SHA1:
3
- metadata.gz: fdba797ed52f07225b6f16b76e99a9dac4731b4b
4
- data.tar.gz: 7ecdb4551bb8c70d3d01d7aa964198cb667ed852
2
+ SHA256:
3
+ metadata.gz: a72dc87254b563b3550b58ad3ca7e579d747febbf46b9aac3aeba9386686c552
4
+ data.tar.gz: 6a152d59202737f419716eb1246e4059dc5446642a0b9d2672720a6685f4b54e
5
5
  SHA512:
6
- metadata.gz: c792c0b4684d712180eb6a963144faf05a68a28bc9565725b71987f17c8bff788362f839219faf2945952fcb025ac4ee9d76287cd0eff660882617b8c798020d
7
- data.tar.gz: 5cda5a4537478ab21d1cbce6629e081e33864d650a9eb56c932c50c7e673efce188c114f6447c71c67041901d14159f4534f46005938f3b483b8551cbecb7787
6
+ metadata.gz: fa8eb4f6f403c5fc50eb079b762232dc5e797edaa80aec15714f33fbe2f5af724efe874e30f5c0bd0286186c62e1516fb90583e14a8d5ebbeeb3de6f61465959
7
+ data.tar.gz: 0f3446376ef66b7b6a6bcaa8d6c51e94973e3888bda683ea44bced0885cd7895a9ac70ef348f51459ab5b0c22a31db1cc26a6726010fbab8805cfd8986b1af8a
@@ -0,0 +1,86 @@
1
+ version: 2.1
2
+ jobs:
3
+ lint:
4
+ docker:
5
+ - image: salsify/ruby_ci:2.5.8
6
+ working_directory: ~/safer_rails_console
7
+ steps:
8
+ - checkout
9
+ - restore_cache:
10
+ keys:
11
+ - v2-gems-ruby-2.5.8-{{ checksum "safer_rails_console.gemspec" }}-{{ checksum "Gemfile" }}
12
+ - v2-gems-ruby-2.5.8-
13
+ - run:
14
+ name: Install Gems
15
+ command: |
16
+ if ! bundle check --path=vendor/bundle; then
17
+ bundle install --path=vendor/bundle --jobs=4 --retry=3
18
+ bundle clean
19
+ fi
20
+ - save_cache:
21
+ key: v2-gems-ruby-2.5.8-{{ checksum "safer_rails_console.gemspec" }}-{{ checksum "Gemfile" }}
22
+ paths:
23
+ - "vendor/bundle"
24
+ - "gemfiles/vendor/bundle"
25
+ - run:
26
+ name: Run Rubocop
27
+ command: bundle exec rubocop
28
+ test:
29
+ parameters:
30
+ ruby_version:
31
+ type: string
32
+ gemfile:
33
+ type: string
34
+ docker:
35
+ - image: salsify/ruby_ci:<< parameters.ruby_version >>
36
+ environment:
37
+ CIRCLE_TEST_REPORTS: "test-results"
38
+ BUNDLE_GEMFILE: "/home/circleci/safer_rails_console/<< parameters.gemfile >>"
39
+ - image: circleci/postgres:9.6
40
+ environment:
41
+ POSTGRES_USER: "circleci"
42
+ POSTGRES_DB: "safer_rails_console_test"
43
+ POSTGRES_HOST_AUTH_METHOD: "trust"
44
+ working_directory: ~/safer_rails_console
45
+ steps:
46
+ - checkout
47
+ - restore_cache:
48
+ keys:
49
+ - v2-gems-ruby-<< parameters.ruby_version >>-{{ checksum "safer_rails_console.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
50
+ - v2-gems-ruby-<< parameters.ruby_version >>-
51
+ - run:
52
+ name: Install Gems
53
+ command: |
54
+ if ! bundle check --path=vendor/bundle; then
55
+ bundle install --path=vendor/bundle --jobs=4 --retry=3
56
+ bundle clean
57
+ fi
58
+ - save_cache:
59
+ key: v2-gems-ruby-<< parameters.ruby_version >>-{{ checksum "safer_rails_console.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
60
+ paths:
61
+ - "vendor/bundle"
62
+ - "gemfiles/vendor/bundle"
63
+ - run:
64
+ name: Run Tests
65
+ command: |
66
+ bundle exec rspec --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/rspec/junit.xml --format progress spec
67
+ - store_test_results:
68
+ path: "test-results"
69
+ workflows:
70
+ build:
71
+ jobs:
72
+ - lint
73
+ - test:
74
+ ruby_version: "2.5.8"
75
+ matrix:
76
+ parameters:
77
+ gemfile:
78
+ - "gemfiles/5.0.gemfile"
79
+ - "gemfiles/5.1.gemfile"
80
+ - "gemfiles/5.2.gemfile"
81
+ - "gemfiles/6.0.gemfile"
82
+ - "gemfiles/6.1.gemfile"
83
+ - test:
84
+ name: 'ruby-3.0.0'
85
+ ruby_version: "3.0.0"
86
+ gemfile: "gemfiles/6.1.gemfile"
data/.gitignore CHANGED
@@ -13,3 +13,5 @@
13
13
 
14
14
  # Appraisal gemfile.lock
15
15
  /gemfiles/*.gemfile.lock
16
+ out
17
+ *.sqlite3
@@ -1,2 +1,11 @@
1
1
  inherit_gem:
2
2
  salsify_rubocop: conf/rubocop_rails.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.4
6
+ Exclude:
7
+ - 'vendor/**/*'
8
+ - 'gemfiles/vendor/**/*'
9
+
10
+ Style/FrozenStringLiteralComment:
11
+ Enabled: true
data/Appraisals CHANGED
@@ -1,10 +1,4 @@
1
- appraise '4.1' do
2
- gem 'rails', '~> 4.1.0'
3
- end
4
-
5
- appraise '4.2' do
6
- gem 'rails', '~> 4.2.0'
7
- end
1
+ # frozen_string_literal: true
8
2
 
9
3
  appraise '5.0' do
10
4
  gem 'rails', '~> 5.0.0'
@@ -13,3 +7,15 @@ end
13
7
  appraise '5.1' do
14
8
  gem 'rails', '~> 5.1.0'
15
9
  end
10
+
11
+ appraise '5.2' do
12
+ gem 'rails', '~> 5.2.0'
13
+ end
14
+
15
+ appraise '6.0' do
16
+ gem 'rails', '~> 6.0.0'
17
+ end
18
+
19
+ appraise '6.1' do
20
+ gem 'rails', '~> 6.1.0'
21
+ end
@@ -1,6 +1,60 @@
1
- # Change Log
1
+ # Changelog
2
+
3
+ ## [v0.5.1](https://github.com/salsify/safer_rails_console/tree/v0.5.0) (2020-01-29)
4
+
5
+ [Full Changelog](https://github.com/salsify/safer_rails_console/compare/v0.5.0...v0.5.1)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Ruby 3 Support [\#39](https://github.com/salsify/safer_rails_console/pull/39) ([kphelps](https://github.com/kphelps))
10
+
11
+ ## [v0.5.0](https://github.com/salsify/safer_rails_console/tree/v0.5.0) (2020-12-15)
12
+
13
+ [Full Changelog](https://github.com/salsify/safer_rails_console/compare/v0.4.1...v0.5.0)
14
+
15
+ **Merged pull requests:**
16
+
17
+ - Enable frozen string literals cop [\#36](https://github.com/salsify/safer_rails_console/pull/36) ([jturkel](https://github.com/jturkel))
18
+ - Rails 6.1 Support [\#35](https://github.com/salsify/safer_rails_console/pull/35) ([jturkel](https://github.com/jturkel))
19
+ - Migrate to CircleCI [\#34](https://github.com/salsify/safer_rails_console/pull/34) ([jturkel](https://github.com/jturkel))
20
+
21
+ ## [v0.4.1](https://github.com/salsify/safer_rails_console/tree/v0.4.1) (2020-10-13)
22
+
23
+ [Full Changelog](https://github.com/salsify/safer_rails_console/compare/v0.4.0...v0.4.1)
24
+
25
+ **Closed issues:**
26
+
27
+ - No default settings for rails 5.1 and 5.2 [\#29](https://github.com/salsify/safer_rails_console/issues/29)
28
+
29
+ **Merged pull requests:**
30
+
31
+ - Bump version v0.4.1 [\#33](https://github.com/salsify/safer_rails_console/pull/33) ([alexsalsify](https://github.com/alexsalsify))
32
+ - Add support for config values from ENV variables [\#32](https://github.com/salsify/safer_rails_console/pull/32) ([alexsalsify](https://github.com/alexsalsify))
33
+
34
+ ## [v0.4.0](https://github.com/salsify/safer_rails_console/tree/v0.4.0) (2019-09-19)
35
+
36
+ [Full Changelog](https://github.com/salsify/safer_rails_console/compare/v0.3.0...v0.4.0)
37
+
38
+ **Closed issues:**
39
+
40
+ - safer\_rails\_console breaks newrelic reporting [\#23](https://github.com/salsify/safer_rails_console/issues/23)
41
+
42
+ **Merged pull requests:**
43
+
44
+ - Use Postgres for local development too [\#28](https://github.com/salsify/safer_rails_console/pull/28) ([jturkel](https://github.com/jturkel))
45
+ - Rails 6.0 support [\#27](https://github.com/salsify/safer_rails_console/pull/27) ([jturkel](https://github.com/jturkel))
46
+ - Drop Rails 4.2 support [\#26](https://github.com/salsify/safer_rails_console/pull/26) ([jturkel](https://github.com/jturkel))
47
+
48
+ ## [v0.3.0](https://github.com/salsify/safer_rails_console/tree/v0.3.0) (2018-04-16)
49
+
50
+ [Full Changelog](https://github.com/salsify/safer_rails_console/compare/v0.2.0...v0.3.0)
51
+
52
+ **Merged pull requests:**
53
+
54
+ - Add support for Rails 5.2; remove support for Rails 4.1 [\#24](https://github.com/salsify/safer_rails_console/pull/24) ([timothysu](https://github.com/timothysu))
2
55
 
3
56
  ## [v0.2.0](https://github.com/salsify/safer_rails_console/tree/v0.2.0) (2017-09-07)
57
+
4
58
  [Full Changelog](https://github.com/salsify/safer_rails_console/compare/v0.1.4...v0.2.0)
5
59
 
6
60
  **Implemented enhancements:**
@@ -15,6 +69,7 @@
15
69
  - Change 'sandboxed' and 'unsandboxed' to 'read-only' and 'writable' and add respective flags [\#20](https://github.com/salsify/safer_rails_console/pull/20) ([timothysu](https://github.com/timothysu))
16
70
 
17
71
  ## [v0.1.4](https://github.com/salsify/safer_rails_console/tree/v0.1.4) (2017-08-15)
72
+
18
73
  [Full Changelog](https://github.com/salsify/safer_rails_console/compare/v0.1.3...v0.1.4)
19
74
 
20
75
  **Fixed bugs:**
@@ -27,6 +82,7 @@
27
82
  - Patch PostgreSQLAdapter\#execute\_and\_clear instead of AbstractAdapter\#log for auto-rollback [\#15](https://github.com/salsify/safer_rails_console/pull/15) ([timothysu](https://github.com/timothysu))
28
83
 
29
84
  ## [v0.1.3](https://github.com/salsify/safer_rails_console/tree/v0.1.3) (2017-08-02)
85
+
30
86
  [Full Changelog](https://github.com/salsify/safer_rails_console/compare/v0.1.2...v0.1.3)
31
87
 
32
88
  **Fixed bugs:**
@@ -39,6 +95,7 @@
39
95
  - Resolve sqlite3 dependency warning [\#11](https://github.com/salsify/safer_rails_console/pull/11) ([timothysu](https://github.com/timothysu))
40
96
 
41
97
  ## [v0.1.2](https://github.com/salsify/safer_rails_console/tree/v0.1.2) (2017-07-21)
98
+
42
99
  [Full Changelog](https://github.com/salsify/safer_rails_console/compare/v0.1.1...v0.1.2)
43
100
 
44
101
  **Merged pull requests:**
@@ -46,6 +103,7 @@
46
103
  - Dasherize the app name given CamelCase [\#10](https://github.com/salsify/safer_rails_console/pull/10) ([timothysu](https://github.com/timothysu))
47
104
 
48
105
  ## [v0.1.1](https://github.com/salsify/safer_rails_console/tree/v0.1.1) (2017-07-07)
106
+
49
107
  [Full Changelog](https://github.com/salsify/safer_rails_console/compare/v0.1.0...v0.1.1)
50
108
 
51
109
  **Fixed bugs:**
@@ -57,10 +115,13 @@
57
115
  - Add support for Spring [\#8](https://github.com/salsify/safer_rails_console/pull/8) ([timothysu](https://github.com/timothysu))
58
116
 
59
117
  ## [v0.1.0](https://github.com/salsify/safer_rails_console/tree/v0.1.0) (2017-06-26)
118
+
119
+ [Full Changelog](https://github.com/salsify/safer_rails_console/compare/baddba2bc069bc6d72e779d8c157e19d26b30fc1...v0.1.0)
120
+
60
121
  **Merged pull requests:**
61
122
 
62
123
  - Initial Implementation [\#2](https://github.com/salsify/safer_rails_console/pull/2) ([timothysu](https://github.com/timothysu))
63
124
 
64
125
 
65
126
 
66
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
127
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in safer_rails_console.gemspec
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # SaferRailsConsole [![Build Status](https://travis-ci.org/salsify/safer_rails_console.svg?branch=master)](https://travis-ci.org/salsify/safer_rails_console)
1
+ # SaferRailsConsole
2
+
3
+ [![Build Status](https://circleci.com/gh/salsify/safer_rails_console.svg?style=svg)](https://circleci.com/gh/salsify/safer_rails_console)
4
+ [![Gem Version](https://badge.fury.io/rb/safer_rails_console.svg)](https://badge.fury.io/rb/safer_rails_console)
2
5
 
3
6
  This gem makes Rails console sessions less dangerous in specified environments by warning, color-coding, auto-sandboxing, and allowing read-only external connections (disables job queueing, non-GET requests, etc.)
4
7
 
@@ -73,6 +76,24 @@ config.safer_rails_console.warn_text = "WARNING: YOU ARE USING RAILS CONSOLE IN
73
76
  'Make sure you know what you\'re doing.'
74
77
  ```
75
78
 
79
+ configuration settings can also be overridden using ENV variables. The following ENV vars can be used:
80
+ ```
81
+ # Set the color prompt to a new color. See colors.rb for a listing of supported colors.
82
+ SAFER_RAILS_CONSOLE_PROMPT_COLOR=red/yellow/green
83
+
84
+ # Set the short name for the rails console prompt
85
+ SAFER_RAILS_CONSOLE_ENVIRONMENT_NAME=short-name
86
+
87
+ # Set the warning text to be displayed when warning for the environments rails consoled is enabled
88
+ SAFER_RAILS_CONSOLE_WARN_TEXT=New warning prompt text
89
+
90
+ # Enable or disable sandboxing of the rails console
91
+ SAFER_RAILS_CONSOLE_SANDBOX_ENVIRONMENT=true/false
92
+
93
+ # Enable or disable warning prompt of the rails console
94
+ SAFER_RAILS_CONSOLE_WARN_ENVIRONMENT=true/false
95
+ ```
96
+
76
97
  ## Development
77
98
 
78
99
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `wwtd` to simulate the entire build matrix (ruby version / rails version) or `appraisal` to test against each supported rails version with your active ruby version. Run `rubocop` to check for style.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'rails'
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "safer_rails_console"
4
+ require 'bundler/setup'
5
+ require 'safer_rails_console'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "safer_rails_console"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.1.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: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 6.1.0"
6
+
7
+ gemspec path: "../"
@@ -1,25 +1,52 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'safer_rails_console/version'
2
4
  require 'safer_rails_console/railtie'
3
5
  require 'safer_rails_console/colors'
4
6
  require 'safer_rails_console/rails_version'
5
7
  require 'safer_rails_console/console'
8
+ require 'active_model/type'
6
9
 
7
10
  module SaferRailsConsole
8
11
  class << self
9
12
  def environment_name
10
- config.environment_names.key?(::Rails.env.downcase) ? config.environment_names[::Rails.env.downcase] : 'unknown env'
13
+ if ENV.key?('SAFER_RAILS_CONSOLE_ENVIRONMENT_NAME')
14
+ ENV['SAFER_RAILS_CONSOLE_ENVIRONMENT_NAME']
15
+ else
16
+ config.environment_names.key?(::Rails.env.downcase) ? config.environment_names[::Rails.env.downcase] : 'unknown env'
17
+ end
11
18
  end
12
19
 
13
20
  def prompt_color
14
- config.environment_prompt_colors.key?(::Rails.env.downcase) ? config.environment_prompt_colors[::Rails.env.downcase] : SaferRailsConsole::Colors::NONE
21
+ if ENV.key?('SAFER_RAILS_CONSOLE_PROMPT_COLOR')
22
+ SaferRailsConsole::Colors.const_get(ENV['SAFER_RAILS_CONSOLE_PROMPT_COLOR'].upcase)
23
+ else
24
+ config.environment_prompt_colors.key?(::Rails.env.downcase) ? config.environment_prompt_colors[::Rails.env.downcase] : SaferRailsConsole::Colors::NONE
25
+ end
15
26
  end
16
27
 
17
28
  def sandbox_environment?
18
- config.sandbox_environments.include?(::Rails.env.downcase)
29
+ if ENV.key?('SAFER_RAILS_CONSOLE_SANDBOX_ENVIRONMENT')
30
+ ActiveModel::Type::Boolean.new.cast(ENV['SAFER_RAILS_CONSOLE_SANDBOX_ENVIRONMENT'])
31
+ else
32
+ config.sandbox_environments.include?(::Rails.env.downcase)
33
+ end
19
34
  end
20
35
 
21
36
  def warn_environment?
22
- config.warn_environments.include?(::Rails.env.downcase)
37
+ if ENV.key?('SAFER_RAILS_CONSOLE_WARN_ENVIRONMENT')
38
+ ActiveModel::Type::Boolean.new.cast(ENV['SAFER_RAILS_CONSOLE_WARN_ENVIRONMENT'])
39
+ else
40
+ config.warn_environments.include?(::Rails.env.downcase)
41
+ end
42
+ end
43
+
44
+ def warn_text
45
+ if ENV.key?('SAFER_RAILS_CONSOLE_WARN_TEXT')
46
+ ENV['SAFER_RAILS_CONSOLE_WARN_TEXT']
47
+ else
48
+ config.warn_text
49
+ end
23
50
  end
24
51
 
25
52
  def config
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SaferRailsConsole
2
4
  module Colors
3
5
  NONE = 0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SaferRailsConsole
2
4
  module Console
3
5
  class << self
@@ -8,7 +10,7 @@ module SaferRailsConsole
8
10
  end
9
11
 
10
12
  def print_warning
11
- puts color_text(SaferRailsConsole.config.warn_text, SaferRailsConsole.prompt_color) # rubocop:disable Rails/Output
13
+ puts color_text(SaferRailsConsole.warn_text, SaferRailsConsole.prompt_color) # rubocop:disable Rails/Output
12
14
  end
13
15
 
14
16
  def load_config
@@ -1,6 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  include SaferRailsConsole::Colors
2
4
 
3
- app_name = ::Rails.application.class.parent.to_s.underscore.dasherize
5
+ app_name = if SaferRailsConsole::RailsVersion.six_or_above?
6
+ ::Rails.application.class.module_parent.to_s.underscore.dasherize
7
+ else
8
+ ::Rails.application.class.parent.to_s.underscore.dasherize
9
+ end
4
10
  env_name = SaferRailsConsole.environment_name
5
11
  status = ::Rails.application.sandbox ? 'read-only' : 'writable'
6
12
  color = SaferRailsConsole.prompt_color
@@ -12,7 +18,7 @@ IRB.conf[:PROMPT][:RAILS_ENV] = {
12
18
  PROMPT_N: color_text("#{prompt}> ", color),
13
19
  PROMPT_S: color_text("#{prompt}%l ", color),
14
20
  PROMPT_C: color_text("#{prompt}* ", color),
15
- RETURN: color_text('=> ', color).concat("%s\n")
21
+ RETURN: "#{color_text('=> ', color)}%s\n"
16
22
  }
17
23
 
18
24
  IRB.conf[:PROMPT_MODE] = :RAILS_ENV
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dir[File.join(__dir__, 'boot', '*.rb')].each { |file| require file }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'safer_rails_console/rails_version'
2
4
 
3
5
  module SaferRailsConsole
@@ -15,37 +17,6 @@ module SaferRailsConsole
15
17
  end
16
18
 
17
19
  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
20
  module CommandsTasks50
50
21
  def console
51
22
  require_command!('console')
@@ -72,16 +43,13 @@ module SaferRailsConsole
72
43
  end
73
44
  end
74
45
 
75
- if SaferRailsConsole::RailsVersion.four_one? || 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?
46
+ if SaferRailsConsole::RailsVersion.five_zero?
79
47
  require 'rails/commands/commands_tasks'
80
48
  ::Rails::CommandsTasks.prepend(SaferRailsConsole::Patches::Boot::SandboxFlag::Rails::CommandsTasks50)
81
- elsif SaferRailsConsole::RailsVersion.five_one?
49
+ elsif SaferRailsConsole::RailsVersion.five_one_or_above?
82
50
  require 'rails/command'
83
51
  require 'rails/commands/console/console_command'
84
- # Rails 5.1 defaults `sandbox` to `false`, but we need it to NOT have a default value and be `nil` when it is not user-specified
52
+ # 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
85
53
  ::Rails::Command::ConsoleCommand.class_eval do
86
54
  remove_class_option :sandbox
87
55
  class_option :sandbox, aliases: '-s', type: :boolean, desc: 'Explicitly enable/disable sandbox mode.'
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dir[File.join(__dir__, 'railtie', '*.rb')].each { |file| require file }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SaferRailsConsole
2
4
  module Patches
3
5
  module Sandbox
@@ -25,7 +27,7 @@ module SaferRailsConsole
25
27
  end
26
28
 
27
29
  if SaferRailsConsole::RailsVersion.supported?
28
- if SaferRailsConsole::RailsVersion.five_one?
30
+ if SaferRailsConsole::RailsVersion.five_one_or_above?
29
31
  require 'rails/commands/console/console_command'
30
32
  else
31
33
  require 'rails/commands/console'
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dir[File.join(__dir__, 'sandbox', '*.rb')].each { |file| require file }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SaferRailsConsole
2
4
  module Patches
3
5
  module Sandbox
@@ -22,28 +24,6 @@ module SaferRailsConsole
22
24
 
23
25
  module ActiveRecord
24
26
  module ConnectionAdapters
25
- module PostgreSQLAdapter41
26
- def exec_no_cache(sql, name, binds)
27
- super
28
- rescue => e
29
- SaferRailsConsole::Patches::Sandbox::AutoRollback.handle_and_reraise_exception(e)
30
- end
31
-
32
- def exec_cache(sql, name, binds)
33
- super
34
- rescue => e
35
- SaferRailsConsole::Patches::Sandbox::AutoRollback.handle_and_reraise_exception(e)
36
- end
37
- end
38
-
39
- module PostgreSQLAdapter42
40
- def execute_and_clear(sql, name, binds)
41
- super
42
- rescue => e
43
- SaferRailsConsole::Patches::Sandbox::AutoRollback.handle_and_reraise_exception(e)
44
- end
45
- end
46
-
47
27
  module PostgreSQLAdapter5
48
28
  def execute_and_clear(sql, name, binds, prepare: false)
49
29
  super
@@ -59,11 +39,5 @@ module SaferRailsConsole
59
39
  end
60
40
 
61
41
  if defined?(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
62
- if SaferRailsConsole::RailsVersion.four_one?
63
- ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(SaferRailsConsole::Patches::Sandbox::AutoRollback::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter41)
64
- elsif SaferRailsConsole::RailsVersion.four_two?
65
- ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(SaferRailsConsole::Patches::Sandbox::AutoRollback::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter42)
66
- else
67
- ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(SaferRailsConsole::Patches::Sandbox::AutoRollback::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter5)
68
- end
42
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(SaferRailsConsole::Patches::Sandbox::AutoRollback::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter5)
69
43
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SaferRailsConsole
2
4
  module Patches
3
5
  module Sandbox
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails'
2
4
 
3
5
  module SaferRailsConsole
@@ -6,17 +8,7 @@ module SaferRailsConsole
6
8
 
7
9
  class << self
8
10
  def supported?
9
- four_one? || four_two? || five_zero? || five_one?
10
- end
11
-
12
- def four_one?
13
- @is_four_one = Gem::Requirement.new('~> 4.1.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_four_one.nil?
14
- @is_four_one
15
- end
16
-
17
- def four_two?
18
- @is_four_two = Gem::Requirement.new('~> 4.2.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_four_two.nil?
19
- @is_four_two
11
+ five_zero? || five_one? || five_two? || six_or_above?
20
12
  end
21
13
 
22
14
  def five_zero?
@@ -28,6 +20,26 @@ module SaferRailsConsole
28
20
  @is_five_one = Gem::Requirement.new('~> 5.1.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_five_one.nil?
29
21
  @is_five_one
30
22
  end
23
+
24
+ def five_one_or_above?
25
+ @is_five_one_or_above = SaferRailsConsole::RailsVersion::RAILS_VERSION >= ::Gem::Version.new('5.1.0') if @is_five_one_or_above.nil?
26
+ @is_five_one_or_above
27
+ end
28
+
29
+ def five_two?
30
+ @is_five_two = Gem::Requirement.new('~> 5.2.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_five_two.nil?
31
+ @is_five_two
32
+ end
33
+
34
+ def six_zero?
35
+ @is_six_zero = Gem::Requirement.new('~> 6.0.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_six_zero.nil?
36
+ @is_six_zero
37
+ end
38
+
39
+ def six_or_above?
40
+ @is_six_or_above = SaferRailsConsole::RailsVersion::RAILS_VERSION >= ::Gem::Version.new('6.0.0') if @is_six_or_above.nil?
41
+ @is_six_or_above
42
+ end
31
43
  end
32
44
  end
33
45
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails'
2
4
  require 'safer_rails_console'
3
5
 
@@ -8,7 +10,7 @@ module SaferRailsConsole
8
10
  config.safer_rails_console = ActiveSupport::OrderedOptions.new
9
11
 
10
12
  initializer 'safer_rails_console.configure' do |app|
11
- SaferRailsConsole.config.set(app.config.safer_rails_console)
13
+ SaferRailsConsole.config.set(**app.config.safer_rails_console)
12
14
  end
13
15
 
14
16
  config.after_initialize do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SaferRailsConsole
2
- VERSION = '0.2.0'.freeze
4
+ VERSION = '0.5.1'
3
5
  end
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  lib = File.expand_path('../lib', __FILE__)
4
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -31,14 +32,15 @@ Gem::Specification.new do |spec|
31
32
  spec.require_paths = ['lib']
32
33
 
33
34
  spec.add_development_dependency 'appraisal', '~> 2.2'
34
- spec.add_development_dependency 'bundler', '~> 1.15'
35
+ spec.add_development_dependency 'bundler', '~> 2.0'
36
+ spec.add_development_dependency 'climate_control', '~> 0.2.0'
35
37
  spec.add_development_dependency 'mixlib-shellout', '~> 2.2'
36
38
  spec.add_development_dependency 'overcommit', '~> 0.39.0'
37
- spec.add_development_dependency 'pg', '~> 0.21'
39
+ spec.add_development_dependency 'pg', '~> 1.1'
38
40
  spec.add_development_dependency 'rake', '~> 12.0'
39
41
  spec.add_development_dependency 'rspec', '~> 3.6'
42
+ spec.add_development_dependency 'rspec_junit_formatter'
40
43
  spec.add_development_dependency 'salsify_rubocop', '~> 0.48.0'
41
- spec.add_development_dependency 'sqlite3', '~> 1.3'
42
- spec.add_development_dependency 'wwtd', '~> 1.3'
43
- spec.add_runtime_dependency 'rails', '>= 4.1', '< 5.2'
44
+
45
+ spec.add_runtime_dependency 'rails', '>= 5.0', '< 6.2'
44
46
  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.2.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify, Inc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-07 00:00:00.000000000 Z
11
+ date: 2021-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -30,14 +30,28 @@ 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
+ - !ruby/object:Gem::Dependency
42
+ name: climate_control
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: mixlib-shellout
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +86,14 @@ dependencies:
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '0.21'
89
+ version: '1.1'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '0.21'
96
+ version: '1.1'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -109,67 +123,53 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '3.6'
111
125
  - !ruby/object:Gem::Dependency
112
- name: salsify_rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.48.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.48.0
125
- - !ruby/object:Gem::Dependency
126
- name: sqlite3
126
+ name: rspec_junit_formatter
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: '1.3'
131
+ version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: '1.3'
138
+ version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: wwtd
140
+ name: salsify_rubocop
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '1.3'
145
+ version: 0.48.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '1.3'
152
+ version: 0.48.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rails
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: '4.1'
159
+ version: '5.0'
160
160
  - - "<"
161
161
  - !ruby/object:Gem::Version
162
- version: '5.2'
162
+ version: '6.2'
163
163
  type: :runtime
164
164
  prerelease: false
165
165
  version_requirements: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: '4.1'
169
+ version: '5.0'
170
170
  - - "<"
171
171
  - !ruby/object:Gem::Version
172
- version: '5.2'
172
+ version: '6.2'
173
173
  description: This gem makes Rails console sessions less dangerous in specified environments
174
174
  by warning, color-coding, auto-sandboxing, and allowing read-only external connections
175
175
  (disables job queueing, non-GET requests, etc.)
@@ -179,11 +179,11 @@ executables: []
179
179
  extensions: []
180
180
  extra_rdoc_files: []
181
181
  files:
182
+ - ".circleci/config.yml"
182
183
  - ".gitignore"
183
184
  - ".overcommit.yml"
184
185
  - ".rspec"
185
186
  - ".rubocop.yml"
186
- - ".travis.yml"
187
187
  - Appraisals
188
188
  - CHANGELOG.md
189
189
  - Gemfile
@@ -192,10 +192,11 @@ files:
192
192
  - Rakefile
193
193
  - bin/console
194
194
  - bin/setup
195
- - gemfiles/4.1.gemfile
196
- - gemfiles/4.2.gemfile
197
195
  - gemfiles/5.0.gemfile
198
196
  - gemfiles/5.1.gemfile
197
+ - gemfiles/5.2.gemfile
198
+ - gemfiles/6.0.gemfile
199
+ - gemfiles/6.1.gemfile
199
200
  - lib/safer_rails_console.rb
200
201
  - lib/safer_rails_console/colors.rb
201
202
  - lib/safer_rails_console/console.rb
@@ -231,8 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
232
  - !ruby/object:Gem::Version
232
233
  version: '0'
233
234
  requirements: []
234
- rubyforge_project:
235
- rubygems_version: 2.6.12
235
+ rubygems_version: 3.1.2
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Make rails console less dangerous!
@@ -1,37 +0,0 @@
1
- language: ruby
2
- sudo: false
3
-
4
- services:
5
- - postgresql
6
-
7
- bundler_args: --without test --jobs 3 --retry 3
8
- before_install:
9
- - gem install bundler
10
-
11
- before_script:
12
- - cp spec/internal/database.yml.travis spec/internal/rails_4_1/config/database.yml
13
- - cp spec/internal/database.yml.travis spec/internal/rails_4_2/config/database.yml
14
- - cp spec/internal/database.yml.travis spec/internal/rails_5_0/config/database.yml
15
- - cp spec/internal/database.yml.travis spec/internal/rails_5_1/config/database.yml
16
-
17
- script:
18
- - bundle exec rubocop
19
- - bundle exec rspec
20
-
21
- rvm:
22
- - 2.2.7
23
- - 2.3.4
24
- - 2.4.1
25
-
26
- gemfile:
27
- - gemfiles/4.1.gemfile
28
- - gemfiles/4.2.gemfile
29
- - gemfiles/5.0.gemfile
30
- - gemfiles/5.1.gemfile
31
-
32
- matrix:
33
- allow_failures:
34
- - gemfile: gemfiles/4.1.gemfile
35
- rvm: 2.4.1
36
-
37
- fast_finish: true