brakeman 1.5.3 → 1.6.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/bin/brakeman +20 -6
  2. data/lib/brakeman.rb +21 -1
  3. data/lib/brakeman/checks.rb +2 -7
  4. data/lib/brakeman/checks/base_check.rb +31 -26
  5. data/lib/brakeman/checks/check_basic_auth.rb +1 -7
  6. data/lib/brakeman/checks/check_cross_site_scripting.rb +38 -33
  7. data/lib/brakeman/checks/check_evaluation.rb +2 -1
  8. data/lib/brakeman/checks/check_execute.rb +5 -1
  9. data/lib/brakeman/checks/check_file_access.rb +6 -4
  10. data/lib/brakeman/checks/check_link_to.rb +8 -5
  11. data/lib/brakeman/checks/check_link_to_href.rb +6 -5
  12. data/lib/brakeman/checks/check_mail_to.rb +2 -4
  13. data/lib/brakeman/checks/check_mass_assignment.rb +12 -6
  14. data/lib/brakeman/checks/check_redirect.rb +17 -14
  15. data/lib/brakeman/checks/check_render.rb +4 -4
  16. data/lib/brakeman/checks/check_send.rb +4 -2
  17. data/lib/brakeman/checks/check_session_settings.rb +16 -21
  18. data/lib/brakeman/checks/check_skip_before_filter.rb +2 -4
  19. data/lib/brakeman/checks/check_sql.rb +8 -7
  20. data/lib/brakeman/checks/check_validation_regex.rb +2 -4
  21. data/lib/brakeman/checks/check_without_protection.rb +8 -9
  22. data/lib/brakeman/differ.rb +61 -0
  23. data/lib/brakeman/format/style.css +4 -0
  24. data/lib/brakeman/options.rb +8 -0
  25. data/lib/brakeman/processors/alias_processor.rb +5 -7
  26. data/lib/brakeman/processors/controller_alias_processor.rb +10 -3
  27. data/lib/brakeman/processors/erb_template_processor.rb +2 -0
  28. data/lib/brakeman/processors/erubis_template_processor.rb +2 -0
  29. data/lib/brakeman/processors/gem_processor.rb +8 -0
  30. data/lib/brakeman/processors/haml_template_processor.rb +2 -0
  31. data/lib/brakeman/processors/lib/rails2_route_processor.rb +2 -6
  32. data/lib/brakeman/processors/lib/rails3_route_processor.rb +2 -4
  33. data/lib/brakeman/processors/lib/render_helper.rb +3 -1
  34. data/lib/brakeman/processors/library_processor.rb +4 -6
  35. data/lib/brakeman/processors/template_alias_processor.rb +1 -1
  36. data/lib/brakeman/report.rb +257 -198
  37. data/lib/brakeman/rescanner.rb +112 -10
  38. data/lib/brakeman/scanner.rb +3 -4
  39. data/lib/brakeman/templates/controller_overview.html.erb +18 -0
  40. data/lib/brakeman/templates/controller_warnings.html.erb +17 -0
  41. data/lib/brakeman/templates/error_overview.html.erb +14 -0
  42. data/lib/brakeman/templates/header.html.erb +38 -0
  43. data/lib/brakeman/templates/model_warnings.html.erb +17 -0
  44. data/lib/brakeman/templates/overview.html.erb +28 -0
  45. data/lib/brakeman/templates/security_warnings.html.erb +28 -0
  46. data/lib/brakeman/templates/template_overview.html.erb +17 -0
  47. data/lib/brakeman/templates/view_warnings.html.erb +17 -0
  48. data/lib/brakeman/templates/warning_overview.html.erb +13 -0
  49. data/lib/brakeman/tracker.rb +1 -1
  50. data/lib/brakeman/util.rb +24 -4
  51. data/lib/brakeman/version.rb +1 -1
  52. data/lib/brakeman/warning.rb +11 -3
  53. data/lib/ruby_parser/bm_sexp.rb +5 -11
  54. metadata +84 -23
@@ -1,3 +1,3 @@
1
1
  module Brakeman
2
- Version = "1.5.3"
2
+ Version = "1.6.0.pre1"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  #The Warning class stores information about warnings
2
2
  class Brakeman::Warning
3
3
  attr_reader :called_from, :check, :class, :confidence, :controller,
4
- :line, :method, :model, :template, :warning_set, :warning_type
4
+ :line, :method, :model, :template, :user_input, :warning_set, :warning_type
5
5
 
6
6
  attr_accessor :code, :context, :file, :message
7
7
 
@@ -12,7 +12,7 @@ class Brakeman::Warning
12
12
  @view_name = nil
13
13
 
14
14
  [:called_from, :check, :class, :code, :confidence, :controller, :file, :line,
15
- :message, :method, :model, :template, :warning_set, :warning_type].each do |option|
15
+ :message, :method, :model, :template, :user_input, :warning_set, :warning_type].each do |option|
16
16
 
17
17
  self.instance_variable_set("@#{option}", options[option])
18
18
  end
@@ -74,6 +74,12 @@ class Brakeman::Warning
74
74
  Brakeman::OutputProcessor.new.format(self.code).gsub(/(\t|\r|\n)+/, " ")
75
75
  end
76
76
 
77
+ #Return String of the user input formatted and
78
+ #stripped of newlines and tabs.
79
+ def format_user_input
80
+ Brakeman::OutputProcessor.new.format(self.user_input).gsub(/(\t|\r|\n)+/, " ")
81
+ end
82
+
77
83
  #Return formatted warning message
78
84
  def format_message
79
85
  return @format_message if @format_message
@@ -91,7 +97,7 @@ class Brakeman::Warning
91
97
  @format_message
92
98
  end
93
99
 
94
- #Generates a hash suitable for inserting into a Ruport table
100
+ #Generates a hash suitable for inserting into a table
95
101
  def to_row type = :warning
96
102
  @row = { "Confidence" => self.confidence,
97
103
  "Warning Type" => self.warning_type.to_s,
@@ -140,8 +146,10 @@ class Brakeman::Warning
140
146
  { :warning_type => self.warning_type,
141
147
  :message => self.message,
142
148
  :file => self.file,
149
+ :line => self.line,
143
150
  :code => (@code && self.format_code),
144
151
  :location => location,
152
+ :user_input => (@user_input && self.format_user_input),
145
153
  :confidence => TEXT_CONFIDENCE[self.confidence]
146
154
  }
147
155
  end
@@ -20,7 +20,6 @@ class Sexp
20
20
  alias :node_type :sexp_type
21
21
  alias :values :sexp_body # TODO: retire
22
22
 
23
- alias :old_init :initialize
24
23
  alias :old_push :<<
25
24
  alias :old_line :line
26
25
  alias :old_line_set :line=
@@ -30,18 +29,13 @@ class Sexp
30
29
  alias :old_fara :find_and_replace_all
31
30
  alias :old_find_node :find_node
32
31
 
33
- def initialize *args
34
- old_init(*args)
35
- @original_line = nil
36
- @my_hash_value = nil
37
- end
38
-
39
32
  def original_line line = nil
40
33
  if line
41
34
  @my_hash_value = nil
42
35
  @original_line = line
36
+ self
43
37
  else
44
- @original_line
38
+ @original_line ||= nil
45
39
  end
46
40
  end
47
41
 
@@ -53,9 +47,9 @@ class Sexp
53
47
  @my_hash_value ||= super
54
48
  end
55
49
 
56
- def line *args
57
- @my_hash_value = nil
58
- old_line(*args)
50
+ def line num = nil
51
+ @my_hash_value = nil if num
52
+ old_line(num)
59
53
  end
60
54
 
61
55
  def line= *args
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brakeman
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease:
4
+ hash: -1001353691
5
+ prerelease: 6
6
6
  segments:
7
7
  - 1
8
- - 5
9
- - 3
10
- version: 1.5.3
8
+ - 6
9
+ - 0
10
+ - pre
11
+ - 1
12
+ version: 1.6.0.pre1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Justin Collins
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2012-04-10 00:00:00 Z
20
+ date: 2012-04-19 00:00:00 Z
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: activesupport
@@ -46,9 +48,25 @@ dependencies:
46
48
  type: :runtime
47
49
  version_requirements: *id002
48
50
  - !ruby/object:Gem::Dependency
49
- name: ruby2ruby
51
+ name: ruby_parser
50
52
  prerelease: false
51
53
  requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - "="
57
+ - !ruby/object:Gem::Version
58
+ hash: 1
59
+ segments:
60
+ - 2
61
+ - 3
62
+ - 1
63
+ version: 2.3.1
64
+ type: :runtime
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: ruby2ruby
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
52
70
  none: false
53
71
  requirements:
54
72
  - - ~>
@@ -59,11 +77,41 @@ dependencies:
59
77
  - 2
60
78
  version: "1.2"
61
79
  type: :runtime
62
- version_requirements: *id003
80
+ version_requirements: *id004
63
81
  - !ruby/object:Gem::Dependency
64
- name: ruport
82
+ name: terminal-table
65
83
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ hash: 7
90
+ segments:
91
+ - 1
92
+ - 4
93
+ version: "1.4"
94
+ type: :runtime
95
+ version_requirements: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ name: fastercsv
98
+ prerelease: false
99
+ requirement: &id006 !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ~>
103
+ - !ruby/object:Gem::Version
104
+ hash: 5
105
+ segments:
106
+ - 1
107
+ - 5
108
+ version: "1.5"
109
+ type: :runtime
110
+ version_requirements: *id006
111
+ - !ruby/object:Gem::Dependency
112
+ name: highline
113
+ prerelease: false
114
+ requirement: &id007 !ruby/object:Gem::Requirement
67
115
  none: false
68
116
  requirements:
69
117
  - - ~>
@@ -74,11 +122,11 @@ dependencies:
74
122
  - 6
75
123
  version: "1.6"
76
124
  type: :runtime
77
- version_requirements: *id004
125
+ version_requirements: *id007
78
126
  - !ruby/object:Gem::Dependency
79
127
  name: erubis
80
128
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
129
+ requirement: &id008 !ruby/object:Gem::Requirement
82
130
  none: false
83
131
  requirements:
84
132
  - - ~>
@@ -89,11 +137,11 @@ dependencies:
89
137
  - 6
90
138
  version: "2.6"
91
139
  type: :runtime
92
- version_requirements: *id005
140
+ version_requirements: *id008
93
141
  - !ruby/object:Gem::Dependency
94
142
  name: haml
95
143
  prerelease: false
96
- requirement: &id006 !ruby/object:Gem::Requirement
144
+ requirement: &id009 !ruby/object:Gem::Requirement
97
145
  none: false
98
146
  requirements:
99
147
  - - ~>
@@ -104,11 +152,11 @@ dependencies:
104
152
  - 0
105
153
  version: "3.0"
106
154
  type: :runtime
107
- version_requirements: *id006
155
+ version_requirements: *id009
108
156
  - !ruby/object:Gem::Dependency
109
157
  name: sass
110
158
  prerelease: false
111
- requirement: &id007 !ruby/object:Gem::Requirement
159
+ requirement: &id010 !ruby/object:Gem::Requirement
112
160
  none: false
113
161
  requirements:
114
162
  - - ~>
@@ -119,7 +167,7 @@ dependencies:
119
167
  - 0
120
168
  version: "3.0"
121
169
  type: :runtime
122
- version_requirements: *id007
170
+ version_requirements: *id010
123
171
  description: Brakeman detects security vulnerabilities in Ruby on Rails applications via static analysis.
124
172
  email:
125
173
  executables:
@@ -133,7 +181,6 @@ files:
133
181
  - WARNING_TYPES
134
182
  - FEATURES
135
183
  - README.md
136
- - lib/brakeman/brakeman.rake
137
184
  - lib/ruby_parser/ruby18_parser.rb
138
185
  - lib/ruby_parser/ruby_parser_extras.rb
139
186
  - lib/ruby_parser/bm_sexp.rb
@@ -141,6 +188,7 @@ files:
141
188
  - lib/ruby_parser/ruby_parser.rb
142
189
  - lib/ruby_parser/ruby19_parser.rb
143
190
  - lib/brakeman/warning.rb
191
+ - lib/brakeman/differ.rb
144
192
  - lib/brakeman/processors/gem_processor.rb
145
193
  - lib/brakeman/processors/params_processor.rb
146
194
  - lib/brakeman/processors/controller_alias_processor.rb
@@ -166,6 +214,7 @@ files:
166
214
  - lib/brakeman/processors/config_processor.rb
167
215
  - lib/brakeman/processors/erubis_template_processor.rb
168
216
  - lib/brakeman/processors/template_processor.rb
217
+ - lib/brakeman/format/style.css
169
218
  - lib/brakeman/rescanner.rb
170
219
  - lib/brakeman/checks/check_send_file.rb
171
220
  - lib/brakeman/checks/check_translate_bug.rb
@@ -201,17 +250,27 @@ files:
201
250
  - lib/brakeman/tracker.rb
202
251
  - lib/brakeman/util.rb
203
252
  - lib/brakeman/report.rb
253
+ - lib/brakeman/templates/header.html.erb
254
+ - lib/brakeman/templates/warning_overview.html.erb
255
+ - lib/brakeman/templates/overview.html.erb
256
+ - lib/brakeman/templates/controller_warnings.html.erb
257
+ - lib/brakeman/templates/error_overview.html.erb
258
+ - lib/brakeman/templates/controller_overview.html.erb
259
+ - lib/brakeman/templates/security_warnings.html.erb
260
+ - lib/brakeman/templates/model_warnings.html.erb
261
+ - lib/brakeman/templates/view_warnings.html.erb
262
+ - lib/brakeman/templates/template_overview.html.erb
204
263
  - lib/brakeman/parsers/rails3_erubis.rb
205
264
  - lib/brakeman/parsers/rails2_xss_plugin_erubis.rb
206
265
  - lib/brakeman/parsers/rails2_erubis.rb
207
266
  - lib/brakeman/version.rb
208
267
  - lib/brakeman/call_index.rb
268
+ - lib/brakeman/brakeman.rake
209
269
  - lib/brakeman/options.rb
210
270
  - lib/brakeman/scanner.rb
211
271
  - lib/brakeman/checks.rb
212
272
  - lib/brakeman/processor.rb
213
273
  - lib/brakeman.rb
214
- - lib/brakeman/format/style.css
215
274
  homepage: http://brakemanscanner.org
216
275
  licenses: []
217
276
 
@@ -232,12 +291,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
232
291
  required_rubygems_version: !ruby/object:Gem::Requirement
233
292
  none: false
234
293
  requirements:
235
- - - ">="
294
+ - - ">"
236
295
  - !ruby/object:Gem::Version
237
- hash: 3
296
+ hash: 25
238
297
  segments:
239
- - 0
240
- version: "0"
298
+ - 1
299
+ - 3
300
+ - 1
301
+ version: 1.3.1
241
302
  requirements: []
242
303
 
243
304
  rubyforge_project: