guard-brakeman 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/guard/brakeman.rb +19 -23
  2. metadata +11 -11
@@ -24,9 +24,6 @@ module Guard
24
24
 
25
25
  # TODO mixing the use of this attr, good to match? Bad to couple?
26
26
  @options = {
27
- :notifications => true,
28
- :run_on_start => false,
29
- :chatty => false,
30
27
  :min_confidence => 1
31
28
  }.update(options)
32
29
  end
@@ -78,14 +75,14 @@ module Guard
78
75
  private
79
76
 
80
77
  def print_failed report
81
- UI.info "\n------ brakeman warnings --------\n"
82
-
83
- icon = report.all_warnings.count > 0 ? :failed : :success
84
-
85
- all_warnings = reject_below_threshold(report.all_warnings)
78
+ all_warnings = report.all_warnings
86
79
 
87
- puts all_warnings.sort_by { |w| w.confidence }
80
+ unless @options[:no_console_output]
81
+ UI.info "\n------ brakeman warnings --------\n"
82
+ puts all_warnings.sort_by { |w| w.confidence }
83
+ end
88
84
 
85
+ icon = all_warnings.count > 0 ? :failed : :success
89
86
  message = "#{all_warnings.count} brakeman findings"
90
87
 
91
88
  if @options[:output_file]
@@ -104,7 +101,8 @@ module Guard
104
101
  message = ""
105
102
  should_alert = false
106
103
 
107
- fixed_warnings = reject_below_threshold(report.fixed_warnings)
104
+ fixed_warnings = report.fixed_warnings
105
+
108
106
  if fixed_warnings.any?
109
107
  icon = :success
110
108
  results_notification = "#{fixed_warnings.length} fixed warning(s)\n"
@@ -113,11 +111,13 @@ module Guard
113
111
  should_alert = true
114
112
  message += results_notification
115
113
 
116
- puts fixed_warnings.sort_by { |w| w.confidence }
117
- puts
114
+ unless @options[:no_console_output]
115
+ puts fixed_warnings.sort_by { |w| w.confidence }
116
+ puts
117
+ end
118
118
  end
119
119
 
120
- new_warnings = reject_below_threshold(report.new_warnings)
120
+ new_warnings = report.new_warnings
121
121
  if new_warnings.any?
122
122
  new_warning_message = "#{new_warnings.length} new warning(s)\n"
123
123
  UI.error new_warning_message
@@ -126,11 +126,13 @@ module Guard
126
126
  should_alert = true
127
127
  icon = :failed
128
128
 
129
- puts new_warnings.sort_by { |w| w.confidence }
130
- puts
129
+ unless @options[:no_console_output]
130
+ puts new_warnings.sort_by { |w| w.confidence }
131
+ puts
132
+ end
131
133
  end
132
134
 
133
- existing_warnings = reject_below_threshold(report.existing_warnings)
135
+ existing_warnings = report.existing_warnings
134
136
  if existing_warnings.any?
135
137
  should_alert = true if @options[:chatty]
136
138
  icon ||= :pending
@@ -139,11 +141,9 @@ module Guard
139
141
  UI.warning existing_warning_message
140
142
  message += existing_warning_message
141
143
 
142
- puts existing_warnings.sort_by { |w| w.confidence }
144
+ puts existing_warnings.sort_by { |w| w.confidence } unless @options[:no_console_output]
143
145
  end
144
146
 
145
-
146
-
147
147
  if @options[:output_file]
148
148
  write_report
149
149
  message += "\nResults written to #{@options[:output_file]}"
@@ -154,10 +154,6 @@ module Guard
154
154
  end
155
155
  end
156
156
 
157
- def reject_below_threshold(warnings)
158
- warnings.reject {|w| w.confidence > (3 - @options[:min_confidence].to_i)}
159
- end
160
-
161
157
  def write_report
162
158
  File.open @options[:output_file], "w" do |f|
163
159
  f.puts @tracker.report.send(@options[:output_format])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-brakeman
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Neil Matatall
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-02-13 00:00:00 -08:00
19
+ date: 2012-04-09 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- hash: 19
30
+ hash: 21
31
31
  segments:
32
+ - 1
32
33
  - 0
33
- - 2
34
- - 2
35
- version: 0.2.2
34
+ - 1
35
+ version: 1.0.1
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
@@ -43,12 +43,12 @@ dependencies:
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- hash: 27
46
+ hash: 7
47
47
  segments:
48
48
  - 1
49
+ - 5
49
50
  - 2
50
- - 2
51
- version: 1.2.2
51
+ version: 1.5.2
52
52
  type: :runtime
53
53
  version_requirements: *id002
54
54
  description: Guard::Brakeman automatically scans your Rails app for vulnerabilities