brakeman 5.2.1 → 5.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +25 -0
  3. data/bundle/load.rb +4 -4
  4. data/bundle/ruby/2.7.0/gems/{parallel-1.21.0 → parallel-1.22.1}/MIT-LICENSE.txt +0 -0
  5. data/bundle/ruby/2.7.0/gems/{parallel-1.21.0 → parallel-1.22.1}/lib/parallel/processor_count.rb +2 -3
  6. data/bundle/ruby/2.7.0/gems/parallel-1.22.1/lib/parallel/version.rb +4 -0
  7. data/bundle/ruby/2.7.0/gems/{parallel-1.21.0 → parallel-1.22.1}/lib/parallel.rb +84 -4
  8. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/History.rdoc +28 -0
  9. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/Manifest.txt +2 -0
  10. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/README.rdoc +8 -6
  11. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/compare/normalize.rb +0 -0
  12. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/debugging.md +0 -0
  13. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/gauntlet.md +19 -18
  14. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/rp_extensions.rb +0 -0
  15. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/rp_stringscanner.rb +0 -0
  16. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby20_parser.rb +10973 -0
  17. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby20_parser.y +14 -27
  18. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby21_parser.rb +10980 -0
  19. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby21_parser.y +14 -27
  20. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby22_parser.rb +11123 -0
  21. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby22_parser.y +14 -27
  22. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby23_parser.rb +11132 -0
  23. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby23_parser.y +14 -27
  24. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby24_parser.rb +11231 -0
  25. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby24_parser.y +14 -27
  26. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby25_parser.rb +11231 -0
  27. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby25_parser.y +14 -27
  28. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby26_parser.rb +11253 -0
  29. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby26_parser.y +14 -27
  30. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby27_parser.rb +12980 -0
  31. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby27_parser.y +19 -41
  32. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby30_parser.rb +13242 -0
  33. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby30_parser.y +65 -90
  34. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby31_parser.rb +13622 -0
  35. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1/lib/ruby3_parser.yy → ruby_parser-3.19.1/lib/ruby31_parser.y} +110 -105
  36. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby3_parser.yy +3536 -0
  37. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_lexer.rb +0 -0
  38. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_lexer.rex +0 -0
  39. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_lexer.rex.rb +0 -0
  40. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_lexer_strings.rb +0 -0
  41. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_parser.rb +2 -0
  42. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_parser.yy +19 -41
  43. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_parser_extras.rb +55 -2
  44. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/tools/munge.rb +0 -0
  45. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/tools/ripper.rb +0 -0
  46. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/History.rdoc +6 -0
  47. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/Manifest.txt +0 -0
  48. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/README.rdoc +0 -0
  49. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/composite_sexp_processor.rb +0 -0
  50. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/pt_testcase.rb +7 -3
  51. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/sexp.rb +0 -0
  52. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/sexp_matcher.rb +0 -0
  53. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/sexp_processor.rb +1 -1
  54. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/strict_sexp.rb +0 -0
  55. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/unique.rb +0 -0
  56. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/COPYING +0 -0
  57. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/asciidoc.rb +0 -0
  58. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/babel.rb +0 -0
  59. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/bluecloth.rb +0 -0
  60. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/builder.rb +0 -0
  61. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/coffee.rb +0 -0
  62. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/commonmarker.rb +11 -1
  63. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/creole.rb +0 -0
  64. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/csv.rb +1 -1
  65. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/dummy.rb +0 -0
  66. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/erb.rb +0 -0
  67. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/erubi.rb +0 -0
  68. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/erubis.rb +0 -0
  69. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/etanni.rb +0 -0
  70. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/haml.rb +0 -0
  71. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/kramdown.rb +0 -0
  72. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/less.rb +0 -0
  73. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/liquid.rb +0 -0
  74. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/livescript.rb +0 -0
  75. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/mapping.rb +0 -0
  76. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/markaby.rb +0 -0
  77. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/maruku.rb +0 -0
  78. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/nokogiri.rb +0 -0
  79. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/pandoc.rb +23 -15
  80. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/plain.rb +0 -0
  81. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/prawn.rb +0 -0
  82. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/radius.rb +0 -0
  83. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/rdiscount.rb +0 -0
  84. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/rdoc.rb +0 -0
  85. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/redcarpet.rb +5 -2
  86. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/redcloth.rb +0 -0
  87. data/bundle/ruby/2.7.0/gems/tilt-2.0.11/lib/tilt/rst-pandoc.rb +23 -0
  88. data/bundle/ruby/2.7.0/gems/tilt-2.0.11/lib/tilt/sass.rb +78 -0
  89. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/sigil.rb +0 -0
  90. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/string.rb +0 -0
  91. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/template.rb +12 -1
  92. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/typescript.rb +0 -0
  93. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/wikicloth.rb +0 -0
  94. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/yajl.rb +0 -0
  95. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt.rb +2 -1
  96. data/lib/brakeman/app_tree.rb +9 -1
  97. data/lib/brakeman/checks/check_basic_auth.rb +4 -2
  98. data/lib/brakeman/checks/check_basic_auth_timing_attack.rb +2 -1
  99. data/lib/brakeman/checks/check_content_tag.rb +8 -4
  100. data/lib/brakeman/checks/check_cookie_serialization.rb +2 -1
  101. data/lib/brakeman/checks/check_create_with.rb +4 -2
  102. data/lib/brakeman/checks/check_cross_site_scripting.rb +6 -3
  103. data/lib/brakeman/checks/check_csrf_token_forgery_cve.rb +2 -1
  104. data/lib/brakeman/checks/check_default_routes.rb +6 -3
  105. data/lib/brakeman/checks/check_deserialize.rb +2 -1
  106. data/lib/brakeman/checks/check_detailed_exceptions.rb +4 -2
  107. data/lib/brakeman/checks/check_digest_dos.rb +2 -1
  108. data/lib/brakeman/checks/check_divide_by_zero.rb +2 -1
  109. data/lib/brakeman/checks/check_dynamic_finders.rb +2 -1
  110. data/lib/brakeman/checks/check_escape_function.rb +2 -1
  111. data/lib/brakeman/checks/check_evaluation.rb +2 -1
  112. data/lib/brakeman/checks/check_execute.rb +6 -3
  113. data/lib/brakeman/checks/check_file_access.rb +2 -1
  114. data/lib/brakeman/checks/check_file_disclosure.rb +2 -1
  115. data/lib/brakeman/checks/check_filter_skipping.rb +2 -1
  116. data/lib/brakeman/checks/check_force_ssl.rb +2 -1
  117. data/lib/brakeman/checks/check_forgery_setting.rb +4 -2
  118. data/lib/brakeman/checks/check_header_dos.rb +2 -1
  119. data/lib/brakeman/checks/check_i18n_xss.rb +2 -1
  120. data/lib/brakeman/checks/check_jruby_xml.rb +2 -1
  121. data/lib/brakeman/checks/check_json_encoding.rb +2 -1
  122. data/lib/brakeman/checks/check_json_entity_escape.rb +4 -2
  123. data/lib/brakeman/checks/check_json_parsing.rb +4 -2
  124. data/lib/brakeman/checks/check_link_to.rb +2 -1
  125. data/lib/brakeman/checks/check_link_to_href.rb +4 -2
  126. data/lib/brakeman/checks/check_mail_to.rb +2 -1
  127. data/lib/brakeman/checks/check_mass_assignment.rb +6 -3
  128. data/lib/brakeman/checks/check_mime_type_dos.rb +2 -1
  129. data/lib/brakeman/checks/check_model_attr_accessible.rb +2 -1
  130. data/lib/brakeman/checks/check_model_attributes.rb +4 -2
  131. data/lib/brakeman/checks/check_model_serialize.rb +2 -1
  132. data/lib/brakeman/checks/check_nested_attributes.rb +2 -1
  133. data/lib/brakeman/checks/check_nested_attributes_bypass.rb +2 -1
  134. data/lib/brakeman/checks/check_number_to_currency.rb +4 -2
  135. data/lib/brakeman/checks/check_page_caching_cve.rb +2 -1
  136. data/lib/brakeman/checks/check_permit_attributes.rb +2 -1
  137. data/lib/brakeman/checks/check_quote_table_name.rb +2 -1
  138. data/lib/brakeman/checks/check_redirect.rb +2 -1
  139. data/lib/brakeman/checks/check_regex_dos.rb +2 -1
  140. data/lib/brakeman/checks/check_render.rb +4 -2
  141. data/lib/brakeman/checks/check_render_dos.rb +2 -1
  142. data/lib/brakeman/checks/check_render_inline.rb +4 -2
  143. data/lib/brakeman/checks/check_response_splitting.rb +2 -1
  144. data/lib/brakeman/checks/check_reverse_tabnabbing.rb +2 -1
  145. data/lib/brakeman/checks/check_route_dos.rb +2 -1
  146. data/lib/brakeman/checks/check_safe_buffer_manipulation.rb +2 -1
  147. data/lib/brakeman/checks/check_sanitize_config_cve.rb +120 -0
  148. data/lib/brakeman/checks/check_sanitize_methods.rb +6 -3
  149. data/lib/brakeman/checks/check_secrets.rb +2 -1
  150. data/lib/brakeman/checks/check_select_tag.rb +2 -1
  151. data/lib/brakeman/checks/check_select_vulnerability.rb +2 -1
  152. data/lib/brakeman/checks/check_send.rb +2 -1
  153. data/lib/brakeman/checks/check_session_manipulation.rb +2 -1
  154. data/lib/brakeman/checks/check_session_settings.rb +6 -3
  155. data/lib/brakeman/checks/check_simple_format.rb +4 -2
  156. data/lib/brakeman/checks/check_single_quotes.rb +2 -1
  157. data/lib/brakeman/checks/check_skip_before_filter.rb +4 -2
  158. data/lib/brakeman/checks/check_sprockets_path_traversal.rb +2 -1
  159. data/lib/brakeman/checks/check_sql.rb +7 -4
  160. data/lib/brakeman/checks/check_sql_cves.rb +4 -2
  161. data/lib/brakeman/checks/check_ssl_verify.rb +2 -1
  162. data/lib/brakeman/checks/check_strip_tags.rb +6 -3
  163. data/lib/brakeman/checks/check_symbol_dos.rb +2 -1
  164. data/lib/brakeman/checks/check_symbol_dos_cve.rb +2 -1
  165. data/lib/brakeman/checks/check_template_injection.rb +2 -1
  166. data/lib/brakeman/checks/check_translate_bug.rb +2 -1
  167. data/lib/brakeman/checks/check_unsafe_reflection.rb +9 -3
  168. data/lib/brakeman/checks/check_unsafe_reflection_methods.rb +2 -1
  169. data/lib/brakeman/checks/check_unscoped_find.rb +2 -1
  170. data/lib/brakeman/checks/check_validation_regex.rb +2 -1
  171. data/lib/brakeman/checks/check_verb_confusion.rb +2 -1
  172. data/lib/brakeman/checks/check_weak_hash.rb +6 -3
  173. data/lib/brakeman/checks/check_without_protection.rb +2 -1
  174. data/lib/brakeman/checks/check_xml_dos.rb +2 -1
  175. data/lib/brakeman/checks/check_yaml_parsing.rb +4 -2
  176. data/lib/brakeman/checks/eol_check.rb +4 -2
  177. data/lib/brakeman/options.rb +1 -1
  178. data/lib/brakeman/processors/alias_processor.rb +41 -2
  179. data/lib/brakeman/processors/lib/find_all_calls.rb +1 -0
  180. data/lib/brakeman/report/ignore/interactive.rb +2 -2
  181. data/lib/brakeman/report/report_csv.rb +2 -0
  182. data/lib/brakeman/report/report_junit.rb +2 -2
  183. data/lib/brakeman/report/report_table.rb +5 -5
  184. data/lib/brakeman/report/report_text.rb +2 -0
  185. data/lib/brakeman/report/templates/controller_warnings.html.erb +2 -0
  186. data/lib/brakeman/report/templates/ignored_warnings.html.erb +2 -0
  187. data/lib/brakeman/report/templates/model_warnings.html.erb +2 -0
  188. data/lib/brakeman/report/templates/security_warnings.html.erb +2 -0
  189. data/lib/brakeman/report/templates/view_warnings.html.erb +2 -0
  190. data/lib/brakeman/version.rb +1 -1
  191. data/lib/brakeman/warning.rb +5 -2
  192. data/lib/brakeman/warning_codes.rb +1 -0
  193. metadata +95 -92
  194. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/version.rb +0 -4
  195. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby20_parser.rb +0 -7128
  196. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby21_parser.rb +0 -7182
  197. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby22_parser.rb +0 -7228
  198. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby23_parser.rb +0 -7237
  199. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby24_parser.rb +0 -7268
  200. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby25_parser.rb +0 -7268
  201. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby26_parser.rb +0 -7287
  202. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby27_parser.rb +0 -8517
  203. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.rb +0 -8751
  204. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/rst-pandoc.rb +0 -18
  205. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/sass.rb +0 -52
@@ -40,7 +40,8 @@ class Brakeman::CheckUnscopedFind < Brakeman::BaseCheck
40
40
  :message => msg("Unscoped call to ", msg_code("#{result[:target]}##{result[:method]}")),
41
41
  :code => result[:call],
42
42
  :confidence => :weak,
43
- :user_input => input
43
+ :user_input => input,
44
+ :cwe_id => [285]
44
45
  end
45
46
 
46
47
  def optional_belongs_to? exp
@@ -91,7 +91,8 @@ class Brakeman::CheckValidationRegex < Brakeman::BaseCheck
91
91
  :warning_code => :validation_regex,
92
92
  :message => msg("Insufficient validation for ", msg_code(get_name validator), " using ", msg_code(regex.inspect), ". Use ", msg_code("\\A"), " and ", msg_code("\\z"), " as anchors"),
93
93
  :line => value.line,
94
- :confidence => :high
94
+ :confidence => :high,
95
+ :cwe_id => [777]
95
96
  end
96
97
  end
97
98
 
@@ -70,6 +70,7 @@ class Brakeman::CheckVerbConfusion < Brakeman::BaseCheck
70
70
  :message => message,
71
71
  :code => code,
72
72
  :user_input => result[:call],
73
- :confidence => confidence
73
+ :confidence => confidence,
74
+ :cwe_id => [352]
74
75
  end
75
76
  end
@@ -53,7 +53,8 @@ class Brakeman::CheckWeakHash < Brakeman::BaseCheck
53
53
  :warning_code => :weak_hash_digest,
54
54
  :message => message,
55
55
  :confidence => confidence,
56
- :user_input => input
56
+ :user_input => input,
57
+ :cwe_id => [328]
57
58
  end
58
59
 
59
60
  def process_hmac_result result
@@ -74,7 +75,8 @@ class Brakeman::CheckWeakHash < Brakeman::BaseCheck
74
75
  :warning_type => "Weak Hash",
75
76
  :warning_code => :weak_hash_hmac,
76
77
  :message => message,
77
- :confidence => :medium
78
+ :confidence => :medium,
79
+ :cwe_id => [328]
78
80
  end
79
81
 
80
82
  def process_openssl_result result
@@ -90,7 +92,8 @@ class Brakeman::CheckWeakHash < Brakeman::BaseCheck
90
92
  :warning_type => "Weak Hash",
91
93
  :warning_code => :weak_hash_digest,
92
94
  :message => msg("Weak hashing algorithm used: ", msg_lit(alg)),
93
- :confidence => :medium
95
+ :confidence => :medium,
96
+ :cwe_id => [328]
94
97
  end
95
98
  end
96
99
  end
@@ -55,7 +55,8 @@ class Brakeman::CheckWithoutProtection < Brakeman::BaseCheck
55
55
  :message => "Unprotected mass assignment",
56
56
  :code => call,
57
57
  :user_input => input,
58
- :confidence => confidence
58
+ :confidence => confidence,
59
+ :cwe_id => [915]
59
60
 
60
61
  end
61
62
  end
@@ -30,7 +30,8 @@ class Brakeman::CheckXMLDoS < Brakeman::BaseCheck
30
30
  :message => message,
31
31
  :confidence => :medium,
32
32
  :gem_info => gemfile_or_environment,
33
- :link_path => "https://groups.google.com/d/msg/rubyonrails-security/bahr2JLnxvk/x4EocXnHPp8J"
33
+ :link_path => "https://groups.google.com/d/msg/rubyonrails-security/bahr2JLnxvk/x4EocXnHPp8J",
34
+ :cwe_id => [125]
34
35
  end
35
36
 
36
37
  def has_workaround?
@@ -29,7 +29,8 @@ class Brakeman::CheckYAMLParsing < Brakeman::BaseCheck
29
29
  :message => message,
30
30
  :confidence => :high,
31
31
  :gem_info => gemfile_or_environment,
32
- :link_path => "https://groups.google.com/d/topic/rubyonrails-security/61bkgvnSGTQ/discussion"
32
+ :link_path => "https://groups.google.com/d/topic/rubyonrails-security/61bkgvnSGTQ/discussion",
33
+ :cwe_id => [20]
33
34
  end
34
35
 
35
36
  #Warn if app accepts YAML
@@ -41,7 +42,8 @@ class Brakeman::CheckYAMLParsing < Brakeman::BaseCheck
41
42
  :message => message,
42
43
  :confidence => :high,
43
44
  :gem_info => gemfile_or_environment,
44
- :link_path => "https://groups.google.com/d/topic/rubyonrails-security/61bkgvnSGTQ/discussion"
45
+ :link_path => "https://groups.google.com/d/topic/rubyonrails-security/61bkgvnSGTQ/discussion",
46
+ :cwe_id => [20]
45
47
  end
46
48
  end
47
49
 
@@ -34,7 +34,8 @@ class Brakeman::EOLCheck < Brakeman::BaseCheck
34
34
  warning_code: :"pending_eol_#{library}",
35
35
  message: msg("Support for ", msg_version(version, library.capitalize), " ends on #{eol_date}"),
36
36
  confidence: confidence,
37
- gem_info: gemfile_or_environment
37
+ gem_info: gemfile_or_environment,
38
+ :cwe_id => [1104]
38
39
  end
39
40
 
40
41
  def warn_about_unsupported_version library, eol_date, version
@@ -42,6 +43,7 @@ class Brakeman::EOLCheck < Brakeman::BaseCheck
42
43
  warning_code: :"eol_#{library}",
43
44
  message: msg("Support for ", msg_version(version, library.capitalize), " ended on #{eol_date}"),
44
45
  confidence: :high,
45
- gem_info: gemfile_or_environment
46
+ gem_info: gemfile_or_environment,
47
+ :cwe_id => [1104]
46
48
  end
47
49
  end
@@ -323,7 +323,7 @@ module Brakeman::Options
323
323
  end
324
324
 
325
325
  opts.on "--text-fields field1,field2,etc.", Array, "Specify fields for text report format" do |format|
326
- valid_options = [:category, :category_id, :check, :code, :confidence, :file, :fingerprint, :line, :link, :message, :render_path]
326
+ valid_options = [:category, :category_id, :check, :code, :confidence, :cwe, :file, :fingerprint, :line, :link, :message, :render_path]
327
327
 
328
328
  options[:text_fields] = format.map(&:to_sym)
329
329
 
@@ -404,7 +404,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
404
404
  end
405
405
 
406
406
  def join_item item, join_value
407
- if item.is_a? String
407
+ if item.nil? || item.is_a?(String)
408
408
  "#{item}#{join_value}"
409
409
  elsif string? item or symbol? item or number? item
410
410
  s(:str, "#{item.value}#{join_value}").line(item.line)
@@ -703,7 +703,30 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
703
703
  end
704
704
  end
705
705
 
706
- exp
706
+ # Return early unless there might be short-hand syntax,
707
+ # since handling it is kind of expensive.
708
+ return exp unless exp.any? { |e| e.nil? }
709
+
710
+ # Need to handle short-hand hash syntax
711
+ new_hash = [:hash]
712
+ hash_iterate(exp) do |key, value|
713
+ # e.g. { a: }
714
+ if value.nil? and symbol? key
715
+ # Only handling local variables for now, not calls
716
+ lvar = s(:lvar, key.value)
717
+ if var_value = env[lvar]
718
+ new_hash << key << var_value.deep_clone(key.line || 0)
719
+ else
720
+ # If the value is unknown, assume it was a call
721
+ # and set the value to a call
722
+ new_hash.concat << key << s(:call, nil, key.value).line(key.line || 0)
723
+ end
724
+ else
725
+ new_hash.concat << key << value
726
+ end
727
+ end
728
+
729
+ Sexp.from_array(new_hash).line(exp.line || 0)
707
730
  end
708
731
 
709
732
  #Merge values into hash when processing
@@ -864,6 +887,9 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
864
887
  elsif false? condition
865
888
  no_branch = true
866
889
  exps = [nil, exp.else_clause]
890
+ elsif equality_check? condition and condition.target == condition.first_arg
891
+ no_branch = true
892
+ exps = [exp.then_clause, nil]
867
893
  else
868
894
  no_branch = false
869
895
  exps = [exp.then_clause, exp.else_clause]
@@ -897,6 +923,14 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
897
923
  env.current[var] = safe_literal(var.line)
898
924
  exp[branch_index] = process_if_branch branch
899
925
  env.current[var] = previous_value
926
+ elsif i == 0 and equality_check? condition
927
+ # For conditions like a == b,
928
+ # set a to b inside the true branch
929
+ var = condition.target
930
+ previous_value = env.current[var]
931
+ env.current[var] = condition.first_arg
932
+ exp[branch_index] = process_if_branch branch
933
+ env.current[var] = previous_value
900
934
  elsif i == 1 and hash_or_array_include_all_literals? condition and early_return? branch
901
935
  var = condition.first_arg
902
936
  env.current[var] = safe_literal(var.line)
@@ -931,6 +965,11 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
931
965
  end
932
966
  end
933
967
 
968
+ def equality_check? exp
969
+ call? exp and
970
+ exp.method == :==
971
+ end
972
+
934
973
  def simple_when? exp
935
974
  node_type? exp[1], :array and
936
975
  not node_type? exp[1][1], :splat, :array and
@@ -233,6 +233,7 @@ class Brakeman::FindAllCalls < Brakeman::BasicProcessor
233
233
 
234
234
  unless @in_target
235
235
  @full_call = call_hash
236
+ call_hash[:full_call] = call_hash
236
237
  end
237
238
 
238
239
  # Process up the call chain
@@ -88,10 +88,10 @@ module Brakeman
88
88
 
89
89
  m.choice "i"
90
90
  m.choice "n"
91
- m.choice "k"
91
+ m.choice "s"
92
92
  m.choice "u"
93
93
  m.choice "a"
94
- m.choice "s"
94
+ m.choice "k"
95
95
  m.choice "q"
96
96
  m.choice "?" do
97
97
  show_help
@@ -5,6 +5,7 @@ class Brakeman::Report::CSV < Brakeman::Report::Base
5
5
  headers = [
6
6
  "Confidence",
7
7
  "Warning Type",
8
+ "CWE",
8
9
  "File",
9
10
  "Line",
10
11
  "Message",
@@ -35,6 +36,7 @@ class Brakeman::Report::CSV < Brakeman::Report::Base
35
36
  [
36
37
  warning.confidence_name,
37
38
  warning.warning_type,
39
+ warning.cwe_id.first,
38
40
  warning_file(warning),
39
41
  warning.line,
40
42
  warning.message,
@@ -1,6 +1,6 @@
1
1
  require 'time'
2
- require "stringio"
3
- require 'rexml/document'
2
+ require 'stringio'
3
+ Brakeman.load_brakeman_dependency 'rexml/document'
4
4
 
5
5
  class Brakeman::Report::JUnit < Brakeman::Report::Base
6
6
  def generate_report
@@ -98,7 +98,7 @@ class Brakeman::Report::Table < Brakeman::Report::Base
98
98
  render_warnings generic_warnings,
99
99
  :warning,
100
100
  'security_warnings',
101
- ["Confidence", "Class", "Method", "Warning Type", "Message"],
101
+ ["Confidence", "Class", "Method", "Warning Type", "CWE ID", "Message"],
102
102
  'Class'
103
103
  end
104
104
 
@@ -107,7 +107,7 @@ class Brakeman::Report::Table < Brakeman::Report::Base
107
107
  render_warnings template_warnings,
108
108
  :template,
109
109
  'view_warnings',
110
- ['Confidence', 'Template', 'Warning Type', 'Message'],
110
+ ['Confidence', 'Template', 'Warning Type', "CWE ID", 'Message'],
111
111
  'Template'
112
112
 
113
113
  end
@@ -117,7 +117,7 @@ class Brakeman::Report::Table < Brakeman::Report::Base
117
117
  render_warnings model_warnings,
118
118
  :model,
119
119
  'model_warnings',
120
- ['Confidence', 'Model', 'Warning Type', 'Message'],
120
+ ['Confidence', 'Model', 'Warning Type', "CWE ID", 'Message'],
121
121
  'Model'
122
122
  end
123
123
 
@@ -126,7 +126,7 @@ class Brakeman::Report::Table < Brakeman::Report::Base
126
126
  render_warnings controller_warnings,
127
127
  :controller,
128
128
  'controller_warnings',
129
- ['Confidence', 'Controller', 'Warning Type', 'Message'],
129
+ ['Confidence', 'Controller', 'Warning Type', "CWE ID", 'Message'],
130
130
  'Controller'
131
131
  end
132
132
 
@@ -134,7 +134,7 @@ class Brakeman::Report::Table < Brakeman::Report::Base
134
134
  render_warnings ignored_warnings,
135
135
  :ignored,
136
136
  'ignored_warnings',
137
- ['Confidence', 'Warning Type', 'File', 'Message'],
137
+ ['Confidence', 'Warning Type', "CWE ID", 'File', 'Message'],
138
138
  'Warning Type'
139
139
  end
140
140
 
@@ -159,6 +159,8 @@ class Brakeman::Report::Text < Brakeman::Report::Base
159
159
  label('Confidence', confidence(w.confidence))
160
160
  when :category
161
161
  label('Category', w.warning_type.to_s)
162
+ when :cwe
163
+ label('CWE', w.cwe_id.join(', '))
162
164
  when :check
163
165
  label('Check', w.check_name)
164
166
  when :message
@@ -5,6 +5,7 @@
5
5
  <th>Confidence</th>
6
6
  <th>Controller</th>
7
7
  <th>Warning Type</th>
8
+ <th>CWE ID</th>
8
9
  <th>Message</th>
9
10
  </tr>
10
11
  </thead>
@@ -14,6 +15,7 @@
14
15
  <td><%= warning['Confidence']%></td>
15
16
  <td><%= warning['Controller']%></td>
16
17
  <td><%= warning['Warning Type']%></td>
18
+ <td><%= warning['CWE ID']%></td>
17
19
  <td><%= warning['Message']%></td>
18
20
  </tr>
19
21
  <% end %>
@@ -6,6 +6,7 @@
6
6
  <th>Confidence</th>
7
7
  <th>File</th>
8
8
  <th>Warning Type</th>
9
+ <th>CWE ID</th>
9
10
  <th>Message</th>
10
11
  <th>Note</th>
11
12
  </tr>
@@ -16,6 +17,7 @@
16
17
  <td><%= warning['Confidence']%></td>
17
18
  <td><%= warning['File']%></td>
18
19
  <td><%= warning['Warning Type']%></td>
20
+ <td><%= warning['CWE ID']%></td>
19
21
  <td><%= warning['Message']%></td>
20
22
  <td><%= warning['Note']%></td>
21
23
  </tr>
@@ -5,6 +5,7 @@
5
5
  <th>Confidence</th>
6
6
  <th>Model</th>
7
7
  <th>Warning Type</th>
8
+ <th>CWE ID</th>
8
9
  <th>Message</th>
9
10
  </tr>
10
11
  </thead>
@@ -14,6 +15,7 @@
14
15
  <td><%= warning['Confidence']%></td>
15
16
  <td><%= warning['Model']%></td>
16
17
  <td><%= warning['Warning Type']%></td>
18
+ <td><%= warning['CWE ID']%></td>
17
19
  <td><%= warning['Message']%></td>
18
20
  </tr>
19
21
  <% end %>
@@ -6,6 +6,7 @@
6
6
  <th>Class</th>
7
7
  <th>Method</th>
8
8
  <th>Warning Type</th>
9
+ <th>CWE ID</th>
9
10
  <th>Message</th>
10
11
  </tr>
11
12
  </thead>
@@ -16,6 +17,7 @@
16
17
  <td><%= warning['Class']%></td>
17
18
  <td><%= warning['Method']%></td>
18
19
  <td><%= warning['Warning Type']%></td>
20
+ <td><%= warning['CWE ID']%></td>
19
21
  <td><%= warning['Message']%></td>
20
22
  </tr>
21
23
  <% end %>
@@ -5,6 +5,7 @@
5
5
  <th>Confidence</th>
6
6
  <th>Template</th>
7
7
  <th>Warning Type</th>
8
+ <th>CWE ID</th>
8
9
  <th>Message</th>
9
10
  </tr>
10
11
  </thead>
@@ -27,6 +28,7 @@
27
28
  <% end %>
28
29
  </td>
29
30
  <td><%= warning['Warning Type']%></td>
31
+ <td><%= warning['CWE ID']%></td>
30
32
  <td><%= warning['Message']%></td>
31
33
  </tr>
32
34
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module Brakeman
2
- Version = "5.2.1"
2
+ Version = "5.3.1"
3
3
  end
@@ -5,7 +5,7 @@ require 'brakeman/messages'
5
5
 
6
6
  #The Warning class stores information about warnings
7
7
  class Brakeman::Warning
8
- attr_reader :called_from, :check, :class, :confidence, :controller,
8
+ attr_reader :called_from, :check, :class, :confidence, :controller, :cwe_id,
9
9
  :line, :method, :model, :template, :user_input, :user_input_type,
10
10
  :warning_code, :warning_set, :warning_type
11
11
 
@@ -31,6 +31,7 @@ class Brakeman::Warning
31
31
  :class => :@class,
32
32
  :code => :@code,
33
33
  :controller => :@controller,
34
+ :cwe_id => :@cwe_id,
34
35
  :file => :@file,
35
36
  :gem_info => :@gem_info,
36
37
  :line => :@line,
@@ -219,6 +220,7 @@ class Brakeman::Warning
219
220
  def to_row type = :warning
220
221
  @row = { "Confidence" => TEXT_CONFIDENCE[self.confidence],
221
222
  "Warning Type" => self.warning_type.to_s,
223
+ "CWE ID" => self.cwe_id,
222
224
  "Message" => self.message }
223
225
 
224
226
  case type
@@ -302,7 +304,8 @@ class Brakeman::Warning
302
304
  :render_path => render_path,
303
305
  :location => self.location(false),
304
306
  :user_input => (@user_input && self.format_user_input(false)),
305
- :confidence => self.confidence_name
307
+ :confidence => self.confidence_name,
308
+ :cwe_id => cwe_id
306
309
  }
307
310
  end
308
311
 
@@ -125,6 +125,7 @@ module Brakeman::WarningCodes
125
125
  :eol_ruby => 121,
126
126
  :pending_eol_rails => 122,
127
127
  :pending_eol_ruby => 123,
128
+ :CVE_2022_32209 => 124,
128
129
 
129
130
  :custom_check => 9090,
130
131
  }