simplycop 1.7.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.custom_simplycop.yml +1 -0
- data/.github/workflows/dobby-actions.yml +15 -4
- data/README.md +1 -69
- data/catalog-info.yaml +0 -1
- data/docs/index.md +73 -0
- data/lib/simplycop/custom_cops/variable_name_shadowing_method.rb +31 -0
- data/lib/simplycop/version.rb +1 -1
- data/mkdocs.yml +7 -0
- data/simplycop.gemspec +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7186eac4e8a769e55cefe3738cfbf45c967a6b2aab0f4744191d92b932175ea7
|
4
|
+
data.tar.gz: 604182eff86928d921da2831b08a1bb880b1a21660a252610619012f7059fa34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0be2768aceb033e5625ebd342c86c1ae8cbe356d348f8ad27d7cd9ef9d9faecb78907ff4a6f17f6369eade666f99b8e1697a35143b43b768b7ef73609024de0b
|
7
|
+
data.tar.gz: 0a09ff8fccde37b4b8f9eea6241a2c64ca76e5a775f34777eebfb7eda8751ec7471c7d080319d1cd420c67f28cf386a220f4870435b0b8d059a5ef8f6119aa37
|
data/.custom_simplycop.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
name: "Dobby action"
|
2
3
|
on:
|
3
4
|
issue_comment:
|
4
5
|
types: [created]
|
@@ -6,10 +7,20 @@ jobs:
|
|
6
7
|
pr_commented:
|
7
8
|
runs-on: ubuntu-20.04
|
8
9
|
if: startsWith(github.event.comment.body, '/dobby')
|
9
|
-
|
10
|
+
env:
|
11
|
+
BUNDLE_WITHOUT: "development:test"
|
10
12
|
steps:
|
11
|
-
- name:
|
12
|
-
uses:
|
13
|
+
- name: Chekcout action
|
14
|
+
uses: actions/checkout@v2
|
15
|
+
with:
|
16
|
+
repository: 'simplybusiness/dobby'
|
17
|
+
ref: 'v3.0.0'
|
18
|
+
- name: Set up ruby
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
bundler-cache: true
|
22
|
+
- name: Bump version
|
23
|
+
uses: simplybusiness/dobby@v3.0.0
|
13
24
|
env:
|
14
25
|
DOBBY_APP_ID: ${{ secrets.DOBBY_APP_ID }}
|
15
26
|
DOBBY_PRIVATE_KEY: ${{ secrets.DOBBY_PRIVATE_KEY }}
|
data/README.md
CHANGED
@@ -2,72 +2,4 @@
|
|
2
2
|
|
3
3
|
Provides standard shared rubocop configuration for Simply Business applications. No more copying `.rubocop.yml`, no more out-of-sync configuration files. Yay!
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'simplycop', git: 'git@github.com:simplybusiness/simplycop.git'
|
11
|
-
|
12
|
-
```
|
13
|
-
|
14
|
-
Then install gems by executing:
|
15
|
-
|
16
|
-
$ bundle install
|
17
|
-
|
18
|
-
Put following lines at the beginning of your `rubocop.yml` file:
|
19
|
-
|
20
|
-
```yaml
|
21
|
-
inherit_gem:
|
22
|
-
simplycop: .simplycop.yml
|
23
|
-
|
24
|
-
AllCops:
|
25
|
-
Exclude:
|
26
|
-
- 'vendor/**/*'
|
27
|
-
```
|
28
|
-
|
29
|
-
* If you are implementing this in rails project and have rspec , you probably want the standard rails and rspec cops. you can include this by adding:
|
30
|
-
|
31
|
-
```yaml
|
32
|
-
inherit_gem:
|
33
|
-
simplycop:
|
34
|
-
- .simplycop.yml
|
35
|
-
- .simplycop_rails.yml
|
36
|
-
- .simplycop_rspec.yml
|
37
|
-
```
|
38
|
-
|
39
|
-
## Usage
|
40
|
-
|
41
|
-
Run Rubocop as you would usually do, i.e.
|
42
|
-
|
43
|
-
$ bundle exec rubocop
|
44
|
-
|
45
|
-
or from your continuous integration tool.
|
46
|
-
|
47
|
-
## Guidances
|
48
|
-
|
49
|
-
* If you are implementing this in a non-rails project, you probably don't want or need the rails cops. In case they cause problems, you can exclude them using:
|
50
|
-
```yaml
|
51
|
-
Rails:
|
52
|
-
Enabled: false
|
53
|
-
```
|
54
|
-
* When adding rubocop and simplycop to a legacy project, you might want to initially disable some of the rules.
|
55
|
-
|
56
|
-
## Security Cops
|
57
|
-
- CheckForVulnerableCode
|
58
|
-
|
59
|
-
This cop was built to identify possible Rails vulnerable code.
|
60
|
-
Its purpose is to raise an awareness of the finding.
|
61
|
-
When an offence was raised, please seek for help and guidance from application security team.
|
62
|
-
|
63
|
-
IMPORTANT:
|
64
|
-
This cop must be enabled at all times, if you need to disable it please check with AppSec team first.
|
65
|
-
|
66
|
-
Example of vulnerable code:
|
67
|
-
|
68
|
-
```ruby
|
69
|
-
class BooksController < ApplicationController
|
70
|
-
caches_page :show
|
71
|
-
end
|
72
|
-
```
|
73
|
-
Vulnerability Details: https://nvd.nist.gov/vuln/detail/CVE-2020-8159
|
5
|
+
See [Full docs](docs/index.md)
|
data/catalog-info.yaml
CHANGED
@@ -6,7 +6,6 @@ metadata:
|
|
6
6
|
annotations:
|
7
7
|
github.com/project-slug: "simplybusiness/simplycop"
|
8
8
|
backstage.io/source-location: url:https://github.com/simplybusiness/simplycop/
|
9
|
-
backstage.io/techdocs-ref: url:https://github.com/simplybusiness/simplycop/
|
10
9
|
spec:
|
11
10
|
type: library
|
12
11
|
lifecycle: production
|
data/docs/index.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Simplycop
|
2
|
+
|
3
|
+
Provides standard shared rubocop configuration for Simply Business applications. No more copying `.rubocop.yml`, no more out-of-sync configuration files. Yay!
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'simplycop'
|
11
|
+
|
12
|
+
```
|
13
|
+
|
14
|
+
Then install gems by executing:
|
15
|
+
|
16
|
+
$ bundle install
|
17
|
+
|
18
|
+
Put following lines at the beginning of your `rubocop.yml` file:
|
19
|
+
|
20
|
+
```yaml
|
21
|
+
inherit_gem:
|
22
|
+
simplycop: .simplycop.yml
|
23
|
+
|
24
|
+
AllCops:
|
25
|
+
Exclude:
|
26
|
+
- 'vendor/**/*'
|
27
|
+
```
|
28
|
+
|
29
|
+
* If you are implementing this in rails project and have rspec , you probably want the standard rails and rspec cops. you can include this by adding:
|
30
|
+
|
31
|
+
```yaml
|
32
|
+
inherit_gem:
|
33
|
+
simplycop:
|
34
|
+
- .simplycop.yml
|
35
|
+
- .simplycop_rails.yml
|
36
|
+
- .simplycop_rspec.yml
|
37
|
+
```
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
Run Rubocop as you would usually do, i.e.
|
42
|
+
|
43
|
+
$ bundle exec rubocop
|
44
|
+
|
45
|
+
or from your continuous integration tool.
|
46
|
+
|
47
|
+
## Guidances
|
48
|
+
|
49
|
+
* If you are implementing this in a non-rails project, you probably don't want or need the rails cops. In case they cause problems, you can exclude them using:
|
50
|
+
```yaml
|
51
|
+
Rails:
|
52
|
+
Enabled: false
|
53
|
+
```
|
54
|
+
* When adding rubocop and simplycop to a legacy project, you might want to initially disable some of the rules.
|
55
|
+
|
56
|
+
## Security Cops
|
57
|
+
- CheckForVulnerableCode
|
58
|
+
|
59
|
+
This cop was built to identify possible Rails vulnerable code.
|
60
|
+
Its purpose is to raise an awareness of the finding.
|
61
|
+
When an offence was raised, please seek for help and guidance from application security team.
|
62
|
+
|
63
|
+
IMPORTANT:
|
64
|
+
This cop must be enabled at all times, if you need to disable it please check with AppSec team first.
|
65
|
+
|
66
|
+
Example of vulnerable code:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
class BooksController < ApplicationController
|
70
|
+
caches_page :show
|
71
|
+
end
|
72
|
+
```
|
73
|
+
Vulnerability Details: https://nvd.nist.gov/vuln/detail/CVE-2020-8159
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CustomCops
|
4
|
+
class VariableNameShadowingMethod < RuboCop::Cop::Cop
|
5
|
+
# For each source file, Rubocop calls on_new_investigation, then walks the abstract syntax
|
6
|
+
# tree calling on_foo methods for each "foo" AST node - e.g on_begin, on_def, on_args,
|
7
|
+
# on_int, etc.
|
8
|
+
|
9
|
+
# We need to do two passes over the source so that we can find all the method names before
|
10
|
+
# we start looking at the nodes that assign local variables (some methods may be defined
|
11
|
+
# _after_ code that assigns shadowing local variables. We do the first one in
|
12
|
+
# on_new_investigation
|
13
|
+
|
14
|
+
def_node_search :method_names, <<~PATTERN
|
15
|
+
(:def $_ ...)
|
16
|
+
PATTERN
|
17
|
+
|
18
|
+
def on_new_investigation
|
19
|
+
@declared_method_names = method_names(processed_source.ast).to_a
|
20
|
+
end
|
21
|
+
|
22
|
+
def on_lvasgn(node)
|
23
|
+
if @declared_method_names.include?(node.name)
|
24
|
+
add_offense(
|
25
|
+
node,
|
26
|
+
message: "Shadowing method name - `#{node.name}`."
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/simplycop/version.rb
CHANGED
data/mkdocs.yml
ADDED
data/simplycop.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_dependency 'rubocop', '~> 1.12.1'
|
21
21
|
spec.add_dependency 'rubocop-rails', '~> 2.9.0'
|
22
22
|
spec.add_dependency 'rubocop-rspec', '~> 2.2.0'
|
23
|
-
spec.add_development_dependency 'bundler'
|
23
|
+
spec.add_development_dependency 'bundler', '>= 2.2.15'
|
24
24
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
25
25
|
spec.add_development_dependency 'rspec', '~> 3.10'
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplycop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simply Business
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.2.15
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.2.15
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- bin/console
|
125
125
|
- bin/setup
|
126
126
|
- catalog-info.yaml
|
127
|
+
- docs/index.md
|
127
128
|
- lib/simplycop.rb
|
128
129
|
- lib/simplycop/custom_cops/constantize.rb
|
129
130
|
- lib/simplycop/custom_cops/define_method.rb
|
@@ -131,10 +132,12 @@ files:
|
|
131
132
|
- lib/simplycop/custom_cops/instance_eval.rb
|
132
133
|
- lib/simplycop/custom_cops/method_missing.rb
|
133
134
|
- lib/simplycop/custom_cops/timecop_without_block.rb
|
135
|
+
- lib/simplycop/custom_cops/variable_name_shadowing_method.rb
|
134
136
|
- lib/simplycop/security/check_for_vulnerable_code.rb
|
135
137
|
- lib/simplycop/security/csrf_token_validation.rb
|
136
138
|
- lib/simplycop/security/reject_all_requests_local.rb
|
137
139
|
- lib/simplycop/version.rb
|
140
|
+
- mkdocs.yml
|
138
141
|
- simplycop.gemspec
|
139
142
|
- vuln_db.json
|
140
143
|
homepage: https://github.com/simplybusiness/simplycop
|
@@ -156,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
159
|
- !ruby/object:Gem::Version
|
157
160
|
version: '0'
|
158
161
|
requirements: []
|
159
|
-
rubygems_version: 3.2.
|
162
|
+
rubygems_version: 3.2.22
|
160
163
|
signing_key:
|
161
164
|
specification_version: 4
|
162
165
|
summary: Provides a single point of reference for common rubocop rules.
|