code_hunter 0.0.1 → 0.1.0
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.
- data/README.md +36 -2
- data/code_hunter.gemspec +1 -0
- data/lib/code_hunter.rb +1 -0
- data/lib/code_hunter/option_parser.rb +1 -1
- data/lib/code_hunter/pendaxes.rb +33 -0
- data/lib/code_hunter/runner.rb +6 -6
- data/lib/code_hunter/version.rb +1 -1
- data/spec/code_hunter/pendaxes_spec.rb +39 -0
- metadata +21 -2
data/README.md
CHANGED
@@ -4,11 +4,45 @@ Hunt out weak spots in your rails application with 2 static metrics tools:
|
|
4
4
|
* [Brakeman](https://github.com/presidentbeef/brakeman) - A static analysis security vulnerability scanner for Rails
|
5
5
|
* [RailsBestPractices](https://github.com/railsbp/rails_best_practices) - A code metric tool for rails projects
|
6
6
|
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
```
|
10
|
+
$ gem install code_hunter
|
11
|
+
```
|
12
|
+
|
7
13
|
## Usage
|
8
14
|
```
|
9
|
-
$
|
15
|
+
$ code_hunter --help
|
10
16
|
Usage: code_hunter [options]
|
11
|
-
--application-path= (default:
|
17
|
+
--application-path= (default: ./) rails application root path
|
18
|
+
--format= (default: yaml) output format (yaml or json)
|
19
|
+
|
20
|
+
$ code_hunter --application-path /path/to/rails/root
|
21
|
+
...
|
22
|
+
...
|
23
|
+
---
|
24
|
+
- :service: brakeman
|
25
|
+
:line: 8
|
26
|
+
:path: config/routes.rb
|
27
|
+
:message: All public methods in controllers are available as actions in routes.rb
|
28
|
+
near line 8
|
29
|
+
:sha1: 81887a2fb6efaa9dae59425ce7537c7905516ed0
|
30
|
+
:author: Ryo Nakamura
|
31
|
+
:email: r7kamura@gmail.com
|
32
|
+
:modified_at: 1357783853
|
33
|
+
- :service: rails_best_practices
|
34
|
+
:line: 9
|
35
|
+
:path: config/routes.rb
|
36
|
+
:message: ! 'restrict auto-generated routes examples (only: [])'
|
37
|
+
:sha1: 81887a2fb6efaa9dae59425ce7537c7905516ed0
|
38
|
+
:author: Ryo Nakamura
|
39
|
+
:email: r7kamura@gmail.com
|
40
|
+
:modified_at: 1357783853
|
41
|
+
|
42
|
+
$ code_hunter --application-path /path/to/rails/root --format json
|
43
|
+
...
|
44
|
+
...
|
45
|
+
[{"service":"brakeman","line":8,"path":"config/routes.rb","message":"All public methods in controllers are available as actions in routes.rb near line 8","sha1":"81887a2fb6efaa9dae59425ce7537c7905516ed0","author":"Ryo Nakamura","email":"r7kamura@gmail.com","modified_at":1357783853},{"service":"rails_best_practices","line":9,"path":"config/routes.rb","message":"restrict auto-generated routes examples (only: [])","sha1":"81887a2fb6efaa9dae59425ce7537c7905516ed0","author":"Ryo Nakamura","email":"r7kamura@gmail.com","modified_at":1357783853}]
|
12
46
|
```
|
13
47
|
|
14
48
|
## Requirements
|
data/code_hunter.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_dependency "activesupport"
|
22
22
|
gem.add_dependency "brakeman"
|
23
23
|
gem.add_dependency "rails_best_practices"
|
24
|
+
gem.add_dependency "pendaxes", "0.2.1"
|
24
25
|
|
25
26
|
gem.add_development_dependency "rspec", ">= 2.12.0"
|
26
27
|
gem.add_development_dependency "simplecov"
|
data/lib/code_hunter.rb
CHANGED
@@ -4,6 +4,7 @@ require "code_hunter/version"
|
|
4
4
|
require "code_hunter/option_parser"
|
5
5
|
require "code_hunter/runner"
|
6
6
|
require "code_hunter/renderer"
|
7
|
+
require "code_hunter/pendaxes"
|
7
8
|
require "code_hunter/brakeman"
|
8
9
|
require "code_hunter/rails_best_practices"
|
9
10
|
require "code_hunter/git_blamer"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
module CodeHunter
|
4
|
+
class Pendaxes
|
5
|
+
attr_reader :options
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
summarize(invoke)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def invoke
|
18
|
+
`pendaxes-oneshot #{options[:application_path]} --reporter json`
|
19
|
+
end
|
20
|
+
|
21
|
+
def summarize(json)
|
22
|
+
pendings = JSON.parse(json)["pendings"]
|
23
|
+
pendings.map do |pending|
|
24
|
+
{
|
25
|
+
:service => :pendaxes,
|
26
|
+
:path => pending["example"]["file"],
|
27
|
+
:line => pending["example"]["line"],
|
28
|
+
:message => pending["example"]["message"],
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/code_hunter/runner.rb
CHANGED
@@ -31,16 +31,16 @@ module CodeHunter
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def services
|
34
|
-
[
|
34
|
+
[
|
35
|
+
Pendaxes,
|
36
|
+
Brakeman,
|
37
|
+
RailsBestPractices,
|
38
|
+
].map {|klass| klass.new(options) }
|
35
39
|
end
|
36
40
|
|
37
41
|
def run_with_application_path
|
38
|
-
Dir.chdir(application_path) { run_without_application_path }
|
42
|
+
Dir.chdir(options[:application_path]) { run_without_application_path }
|
39
43
|
end
|
40
44
|
alias_method_chain :run, :application_path
|
41
|
-
|
42
|
-
def application_path
|
43
|
-
options[:application_path] || "./"
|
44
|
-
end
|
45
45
|
end
|
46
46
|
end
|
data/lib/code_hunter/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CodeHunter
|
4
|
+
describe Pendaxes do
|
5
|
+
let(:instance) do
|
6
|
+
described_class.new(:application_path => "./")
|
7
|
+
end
|
8
|
+
|
9
|
+
before do
|
10
|
+
instance.stub(:` => result)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Stub the result of pendaxes-oneshot command
|
14
|
+
let(:result) do
|
15
|
+
{
|
16
|
+
:pendings => [
|
17
|
+
:example => {
|
18
|
+
:file => "dir/filename.rb",
|
19
|
+
:line => 1,
|
20
|
+
:message => "message",
|
21
|
+
},
|
22
|
+
],
|
23
|
+
}.to_json
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#run" do
|
27
|
+
it "returns an Array of parsed pendings data" do
|
28
|
+
instance.run.should == [
|
29
|
+
{
|
30
|
+
:service => :pendaxes,
|
31
|
+
:path => "dir/filename.rb",
|
32
|
+
:line => 1,
|
33
|
+
:message => "message",
|
34
|
+
}
|
35
|
+
]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_hunter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: pendaxes
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - '='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.2.1
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - '='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.2.1
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: rspec
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,12 +144,14 @@ files:
|
|
128
144
|
- lib/code_hunter/brakeman/summarizer.rb
|
129
145
|
- lib/code_hunter/git_blamer.rb
|
130
146
|
- lib/code_hunter/option_parser.rb
|
147
|
+
- lib/code_hunter/pendaxes.rb
|
131
148
|
- lib/code_hunter/rails_best_practices.rb
|
132
149
|
- lib/code_hunter/rails_best_practices/invoker.rb
|
133
150
|
- lib/code_hunter/rails_best_practices/summarizer.rb
|
134
151
|
- lib/code_hunter/renderer.rb
|
135
152
|
- lib/code_hunter/runner.rb
|
136
153
|
- lib/code_hunter/version.rb
|
154
|
+
- spec/code_hunter/pendaxes_spec.rb
|
137
155
|
- spec/code_hunter/renderer_spec.rb
|
138
156
|
- spec/spec_helper.rb
|
139
157
|
homepage: https://github.com/r7kamura/code_hunter
|
@@ -161,5 +179,6 @@ signing_key:
|
|
161
179
|
specification_version: 3
|
162
180
|
summary: Code hunter
|
163
181
|
test_files:
|
182
|
+
- spec/code_hunter/pendaxes_spec.rb
|
164
183
|
- spec/code_hunter/renderer_spec.rb
|
165
184
|
- spec/spec_helper.rb
|