rubocop-eightyfourcodes 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/config/default.yml +7 -1
- data/lib/rubocop-eightyfourcodes.rb +14 -14
- data/lib/rubocop/cop/{eightyfourcodes → eighty_four_codes}/command_literal_injection.rb +0 -0
- data/lib/rubocop/cop/{eightyfourcodes → eighty_four_codes}/cop.rb +0 -0
- data/lib/rubocop/cop/eighty_four_codes/ruby_version_file.rb +48 -0
- data/lib/rubocop/cop/eighty_four_codes/shell_escape.rb +62 -0
- data/lib/rubocop/{eightyfourcodes.rb → eighty_four_codes.rb} +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/concept.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/config_formatter.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/description_extractor.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/example.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/example_group.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/hook.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/inject.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/language.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/language/node_pattern.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/top_level_describe.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/util.rb +0 -0
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/version.rb +1 -1
- data/lib/rubocop/{eightyfourcodes → eighty_four_codes}/wording.rb +0 -0
- data/rubocop-eightyfourcodes.gemspec +1 -1
- metadata +24 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caa8bb23e13eed6bbcb9e59c2a4a76db329ae6ec62c7efe251cdcc6e794beff3
|
4
|
+
data.tar.gz: fdc49e8b5e58feb5e438d6c2cc0183cf20a194175cc2fea9c970939d4d51c751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7669d1010b6d8521ffbf0b61d0c858c62d851df29c0f3144a5a010ae021737df911488393a8b4538505e774b96e138f769196ae1e514f57558df71cb5dab9517
|
7
|
+
data.tar.gz: 56f7910d7429f6592cf1f3a9ef54b7c02690b55545f1f45f9c02d872249bf3d6c79e815615fe922f4ce22526bcebf7cda73678f9f634f1dbe50504af44664e76
|
data/CHANGELOG.md
CHANGED
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/
|
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
|
data/config/default.yml
CHANGED
@@ -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/
|
7
|
-
require 'rubocop/
|
8
|
-
require 'rubocop/
|
9
|
-
require 'rubocop/
|
10
|
-
require 'rubocop/
|
11
|
-
require 'rubocop/
|
12
|
-
require 'rubocop/
|
13
|
-
require 'rubocop/
|
14
|
-
require 'rubocop/
|
15
|
-
require 'rubocop/
|
16
|
-
require 'rubocop/
|
17
|
-
require 'rubocop/
|
18
|
-
require 'rubocop/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
|
-
|
22
|
+
Dir["#{__dir__}/rubocop/cop/eighty_four_codes/**/*.rb"].each { |cop| require cop }
|
File without changes
|
File without changes
|
@@ -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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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.
|
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:
|
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/
|
62
|
-
- lib/rubocop/cop/
|
63
|
-
- lib/rubocop/
|
64
|
-
- lib/rubocop/
|
65
|
-
- lib/rubocop/
|
66
|
-
- lib/rubocop/
|
67
|
-
- lib/rubocop/
|
68
|
-
- lib/rubocop/
|
69
|
-
- lib/rubocop/
|
70
|
-
- lib/rubocop/
|
71
|
-
- lib/rubocop/
|
72
|
-
- lib/rubocop/
|
73
|
-
- lib/rubocop/
|
74
|
-
- lib/rubocop/
|
75
|
-
- lib/rubocop/
|
76
|
-
- lib/rubocop/
|
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.
|
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: []
|