brakeman-min 4.3.1 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +24 -1
  3. data/README.md +35 -6
  4. data/bin/brakeman +2 -0
  5. data/lib/brakeman.rb +5 -3
  6. data/lib/brakeman/app_tree.rb +15 -1
  7. data/lib/brakeman/call_index.rb +7 -4
  8. data/lib/brakeman/checks.rb +16 -8
  9. data/lib/brakeman/checks/base_check.rb +2 -19
  10. data/lib/brakeman/checks/check_basic_auth_timing_attack.rb +1 -1
  11. data/lib/brakeman/checks/check_content_tag.rb +4 -4
  12. data/lib/brakeman/checks/check_create_with.rb +1 -1
  13. data/lib/brakeman/checks/check_cross_site_scripting.rb +3 -3
  14. data/lib/brakeman/checks/check_default_routes.rb +3 -3
  15. data/lib/brakeman/checks/check_deserialize.rb +1 -1
  16. data/lib/brakeman/checks/check_detailed_exceptions.rb +1 -1
  17. data/lib/brakeman/checks/check_digest_dos.rb +4 -4
  18. data/lib/brakeman/checks/check_escape_function.rb +1 -1
  19. data/lib/brakeman/checks/check_execute.rb +5 -4
  20. data/lib/brakeman/checks/check_file_access.rb +13 -3
  21. data/lib/brakeman/checks/check_file_disclosure.rb +1 -1
  22. data/lib/brakeman/checks/check_filter_skipping.rb +1 -1
  23. data/lib/brakeman/checks/check_forgery_setting.rb +3 -3
  24. data/lib/brakeman/checks/check_header_dos.rb +3 -3
  25. data/lib/brakeman/checks/check_i18n_xss.rb +3 -3
  26. data/lib/brakeman/checks/check_jruby_xml.rb +1 -1
  27. data/lib/brakeman/checks/check_json_encoding.rb +3 -3
  28. data/lib/brakeman/checks/check_json_parsing.rb +8 -11
  29. data/lib/brakeman/checks/check_link_to.rb +3 -3
  30. data/lib/brakeman/checks/check_link_to_href.rb +2 -2
  31. data/lib/brakeman/checks/check_mail_to.rb +3 -3
  32. data/lib/brakeman/checks/check_mime_type_dos.rb +1 -1
  33. data/lib/brakeman/checks/check_model_attributes.rb +4 -4
  34. data/lib/brakeman/checks/check_model_serialize.rb +1 -1
  35. data/lib/brakeman/checks/check_nested_attributes.rb +3 -3
  36. data/lib/brakeman/checks/check_nested_attributes_bypass.rb +1 -1
  37. data/lib/brakeman/checks/check_number_to_currency.rb +4 -4
  38. data/lib/brakeman/checks/check_quote_table_name.rb +2 -2
  39. data/lib/brakeman/checks/check_regex_dos.rb +1 -1
  40. data/lib/brakeman/checks/check_render.rb +2 -2
  41. data/lib/brakeman/checks/check_render_dos.rb +1 -1
  42. data/lib/brakeman/checks/check_render_inline.rb +1 -1
  43. data/lib/brakeman/checks/check_response_splitting.rb +1 -1
  44. data/lib/brakeman/checks/check_route_dos.rb +1 -1
  45. data/lib/brakeman/checks/check_safe_buffer_manipulation.rb +1 -1
  46. data/lib/brakeman/checks/check_sanitize_methods.rb +3 -3
  47. data/lib/brakeman/checks/check_secrets.rb +1 -1
  48. data/lib/brakeman/checks/check_select_tag.rb +1 -1
  49. data/lib/brakeman/checks/check_select_vulnerability.rb +1 -1
  50. data/lib/brakeman/checks/check_session_manipulation.rb +1 -1
  51. data/lib/brakeman/checks/check_session_settings.rb +1 -1
  52. data/lib/brakeman/checks/check_simple_format.rb +2 -2
  53. data/lib/brakeman/checks/check_single_quotes.rb +14 -10
  54. data/lib/brakeman/checks/check_skip_before_filter.rb +2 -2
  55. data/lib/brakeman/checks/check_sprockets_path_traversal.rb +39 -0
  56. data/lib/brakeman/checks/check_sql.rb +1 -1
  57. data/lib/brakeman/checks/check_sql_cves.rb +2 -2
  58. data/lib/brakeman/checks/check_strip_tags.rb +10 -8
  59. data/lib/brakeman/checks/check_symbol_dos.rb +1 -1
  60. data/lib/brakeman/checks/check_symbol_dos_cve.rb +1 -1
  61. data/lib/brakeman/checks/check_translate_bug.rb +7 -7
  62. data/lib/brakeman/checks/check_unsafe_reflection.rb +1 -1
  63. data/lib/brakeman/checks/check_unscoped_find.rb +1 -1
  64. data/lib/brakeman/checks/check_validation_regex.rb +1 -1
  65. data/lib/brakeman/checks/check_weak_hash.rb +18 -19
  66. data/lib/brakeman/checks/check_xml_dos.rb +1 -1
  67. data/lib/brakeman/checks/check_yaml_parsing.rb +1 -1
  68. data/lib/brakeman/format/style.css +8 -0
  69. data/lib/brakeman/messages.rb +220 -0
  70. data/lib/brakeman/options.rb +13 -0
  71. data/lib/brakeman/parsers/template_parser.rb +2 -2
  72. data/lib/brakeman/processors/alias_processor.rb +7 -0
  73. data/lib/brakeman/processors/config_processor.rb +4 -1
  74. data/lib/brakeman/processors/gem_processor.rb +30 -2
  75. data/lib/brakeman/processors/lib/call_conversion_helper.rb +2 -1
  76. data/lib/brakeman/processors/lib/rails3_route_processor.rb +0 -2
  77. data/lib/brakeman/processors/lib/rails4_config_processor.rb +18 -0
  78. data/lib/brakeman/processors/lib/render_helper.rb +5 -0
  79. data/lib/brakeman/processors/lib/render_path.rb +15 -0
  80. data/lib/brakeman/processors/library_processor.rb +1 -1
  81. data/lib/brakeman/report/report_base.rb +17 -161
  82. data/lib/brakeman/report/report_csv.rb +17 -0
  83. data/lib/brakeman/report/report_html.rb +34 -31
  84. data/lib/brakeman/report/report_json.rb +21 -0
  85. data/lib/brakeman/report/report_markdown.rb +13 -6
  86. data/lib/brakeman/report/report_table.rb +157 -0
  87. data/lib/brakeman/report/report_tabs.rb +3 -1
  88. data/lib/brakeman/report/report_text.rb +16 -0
  89. data/lib/brakeman/scanner.rb +5 -1
  90. data/lib/brakeman/tracker/config.rb +1 -1
  91. data/lib/brakeman/util.rb +0 -17
  92. data/lib/brakeman/version.rb +1 -1
  93. data/lib/brakeman/warning.rb +9 -4
  94. data/lib/brakeman/warning_codes.rb +1 -0
  95. metadata +9 -6
@@ -1,6 +1,8 @@
1
+ require 'brakeman/report/report_table'
2
+
1
3
  #Generated tab-separated output suitable for the Jenkins Brakeman Plugin:
2
4
  #https://github.com/presidentbeef/brakeman-jenkins-plugin
3
- class Brakeman::Report::Tabs < Brakeman::Report::Base
5
+ class Brakeman::Report::Tabs < Brakeman::Report::Table
4
6
  def generate_report
5
7
  [[:generic_warnings, "General"], [:controller_warnings, "Controller"],
6
8
  [:model_warnings, "Model"], [:template_warnings, "Template"]].map do |meth, category|
@@ -33,6 +33,22 @@ class Brakeman::Report::Text < Brakeman::Report::Base
33
33
  end
34
34
  end
35
35
 
36
+ def generate_controllers
37
+ double_space "Controller Overview", controller_information.map { |ci|
38
+ controller = [
39
+ label("Controller", ci["Name"]),
40
+ label("Parent", ci["Parent"]),
41
+ label("Routes", ci["Routes"])
42
+ ]
43
+
44
+ if ci["Includes"] and not ci["Includes"].empty?
45
+ controller.insert(2, label("Includes", ci["Includes"]))
46
+ end
47
+
48
+ controller
49
+ }
50
+ end
51
+
36
52
  def generate_header
37
53
  [
38
54
  header("Brakeman Report"),
@@ -143,7 +143,11 @@ class Brakeman::Scanner
143
143
  gem_files[:gemlock] = { :src => @app_tree.read("gems.locked"), :file => "gems.locked" }
144
144
  end
145
145
 
146
- if gem_files[:gemfile] or gem_files[:gemlock]
146
+ if @app_tree.gemspec
147
+ gem_files[:gemspec] = { :src => parse_ruby(@app_tree.read(@app_tree.gemspec)), :file => @app_tree.gemspec }
148
+ end
149
+
150
+ if not gem_files.empty?
147
151
  @processor.process_gems gem_files
148
152
  end
149
153
  rescue => e
@@ -81,7 +81,7 @@ module Brakeman
81
81
  def set_rails_version
82
82
  # Ignore ~>, etc. when using values from Gemfile
83
83
  version = gem_version(:rails) || gem_version(:railties)
84
- if version and version.match(/(\d+\.\d+\.\d+.*)/)
84
+ if version and version.match(/(\d+\.\d+(\.\d+.*)?)/)
85
85
  @rails_version = $1
86
86
 
87
87
  if tracker.options[:rails3].nil? and tracker.options[:rails4].nil?
@@ -483,21 +483,4 @@ module Brakeman::Util
483
483
  end
484
484
  end.join
485
485
  end
486
-
487
- # rely on Terminal::Table to build the structure, extract the data out in CSV format
488
- def table_to_csv table
489
- return "" unless table
490
-
491
- Brakeman.load_brakeman_dependency 'terminal-table'
492
- headings = table.headings
493
- if headings.is_a? Array
494
- headings = headings.first
495
- end
496
-
497
- output = CSV.generate_line(headings.cells.map{|cell| cell.to_s.strip})
498
- table.rows.each do |row|
499
- output << CSV.generate_line(row.cells.map{|cell| cell.to_s.strip})
500
- end
501
- output
502
- end
503
486
  end
@@ -1,3 +1,3 @@
1
1
  module Brakeman
2
- Version = "4.3.1"
2
+ Version = "4.4.0"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require 'json'
2
2
  require 'digest/sha2'
3
3
  require 'brakeman/warning_codes'
4
+ require 'brakeman/messages'
4
5
 
5
6
  #The Warning class stores information about warnings
6
7
  class Brakeman::Warning
@@ -115,6 +116,10 @@ class Brakeman::Warning
115
116
 
116
117
  Brakeman.debug("Warning created without warning code: #{options[:warning_code]}") unless @warning_code
117
118
 
119
+ if options[:message].is_a? String
120
+ @message = Brakeman::Messages::Message.new(options[:message])
121
+ end
122
+
118
123
  @format_message = nil
119
124
  @row = nil
120
125
  end
@@ -176,7 +181,7 @@ class Brakeman::Warning
176
181
  def format_message
177
182
  return @format_message if @format_message
178
183
 
179
- @format_message = self.message.dup
184
+ @format_message = self.message.to_s.dup
180
185
 
181
186
  if self.line
182
187
  @format_message << " near line #{self.line}"
@@ -208,9 +213,9 @@ class Brakeman::Warning
208
213
 
209
214
  #Generates a hash suitable for inserting into a table
210
215
  def to_row type = :warning
211
- @row = { "Confidence" => self.confidence,
216
+ @row = { "Confidence" => TEXT_CONFIDENCE[self.confidence],
212
217
  "Warning Type" => self.warning_type.to_s,
213
- "Message" => self.format_message }
218
+ "Message" => self.message }
214
219
 
215
220
  case type
216
221
  when :template
@@ -267,7 +272,7 @@ class Brakeman::Warning
267
272
  :warning_code => @warning_code,
268
273
  :fingerprint => self.fingerprint,
269
274
  :check_name => self.check.gsub(/^Brakeman::Check/, ''),
270
- :message => self.message,
275
+ :message => self.message.to_s,
271
276
  :file => self.file,
272
277
  :line => self.line,
273
278
  :link => self.link,
@@ -109,6 +109,7 @@ module Brakeman::WarningCodes
109
109
  :dangerous_permit_key => 105,
110
110
  :CVE_2018_8048 => 106,
111
111
  :CVE_2018_3741 => 107,
112
+ :CVE_2018_3760 => 108,
112
113
  }
113
114
 
114
115
  def self.code name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brakeman-min
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.1
4
+ version: 4.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Collins
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - brakeman-public_cert.pem
12
- date: 2018-06-07 00:00:00.000000000 Z
12
+ date: 2019-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 3.11.0
34
+ version: '3.12'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 3.11.0
41
+ version: '3.12'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: sexp_processor
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -154,6 +154,7 @@ files:
154
154
  - lib/brakeman/checks/check_simple_format.rb
155
155
  - lib/brakeman/checks/check_single_quotes.rb
156
156
  - lib/brakeman/checks/check_skip_before_filter.rb
157
+ - lib/brakeman/checks/check_sprockets_path_traversal.rb
157
158
  - lib/brakeman/checks/check_sql.rb
158
159
  - lib/brakeman/checks/check_sql_cves.rb
159
160
  - lib/brakeman/checks/check_ssl_verify.rb
@@ -173,6 +174,7 @@ files:
173
174
  - lib/brakeman/differ.rb
174
175
  - lib/brakeman/file_parser.rb
175
176
  - lib/brakeman/format/style.css
177
+ - lib/brakeman/messages.rb
176
178
  - lib/brakeman/options.rb
177
179
  - lib/brakeman/parsers/rails2_erubis.rb
178
180
  - lib/brakeman/parsers/rails2_xss_plugin_erubis.rb
@@ -199,6 +201,7 @@ files:
199
201
  - lib/brakeman/processors/lib/rails2_route_processor.rb
200
202
  - lib/brakeman/processors/lib/rails3_config_processor.rb
201
203
  - lib/brakeman/processors/lib/rails3_route_processor.rb
204
+ - lib/brakeman/processors/lib/rails4_config_processor.rb
202
205
  - lib/brakeman/processors/lib/render_helper.rb
203
206
  - lib/brakeman/processors/lib/render_path.rb
204
207
  - lib/brakeman/processors/lib/route_helper.rb
@@ -255,7 +258,7 @@ files:
255
258
  - lib/ruby_parser/bm_sexp_processor.rb
256
259
  homepage: http://brakemanscanner.org
257
260
  licenses:
258
- - MIT
261
+ - CC-BY-NC-SA-4.0
259
262
  metadata: {}
260
263
  post_install_message:
261
264
  rdoc_options: []
@@ -273,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
273
276
  version: '0'
274
277
  requirements: []
275
278
  rubyforge_project:
276
- rubygems_version: 2.7.6
279
+ rubygems_version: 2.7.8
277
280
  signing_key:
278
281
  specification_version: 4
279
282
  summary: Security vulnerability scanner for Ruby on Rails.