guard-brakeman 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +11 -5
  2. data/lib/guard/brakeman.rb +25 -5
  3. metadata +6 -6
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Guard::Brakeman [![Build Status](https://secure.travis-ci.org/oreoshake/guard-brakeman.png)](http://travis-ci.org/oreoshake/guard-brakeman)
1
+ # Guard::Brakeman [![Build Status](https://secure.travis-ci.org/guard/guard-brakeman.png)](http://travis-ci.org/oreoshake/guard-brakeman)
2
2
 
3
3
  Guard::Brakeman allows you to automatically run [Brakeman](http://brakemanscanner.org/) tests when files are modified.
4
4
 
@@ -22,6 +22,10 @@ Add the default Guard::Brakeman template to your `Guardfile` by running:
22
22
  $ guard init brakeman
23
23
  ```
24
24
 
25
+ ## Use sublime Text 2?
26
+
27
+ Check out [sublime_guard](https://github.com/cyphactor/sublime_guard)! It gives you control Guard without leaving the editor. This is even more powerful with Growl notifications. Enter distraction-free mode and never leave!
28
+
25
29
  ## Usage
26
30
 
27
31
  Please read the [Guard usage documentation](https://github.com/guard/guard#readme).
@@ -46,10 +50,12 @@ Please read the [Guard documentation](http://github.com/guard/guard#readme) for
46
50
  ### List of available options
47
51
 
48
52
  ```ruby
49
- :notifications => false # display Growl notifications, defaults to true
50
- :run_on_start => true # run all checks on startup, defaults to false
51
- :min_confidence => 3 # only alert on warnings above a threshold, defaults to 1
52
- :chatty => true # notify on ALL changes. Defaults to false, only new or fixed warnings trigger a Growl
53
+ :output_file => 'donkey' # write the results to the specified file, optinally supply extension which will be used for :output_format
54
+ :output_format => 'html' # specify the output format
55
+ :notifications => false # display Growl notifications, defaults to true
56
+ :run_on_start => true # run all checks on startup, defaults to false
57
+ :min_confidence => 3 # only alert on warnings above a threshold, defaults to 1
58
+ :chatty => true # notify on ALL changes. Defaults to false, only new or fixed warnings trigger a Growl
53
59
  ```
54
60
 
55
61
  ## Brakeman configuration
@@ -36,14 +36,14 @@ module Guard
36
36
  # @raise [:task_has_failed] when stop has failed
37
37
  #
38
38
  def start
39
- scanner_opts = ::Brakeman::set_options({:app_path => '.'}.merge(@options))
40
- @scanner = ::Brakeman::Scanner.new(scanner_opts)
39
+ @scanner_opts = ::Brakeman::set_options({:app_path => '.'}.merge(@options))
40
+ @scanner = ::Brakeman::Scanner.new(@scanner_opts)
41
41
  @tracker = @scanner.process
42
42
 
43
43
  if @options[:run_on_start]
44
44
  run_all
45
45
  elsif @options[:chatty]
46
- Notifier.notify("Brakeman is ready to work!", :title => "Brakeman started", :image => :pending)
46
+ ::Guard::Notifier.notify("Brakeman is ready to work!", :title => "Brakeman started", :image => :pending)
47
47
  end
48
48
  end
49
49
 
@@ -83,8 +83,15 @@ module Guard
83
83
 
84
84
  puts all_warnings.sort_by { |w| w.confidence }
85
85
 
86
+ message = "#{all_warnings.count} brakeman findings"
87
+
88
+ if @options[:output_file]
89
+ write_report
90
+ message += "\nResults written to #{@options[:output_file]}"
91
+ end
92
+
86
93
  if @options[:chatty] && all_warnings.any?
87
- Notifier.notify("#{all_warnings.count} brakeman findings", :title => "Full Brakeman results", :image => icon)
94
+ ::Guard::Notifier.notify(message, :title => "Full Brakeman results", :image => icon)
88
95
  end
89
96
  end
90
97
 
@@ -132,13 +139,26 @@ module Guard
132
139
  puts existing_warnings.sort_by { |w| w.confidence }
133
140
  end
134
141
 
142
+
143
+
144
+ if @options[:output_file]
145
+ write_report
146
+ message += "\nResults written to #{@options[:output_file]}"
147
+ end
148
+
135
149
  if @options[:notifications] && should_alert
136
- Notifier.notify(message.chomp, :title => "Brakeman results", :image => icon)
150
+ ::Guard::Notifier.notify(message.chomp, :title => "Brakeman results", :image => icon)
137
151
  end
138
152
  end
139
153
 
140
154
  def reject_below_threshold(warnings)
141
155
  warnings.reject {|w| w.confidence > (3 - @options[:min_confidence].to_i)}
142
156
  end
157
+
158
+ def write_report
159
+ File.open @options[:output_file], "w" do |f|
160
+ f.puts @tracker.report.send(@scanner_opts[:output_format])
161
+ end
162
+ end
143
163
  end
144
164
  end
metadata CHANGED
@@ -1,21 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-brakeman
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Neil Matatall
14
+ - Justin Collins
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2012-02-02 00:00:00 -08:00
19
+ date: 2012-02-13 00:00:00 -08:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -52,7 +53,6 @@ dependencies:
52
53
  version_requirements: *id002
53
54
  description: Guard::Brakeman automatically scans your Rails app for vulnerabilities
54
55
  email:
55
- - neil@matatall.com
56
56
  executables: []
57
57
 
58
58
  extensions: []
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  requirements: []
97
97
 
98
98
  rubyforge_project: guard-brakeman
99
- rubygems_version: 1.6.1
99
+ rubygems_version: 1.4.2
100
100
  signing_key:
101
101
  specification_version: 3
102
102
  summary: Guard gem for Brakeman