rubocop-eightyfourcodes 0.0.1 → 0.0.2

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.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +1 -1
  4. data/config/default.yml +7 -1
  5. data/lib/rubocop-eightyfourcodes.rb +14 -14
  6. data/lib/rubocop/cop/{eightyfourcodes → eighty_four_codes}/command_literal_injection.rb +0 -0
  7. data/lib/rubocop/cop/{eightyfourcodes → eighty_four_codes}/cop.rb +0 -0
  8. data/lib/rubocop/cop/eighty_four_codes/ruby_version_file.rb +48 -0
  9. data/lib/rubocop/cop/eighty_four_codes/shell_escape.rb +62 -0
  10. data/lib/rubocop/{eightyfourcodes.rb → eighty_four_codes.rb} +0 -0
  11. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/concept.rb +0 -0
  12. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/config_formatter.rb +0 -0
  13. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/description_extractor.rb +0 -0
  14. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/example.rb +0 -0
  15. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/example_group.rb +0 -0
  16. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/hook.rb +0 -0
  17. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/inject.rb +0 -0
  18. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/language.rb +0 -0
  19. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/language/node_pattern.rb +0 -0
  20. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/top_level_describe.rb +0 -0
  21. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/util.rb +0 -0
  22. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/version.rb +1 -1
  23. data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/wording.rb +0 -0
  24. data/rubocop-eightyfourcodes.gemspec +1 -1
  25. metadata +24 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3bdcf879f5dbd72c539cfb616e85279915721d3520667359a6613c8183425c5
4
- data.tar.gz: 8052007c2529fef3406fa5a0b3560720ff373030ef1ddbd12b85c96b62e0eac1
3
+ metadata.gz: caa8bb23e13eed6bbcb9e59c2a4a76db329ae6ec62c7efe251cdcc6e794beff3
4
+ data.tar.gz: fdc49e8b5e58feb5e438d6c2cc0183cf20a194175cc2fea9c970939d4d51c751
5
5
  SHA512:
6
- metadata.gz: 329bf23841b2ba450a8fa291fda6ec57bc709f47036e8cb528f6fec1abca6155febc27417fab729acbe6aed0f64456484ed8d2938795d23d71062703ffe3ba50
7
- data.tar.gz: a8bd924b5f4e3dfe379d4ee2651ae156dd7c30654c4293de210b6973e03132449d414d45a8948fcd431d2b225844bea177d908fb16985cf019155a673d8e73ed
6
+ metadata.gz: 7669d1010b6d8521ffbf0b61d0c858c62d851df29c0f3144a5a010ae021737df911488393a8b4538505e774b96e138f769196ae1e514f57558df71cb5dab9517
7
+ data.tar.gz: 56f7910d7429f6592cf1f3a9ef54b7c02690b55545f1f45f9c02d872249bf3d6c79e815615fe922f4ce22526bcebf7cda73678f9f634f1dbe50504af44664e76
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.2 (2020-09-24)
4
+
5
+ - Added `RubyVersionFile`: Ensure we read Gemfile ruby version from `.ruby-version` file
6
+
3
7
  ## 0.0.1 (2019-09-11)
4
8
 
5
9
  - Forked from gitlab-security
data/README.md CHANGED
@@ -69,7 +69,7 @@ AllCops:
69
69
  ## The Cops
70
70
 
71
71
  All cops are located under
72
- [`lib/rubocop/cop/eightyfourcodes`](lib/rubocop/cop/eightyfourcodes), and contain
72
+ [`lib/rubocop/cop/eighty_four_codes`](lib/rubocop/cop/eighty_four_codes), and contain
73
73
  examples/documentation.
74
74
 
75
75
  In your `.rubocop.yml`, you may treat the eightyfourcodes cops just like any other
@@ -5,5 +5,11 @@ AllCops:
5
5
  - ".+"
6
6
 
7
7
  EightyFourCodes/CommandLiteralInjection:
8
- Description: Check for Command Injection in `` and %x
8
+ Description: "Check for Command Injection in `` and %x"
9
9
  Enabled: true
10
+ VersionAdded: "0.0.1"
11
+
12
+ EightyFourCodes/RubyVersionFile:
13
+ Description: "Ensure .ruby-version file use in Gemfile"
14
+ Enabled: true
15
+ VersionAdded: "0.0.2"
@@ -3,20 +3,20 @@ require 'yaml'
3
3
 
4
4
  require 'rubocop'
5
5
 
6
- require 'rubocop/eightyfourcodes'
7
- require 'rubocop/eightyfourcodes/version'
8
- require 'rubocop/eightyfourcodes/inject'
9
- require 'rubocop/eightyfourcodes/top_level_describe'
10
- require 'rubocop/eightyfourcodes/wording'
11
- require 'rubocop/eightyfourcodes/util'
12
- require 'rubocop/eightyfourcodes/language'
13
- require 'rubocop/eightyfourcodes/language/node_pattern'
14
- require 'rubocop/eightyfourcodes/concept'
15
- require 'rubocop/eightyfourcodes/example_group'
16
- require 'rubocop/eightyfourcodes/example'
17
- require 'rubocop/eightyfourcodes/hook'
18
- require 'rubocop/cop/eightyfourcodes/cop'
6
+ require 'rubocop/eighty_four_codes'
7
+ require 'rubocop/eighty_four_codes/version'
8
+ require 'rubocop/eighty_four_codes/inject'
9
+ require 'rubocop/eighty_four_codes/top_level_describe'
10
+ require 'rubocop/eighty_four_codes/wording'
11
+ require 'rubocop/eighty_four_codes/util'
12
+ require 'rubocop/eighty_four_codes/language'
13
+ require 'rubocop/eighty_four_codes/language/node_pattern'
14
+ require 'rubocop/eighty_four_codes/concept'
15
+ require 'rubocop/eighty_four_codes/example_group'
16
+ require 'rubocop/eighty_four_codes/example'
17
+ require 'rubocop/eighty_four_codes/hook'
18
+ require 'rubocop/cop/eighty_four_codes/cop'
19
19
 
20
20
  RuboCop::EightyFourCodes::Inject.defaults!
21
21
 
22
- require 'rubocop/cop/eightyfourcodes/command_literal_injection'
22
+ Dir["#{__dir__}/rubocop/cop/eighty_four_codes/**/*.rb"].each { |cop| require cop }
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module EightyFourCodes
6
+ # Read Ruby version from a .ruby-version file
7
+ #
8
+ # Instead of staticly defining the Ruby runtime version in Gemfile, load it from
9
+ # a .ruby-version file definition. As this Ruby version file is read by rbenv, chruby etc
10
+ # it's much easier for the developer to work with multiple projects with different versions.
11
+ #
12
+ # @example
13
+ # # bad
14
+ # ruby 2.6.6
15
+ #
16
+ # # good
17
+ # ruby File.read('.ruby-version')
18
+ class RubyVersionFile < Base
19
+ extend AutoCorrector
20
+
21
+ MSG = "Control Ruby version via .ruby-version, fix by replacing with File.read('.ruby-version')"
22
+
23
+ RESTRICT_ON_SEND = %i[ruby].freeze
24
+
25
+ def_node_matcher :static_version_found?, <<~PATTERN
26
+ (send nil? :ruby
27
+ $(str _))
28
+ PATTERN
29
+
30
+ def on_send(node)
31
+ return unless File.basename(processed_source.file_path).eql?('Gemfile')
32
+ static_version_found?(node) do |source_node, source|
33
+ message = format(MSG, source: source)
34
+
35
+ add_offense(
36
+ source_node,
37
+ message: message
38
+ ) do |corrector|
39
+ corrector.replace(
40
+ source_node, "File.read('.ruby-version')"
41
+ )
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ # TODO: when finished, run `rake generate_cops_documentation` to update the docs
4
+ module RuboCop
5
+ module Cop
6
+ module EightyFourCodes
7
+ # TODO: Write cop description and example of bad / good code. For every
8
+ # `SupportedStyle` and unique configuration, there needs to be examples.
9
+ # Examples must have valid Ruby syntax. Do not use upticks.
10
+ #
11
+ # @example EnforcedStyle: bar (default)
12
+ # # Description of the `bar` style.
13
+ #
14
+ # # bad
15
+ # bad_bar_method
16
+ #
17
+ # # bad
18
+ # bad_bar_method(args)
19
+ #
20
+ # # good
21
+ # good_bar_method
22
+ #
23
+ # # good
24
+ # good_bar_method(args)
25
+ #
26
+ # @example EnforcedStyle: foo
27
+ # # Description of the `foo` style.
28
+ #
29
+ # # bad
30
+ # bad_foo_method
31
+ #
32
+ # # bad
33
+ # bad_foo_method(args)
34
+ #
35
+ # # good
36
+ # good_foo_method
37
+ #
38
+ # # good
39
+ # good_foo_method(args)
40
+ #
41
+ class ShellEscape < Cop
42
+ # TODO: Implement the cop in here.
43
+ #
44
+ # In many cases, you can use a node matcher for matching node pattern.
45
+ # See https://github.com/rubocop-hq/rubocop/blob/master/lib/rubocop/node_pattern.rb
46
+ #
47
+ # For example
48
+ MSG = 'Use `#good_method` instead of `#bad_method`.'.freeze
49
+
50
+ def_node_matcher :bad_method?, <<~PATTERN
51
+ (send nil? :bad_method ...)
52
+ PATTERN
53
+
54
+ def on_send(node)
55
+ return unless bad_method?(node)
56
+
57
+ add_offense(node)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module EightyFourCodes
5
5
  # Version information for the eightyfourcodes Rubocop plugin.
6
6
  module Version
7
- STRING = '0.0.1'
7
+ STRING = '0.0.2'
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  $LOAD_PATH.unshift File.expand_path('lib', __dir__)
2
- require 'rubocop/eightyfourcodes/version'
2
+ require 'rubocop/eighty_four_codes/version'
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'rubocop-eightyfourcodes'
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-eightyfourcodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anders Bälter
8
8
  - Brian Neel
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-09-11 00:00:00.000000000 Z
12
+ date: 2020-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubocop
@@ -58,28 +58,30 @@ files:
58
58
  - README.md
59
59
  - config/default.yml
60
60
  - lib/rubocop-eightyfourcodes.rb
61
- - lib/rubocop/cop/eightyfourcodes/command_literal_injection.rb
62
- - lib/rubocop/cop/eightyfourcodes/cop.rb
63
- - lib/rubocop/eightyfourcodes.rb
64
- - lib/rubocop/eightyfourcodes/concept.rb
65
- - lib/rubocop/eightyfourcodes/config_formatter.rb
66
- - lib/rubocop/eightyfourcodes/description_extractor.rb
67
- - lib/rubocop/eightyfourcodes/example.rb
68
- - lib/rubocop/eightyfourcodes/example_group.rb
69
- - lib/rubocop/eightyfourcodes/hook.rb
70
- - lib/rubocop/eightyfourcodes/inject.rb
71
- - lib/rubocop/eightyfourcodes/language.rb
72
- - lib/rubocop/eightyfourcodes/language/node_pattern.rb
73
- - lib/rubocop/eightyfourcodes/top_level_describe.rb
74
- - lib/rubocop/eightyfourcodes/util.rb
75
- - lib/rubocop/eightyfourcodes/version.rb
76
- - lib/rubocop/eightyfourcodes/wording.rb
61
+ - lib/rubocop/cop/eighty_four_codes/command_literal_injection.rb
62
+ - lib/rubocop/cop/eighty_four_codes/cop.rb
63
+ - lib/rubocop/cop/eighty_four_codes/ruby_version_file.rb
64
+ - lib/rubocop/cop/eighty_four_codes/shell_escape.rb
65
+ - lib/rubocop/eighty_four_codes.rb
66
+ - lib/rubocop/eighty_four_codes/concept.rb
67
+ - lib/rubocop/eighty_four_codes/config_formatter.rb
68
+ - lib/rubocop/eighty_four_codes/description_extractor.rb
69
+ - lib/rubocop/eighty_four_codes/example.rb
70
+ - lib/rubocop/eighty_four_codes/example_group.rb
71
+ - lib/rubocop/eighty_four_codes/hook.rb
72
+ - lib/rubocop/eighty_four_codes/inject.rb
73
+ - lib/rubocop/eighty_four_codes/language.rb
74
+ - lib/rubocop/eighty_four_codes/language/node_pattern.rb
75
+ - lib/rubocop/eighty_four_codes/top_level_describe.rb
76
+ - lib/rubocop/eighty_four_codes/util.rb
77
+ - lib/rubocop/eighty_four_codes/version.rb
78
+ - lib/rubocop/eighty_four_codes/wording.rb
77
79
  - rubocop-eightyfourcodes.gemspec
78
80
  homepage: https://github.com/84codes/rubocop-eightyfourcodes/
79
81
  licenses:
80
82
  - MIT
81
83
  metadata: {}
82
- post_install_message:
84
+ post_install_message:
83
85
  rdoc_options: []
84
86
  require_paths:
85
87
  - lib
@@ -94,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
96
  - !ruby/object:Gem::Version
95
97
  version: '0'
96
98
  requirements: []
97
- rubygems_version: 3.0.3
98
- signing_key:
99
+ rubygems_version: 3.1.2
100
+ signing_key:
99
101
  specification_version: 4
100
102
  summary: Basic security checks for projects
101
103
  test_files: []