guard-brakeman 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  require 'guard'
2
2
  require 'guard/guard'
3
3
  require 'brakeman'
4
- require 'brakeman/tracker'
4
+ require 'brakeman/scanner'
5
5
 
6
6
  module Guard
7
7
 
@@ -9,10 +9,6 @@ module Guard
9
9
  # Guard events: `start`, `stop`, `reload`, `run_all` and `run_on_change`.
10
10
  #
11
11
  class Brakeman < Guard
12
-
13
- autoload :Runner, 'guard/brakeman/runner'
14
- autoload :Inspector, 'guard/brakeman/inspector'
15
-
16
12
  # Initialize Guard::Brakeman.
17
13
  #
18
14
  # @param [Array<Guard::Watcher>] watchers the watchers in the Guard block
@@ -20,12 +16,11 @@ module Guard
20
16
  # @option options [Boolean] :notification show notifications
21
17
  # @option options [Boolean] :format use a different brakeman format when running individual features - not implemented
22
18
  # @option options [Boolean] :output specify the output file - not implemented
23
- # @option options [Array<String>] :disabled specify tests to skip (comma separated) - not implemented"
19
+ # @option options [Array<String>] :disabled specify tests to skip (comma separated) - not implemented
24
20
  #
25
21
  def initialize(watchers = [], options = { })
26
22
  super
27
23
  @last_failed = false
28
- @failed_paths = []
29
24
  end
30
25
 
31
26
  # Gets called once when Guard starts.
@@ -33,8 +28,9 @@ module Guard
33
28
  # @raise [:task_has_failed] when stop has failed
34
29
  #
35
30
  def start
36
- @tracker = ::Brakeman.run :app_path => '.'
37
- print_failed @tracker
31
+ options = ::Brakeman::set_options(:app_path => '.')
32
+ @scanner = ::Brakeman::Scanner.new(options)
33
+ @tracker = @scanner.process
38
34
  end
39
35
 
40
36
  # Gets called when all checks should be run.
@@ -43,29 +39,9 @@ module Guard
43
39
  #
44
40
  def run_all
45
41
  puts 'running all'
46
- @tracker = ::Brakeman.run :app_path => '.'
47
-
48
- passed = clean_report?(@tracker)
49
-
50
- print_failed @tracker
51
-
52
- if passed
53
- @failed_paths = []
54
- else
55
- @failed_paths = get_failed_paths(@tracker)
56
- end
57
-
58
- @last_failed = !passed
59
-
60
- throw :task_has_failed unless passed
61
- end
62
-
63
- # Gets called when the Guard should reload itself.
64
- #
65
- # @raise [:task_has_failed] when stop has failed
66
- #
67
- def reload
68
- @failed_paths = []
42
+ @tracker.run_checks
43
+ print_failed(@tracker.checks)
44
+ throw :task_has_failed if @tracker.checks.all_warnings.empty?
69
45
  end
70
46
 
71
47
  # Gets called when watched paths and files have changes.
@@ -74,25 +50,18 @@ module Guard
74
50
  # @raise [:task_has_failed] when stop has failed
75
51
  #
76
52
  def run_on_change(paths)
77
- report = Runner.run(paths, @tracker, options)
78
- print_failed report
79
-
80
- passed = !report.all_warnings.any?
81
-
82
- throw :task_has_failed unless passed
53
+ report = ::Brakeman::rescan(@tracker, paths)
54
+ print_failed(report)
55
+ throw :task_has_failed if report.any_warnings?
83
56
  end
84
57
 
85
58
  private
86
59
 
87
- def print_failed tracker
88
- checks = tracker.is_a?(::Brakeman::Tracker) ? tracker.checks.all_warnings : tracker.all_warnings
89
- checks.each do |w|
60
+ def print_failed report
61
+ puts "\n------ brakeman warnings --------\n"
62
+ report.all_warnings.each do |w|
90
63
  puts w.to_row
91
64
  end
92
65
  end
93
-
94
- def clean_report? tracker
95
- tracker.checks.all_warnings.empty? && tracker.errors.empty?
96
- end
97
66
  end
98
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-brakeman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-17 00:00:00.000000000 Z
12
+ date: 2012-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard
16
- requirement: &70245169581980 !ruby/object:Gem::Requirement
16
+ requirement: &70314479970140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.2.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70245169581980
24
+ version_requirements: *70314479970140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: brakeman
27
- requirement: &70245169581500 !ruby/object:Gem::Requirement
27
+ requirement: &70314479969620 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.2'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70245169581500
35
+ version_requirements: *70314479969620
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70245169581040 !ruby/object:Gem::Requirement
38
+ requirement: &70314479969160 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.6.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70245169581040
46
+ version_requirements: *70314479969160
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard-rspec
49
- requirement: &70245169580540 !ruby/object:Gem::Requirement
49
+ requirement: &70314479968680 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.3.1
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70245169580540
57
+ version_requirements: *70314479968680
58
58
  description: Guard::Brakeman automatically scans your Rails app for vulnerabilities
59
59
  email:
60
60
  - neil@matatall.com
@@ -62,8 +62,6 @@ executables: []
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
- - lib/guard/brakeman/inspector.rb
66
- - lib/guard/brakeman/runner.rb
67
65
  - lib/guard/brakeman/templates/Guardfile
68
66
  - lib/guard/brakeman.rb
69
67
  - LICENSE
@@ -1,15 +0,0 @@
1
- module Guard
2
- class Brakeman
3
-
4
- # The inspector verifies of the changed paths are valid
5
- # for Guard::Cucumber.
6
- #
7
- module Inspector
8
- class << self
9
- def clean paths
10
- return paths
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,31 +0,0 @@
1
- require 'brakeman'
2
-
3
- module Guard
4
- class Brakeman
5
-
6
- # The Cucumber runner handles the execution of the cucumber binary.
7
- #
8
- module Runner
9
- class << self
10
-
11
- # Run the supplied features.
12
- #
13
- # @param [Array<String>] paths the feature files or directories
14
- # @param [Hash] options the options for the execution
15
- # @option options [Boolean] :bundler use bundler or not
16
- # @option options [Array<String>] :rvm a list of rvm version to use for the test
17
- # @option options [Boolean] :notification show notifications
18
- # @return [Boolean] the status of the execution
19
- #
20
- def run(paths, tracker, options = { })
21
- return false if paths.empty?
22
-
23
- message = options[:message] || (paths == ['.'] ? 'Run brakeman on the whole project' : "Run brakeman checks #{ paths.join(' ') }")
24
- UI.info message, :reset => true
25
-
26
- ::Brakeman.rescan(tracker, paths)
27
- end
28
- end
29
- end
30
- end
31
- end