brakeman 6.2.2 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +17 -0
  3. data/bundle/load.rb +7 -6
  4. data/bundle/ruby/3.1.0/gems/csv-3.3.2/LICENSE.txt +33 -0
  5. data/bundle/ruby/3.1.0/gems/csv-3.3.2/NEWS.md +965 -0
  6. data/bundle/ruby/3.1.0/gems/csv-3.3.2/README.md +55 -0
  7. data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/core_ext/array.rb +9 -0
  8. data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/core_ext/string.rb +9 -0
  9. data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/fields_converter.rb +96 -0
  10. data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/input_record_separator.rb +18 -0
  11. data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/parser.rb +1292 -0
  12. data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/row.rb +757 -0
  13. data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/table.rb +1055 -0
  14. data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/version.rb +6 -0
  15. data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv/writer.rb +209 -0
  16. data/bundle/ruby/3.1.0/gems/csv-3.3.2/lib/csv.rb +3017 -0
  17. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/config.rb +22 -26
  18. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/history.rb +3 -3
  19. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/io/ansi.rb +64 -111
  20. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/io/dumb.rb +16 -2
  21. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/io/windows.rb +77 -60
  22. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/io.rb +14 -0
  23. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor/base.rb +10 -4
  24. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor/emacs.rb +96 -96
  25. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor/vi_command.rb +182 -182
  26. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor/vi_insert.rb +137 -137
  27. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_stroke.rb +26 -16
  28. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/line_editor.rb +238 -404
  29. data/bundle/ruby/3.1.0/gems/reline-0.6.0/lib/reline/unicode.rb +415 -0
  30. data/bundle/ruby/3.1.0/gems/reline-0.6.0/lib/reline/version.rb +3 -0
  31. data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline.rb +18 -18
  32. data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/NEWS.md +50 -0
  33. data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/baseparser.rb +54 -45
  34. data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/pullparser.rb +4 -0
  35. data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/rexml.rb +1 -1
  36. data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/source.rb +45 -4
  37. data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/text.rb +15 -40
  38. data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/History.rdoc +6 -0
  39. data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/sexp.rb +1 -1
  40. data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/sexp_processor.rb +1 -1
  41. data/bundle/ruby/3.1.0/gems/terminal-table-3.0.2/History.rdoc +142 -0
  42. data/bundle/ruby/3.1.0/gems/terminal-table-3.0.2/README.md +417 -0
  43. data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/cell.rb +8 -8
  44. data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/row.rb +18 -4
  45. data/bundle/ruby/3.1.0/gems/terminal-table-3.0.2/lib/terminal-table/separator.rb +66 -0
  46. data/bundle/ruby/3.1.0/gems/terminal-table-3.0.2/lib/terminal-table/style.rb +284 -0
  47. data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/table.rb +47 -18
  48. data/bundle/ruby/3.1.0/gems/terminal-table-3.0.2/lib/terminal-table/util.rb +13 -0
  49. data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/version.rb +1 -1
  50. data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table.rb +2 -2
  51. data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/terminal-table.gemspec +3 -3
  52. data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/creole.rb +2 -0
  53. data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/liquid.rb +0 -3
  54. data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/mapping.rb +3 -3
  55. data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/rdoc.rb +0 -8
  56. data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/template.rb +27 -3
  57. data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt.rb +1 -4
  58. data/bundle/ruby/3.1.0/gems/{unicode-display_width-1.8.0 → unicode-display_width-2.6.0}/CHANGELOG.md +65 -2
  59. data/bundle/ruby/3.1.0/gems/{unicode-display_width-1.8.0 → unicode-display_width-2.6.0}/MIT-LICENSE.txt +1 -1
  60. data/bundle/ruby/3.1.0/gems/{unicode-display_width-1.8.0 → unicode-display_width-2.6.0}/README.md +67 -20
  61. data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/data/display_width.marshal.gz +0 -0
  62. data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/constants.rb +10 -0
  63. data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/index.rb +34 -0
  64. data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/no_string_ext.rb +8 -0
  65. data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width/string_ext.rb +9 -0
  66. data/bundle/ruby/3.1.0/gems/unicode-display_width-2.6.0/lib/unicode/display_width.rb +123 -0
  67. data/lib/brakeman/app_tree.rb +23 -18
  68. data/lib/brakeman/checks/check_deserialize.rb +4 -1
  69. data/lib/brakeman/checks/check_evaluation.rb +20 -2
  70. data/lib/brakeman/checks/check_model_attr_accessible.rb +1 -0
  71. data/lib/brakeman/file_parser.rb +2 -1
  72. data/lib/brakeman/options.rb +8 -5
  73. data/lib/brakeman/processors/alias_processor.rb +6 -2
  74. data/lib/brakeman/processors/lib/file_type_detector.rb +9 -7
  75. data/lib/brakeman/report/ignore/config.rb +0 -1
  76. data/lib/brakeman/report/report_sarif.rb +122 -2
  77. data/lib/brakeman/rescanner.rb +40 -390
  78. data/lib/brakeman/scanner.rb +62 -38
  79. data/lib/brakeman/tracker/file_cache.rb +83 -0
  80. data/lib/brakeman/tracker.rb +19 -2
  81. data/lib/brakeman/version.rb +1 -1
  82. data/lib/brakeman.rb +12 -2
  83. metadata +170 -160
  84. data/bundle/ruby/3.1.0/gems/reline-0.5.10/lib/reline/terminfo.rb +0 -158
  85. data/bundle/ruby/3.1.0/gems/reline-0.5.10/lib/reline/unicode.rb +0 -671
  86. data/bundle/ruby/3.1.0/gems/reline-0.5.10/lib/reline/version.rb +0 -3
  87. data/bundle/ruby/3.1.0/gems/terminal-table-1.8.0/History.rdoc +0 -85
  88. data/bundle/ruby/3.1.0/gems/terminal-table-1.8.0/README.rdoc +0 -247
  89. data/bundle/ruby/3.1.0/gems/terminal-table-1.8.0/lib/terminal-table/separator.rb +0 -14
  90. data/bundle/ruby/3.1.0/gems/terminal-table-1.8.0/lib/terminal-table/style.rb +0 -79
  91. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/erubis.rb +0 -51
  92. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/maruku.rb +0 -10
  93. data/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/wikicloth.rb +0 -12
  94. data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
  95. data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/constants.rb +0 -8
  96. data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/index.rb +0 -12
  97. data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/no_string_ext.rb +0 -7
  98. data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width/string_ext.rb +0 -17
  99. data/bundle/ruby/3.1.0/gems/unicode-display_width-1.8.0/lib/unicode/display_width.rb +0 -51
  100. /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/BSDL +0 -0
  101. /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/COPYING +0 -0
  102. /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/README.md +0 -0
  103. /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/face.rb +0 -0
  104. /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor/composite.rb +0 -0
  105. /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/key_actor.rb +0 -0
  106. /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/kill_ring.rb +0 -0
  107. /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/lib/reline/unicode/east_asian_width.rb +0 -0
  108. /data/bundle/ruby/3.1.0/gems/{reline-0.5.10 → reline-0.6.0}/license_of_rb-readline +0 -0
  109. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/LICENSE.txt +0 -0
  110. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/README.md +0 -0
  111. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/attlistdecl.rb +0 -0
  112. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/attribute.rb +0 -0
  113. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/cdata.rb +0 -0
  114. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/child.rb +0 -0
  115. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/comment.rb +0 -0
  116. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/doctype.rb +0 -0
  117. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/document.rb +0 -0
  118. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/dtd/attlistdecl.rb +0 -0
  119. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/dtd/dtd.rb +0 -0
  120. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/dtd/elementdecl.rb +0 -0
  121. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/dtd/entitydecl.rb +0 -0
  122. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/dtd/notationdecl.rb +0 -0
  123. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/element.rb +0 -0
  124. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/encoding.rb +0 -0
  125. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/entity.rb +0 -0
  126. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/formatters/default.rb +0 -0
  127. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/formatters/pretty.rb +0 -0
  128. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/formatters/transitive.rb +0 -0
  129. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/functions.rb +0 -0
  130. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/instruction.rb +0 -0
  131. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/light/node.rb +0 -0
  132. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/namespace.rb +0 -0
  133. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/node.rb +0 -0
  134. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/output.rb +0 -0
  135. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parent.rb +0 -0
  136. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parseexception.rb +0 -0
  137. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/lightparser.rb +0 -0
  138. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/sax2parser.rb +0 -0
  139. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/streamparser.rb +0 -0
  140. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/treeparser.rb +0 -0
  141. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/ultralightparser.rb +0 -0
  142. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/parsers/xpathparser.rb +0 -0
  143. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/quickpath.rb +0 -0
  144. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/sax2listener.rb +0 -0
  145. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/security.rb +0 -0
  146. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/streamlistener.rb +0 -0
  147. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/undefinednamespaceexception.rb +0 -0
  148. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/validation/relaxng.rb +0 -0
  149. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/validation/validation.rb +0 -0
  150. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/validation/validationexception.rb +0 -0
  151. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/xmldecl.rb +0 -0
  152. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/xmltokens.rb +0 -0
  153. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/xpath.rb +0 -0
  154. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml/xpath_parser.rb +0 -0
  155. /data/bundle/ruby/3.1.0/gems/{rexml-3.3.8 → rexml-3.4.0}/lib/rexml.rb +0 -0
  156. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/Manifest.txt +0 -0
  157. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/README.rdoc +0 -0
  158. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/composite_sexp_processor.rb +0 -0
  159. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/pt_testcase.rb +0 -0
  160. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/sexp_matcher.rb +0 -0
  161. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/strict_sexp.rb +0 -0
  162. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.17.2 → sexp_processor-4.17.3}/lib/unique.rb +0 -0
  163. /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/Gemfile +0 -0
  164. /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/LICENSE.txt +0 -0
  165. /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/Manifest +0 -0
  166. /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/Todo.rdoc +0 -0
  167. /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/import.rb +0 -0
  168. /data/bundle/ruby/3.1.0/gems/{terminal-table-1.8.0 → terminal-table-3.0.2}/lib/terminal-table/table_helper.rb +0 -0
  169. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/COPYING +0 -0
  170. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/_emacs_org.rb +0 -0
  171. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/_handlebars.rb +0 -0
  172. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/_jbuilder.rb +0 -0
  173. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/_org.rb +0 -0
  174. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/asciidoc.rb +0 -0
  175. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/babel.rb +0 -0
  176. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/builder.rb +0 -0
  177. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/cli.rb +0 -0
  178. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/coffee.rb +0 -0
  179. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/commonmarker.rb +0 -0
  180. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/csv.rb +0 -0
  181. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/erb.rb +0 -0
  182. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/erubi.rb +0 -0
  183. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/etanni.rb +0 -0
  184. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/haml.rb +0 -0
  185. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/kramdown.rb +0 -0
  186. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/livescript.rb +0 -0
  187. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/markaby.rb +0 -0
  188. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/nokogiri.rb +0 -0
  189. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/pandoc.rb +0 -0
  190. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/pipeline.rb +0 -0
  191. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/plain.rb +0 -0
  192. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/prawn.rb +0 -0
  193. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/radius.rb +0 -0
  194. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/rdiscount.rb +0 -0
  195. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/redcarpet.rb +0 -0
  196. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/redcloth.rb +0 -0
  197. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/rst-pandoc.rb +0 -0
  198. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/sass.rb +0 -0
  199. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/slim.rb +0 -0
  200. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/string.rb +0 -0
  201. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/typescript.rb +0 -0
  202. /data/bundle/ruby/3.1.0/gems/{tilt-2.4.0 → tilt-2.5.0}/lib/tilt/yajl.rb +0 -0
@@ -1,12 +1,39 @@
1
- ## Unicode::DisplayWidth [![[version]](https://badge.fury.io/rb/unicode-display_width.svg)](https://badge.fury.io/rb/unicode-display_width) [<img src="https://travis-ci.org/janlelis/unicode-display_width.png" />](https://travis-ci.org/janlelis/unicode-display_width)
1
+ ## Unicode::DisplayWidth [![[version]](https://badge.fury.io/rb/unicode-display_width.svg)](https://badge.fury.io/rb/unicode-display_width) [<img src="https://github.com/janlelis/unicode-display_width/workflows/Test/badge.svg" />](https://github.com/janlelis/unicode-display_width/actions?query=workflow%3ATest)
2
2
 
3
- Determines the monospace display width of a string in Ruby. Implementation based on [EastAsianWidth.txt](https://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt) and other data, 100% in Ruby. Other than [wcwidth()](https://github.com/janlelis/wcswidth-ruby), which fulfills a similar purpose, it does not rely on the OS vendor to provide an up-to-date method for measuring string width.
3
+ Determines the monospace display width of a string in Ruby. Useful for all kinds of terminal-based applications. Implementation based on [EastAsianWidth.txt](https://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt) and other data, 100% in Ruby. It does not rely on the OS vendor (like [wcwidth()](https://github.com/janlelis/wcswidth-ruby)) to provide an up-to-date method for measuring string width.
4
4
 
5
- Unicode version: **14.0.0** (September 2021)
5
+ Unicode version: **16.0.0** (September 2024)
6
6
 
7
- Supported Rubies: **2.7**, **2.6**, **2.5**, **2.4**
7
+ Supported Rubies: **3.3**, **3.2**, **3.1**, **3.0**
8
8
 
9
- Old Rubies that might still work: **2.3**, **2.2**, **2.1**, **2.0**, **1.9**
9
+ Old Rubies which might still work: **2.7**, **2.6**, **2.5**, **2.4**, **2.3**
10
+
11
+ For even older Rubies, use version 2.3.0 of this gem: **2.3**, **2.2**, **2.1**, **2.0**, **1.9**
12
+
13
+ ## Version 2.4.2 — Performance Updates
14
+
15
+ **If you use this gem, you should really upgrade to 2.4.2 or newer. It's often 100x faster, sometimes even 1000x and more!**
16
+
17
+ This is possible because the gem now detects if you use very basic (and common) characters, like ASCII characters. Furthermore, the charachter width lookup code has been optimized, so even when full-width characters are involved, the gem is much faster now.
18
+
19
+ ## Version 2.0 — Breaking Changes
20
+
21
+ Some features of this library were marked deprecated for a long time and have been removed with Version 2.0:
22
+
23
+ - Aliases of display_width (…\_size, …\_length) have been removed
24
+ - Auto-loading of string core extension has been removed:
25
+
26
+ If you are relying on the `String#display_width` string extension to be automatically loaded (old behavior), please load it explicitly now:
27
+
28
+ ```ruby
29
+ require "unicode/display_width/string_ext"
30
+ ```
31
+
32
+ You could also change your `Gemfile` line to achieve this:
33
+
34
+ ```ruby
35
+ gem "unicode-display_width", require: "unicode/display_width/string_ext"
36
+ ```
10
37
 
11
38
  ## Introduction to Character Widths
12
39
 
@@ -20,12 +47,12 @@ Width | Characters | Comment
20
47
  -------|------------------------------|--------------------------------------------------
21
48
  X | (user defined) | Overwrites any other values
22
49
  -1 | `"\b"` | Backspace (total width never below 0)
23
- 0 | `"\0"`, `"\x05"`, `"\a"`, `"\n"`, `"\v"`, `"\f"`, `"\r"`, `"\x0E"`, `"\x0F"` | [C0 control codes](https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C0_.28ASCII_and_derivatives.29) that do not change horizontal width
50
+ 0 | `"\0"`, `"\x05"`, `"\a"`, `"\n"`, `"\v"`, `"\f"`, `"\r"`, `"\x0E"`, `"\x0F"` | [C0 control codes](https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C0_.28ASCII_and_derivatives.29) which do not change horizontal width
24
51
  1 | `"\u{00AD}"` | SOFT HYPHEN
25
52
  2 | `"\u{2E3A}"` | TWO-EM DASH
26
53
  3 | `"\u{2E3B}"` | THREE-EM DASH
27
54
  0 | General Categories: Mn, Me, Cf (non-arabic) | Excludes ARABIC format characters
28
- 0 | `"\u{1160}".."\u{11FF}"` | HANGUL JUNGSEONG
55
+ 0 | `"\u{1160}".."\u{11FF}"`, `"\u{D7B0}".."\u{D7FF}"` | HANGUL JUNGSEONG
29
56
  0 | `"\u{2060}".."\u{206F}"`, `"\u{FFF0}".."\u{FFF8}"`, `"\u{E0000}".."\u{E0FFF}"` | Ignorable ranges
30
57
  2 | East Asian Width: F, W | Full-width characters
31
58
  2 | `"\u{3400}".."\u{4DBF}"`, `"\u{4E00}".."\u{9FFF}"`, `"\u{F900}".."\u{FAFF}"`, `"\u{20000}".."\u{2FFFD}"`, `"\u{30000}".."\u{3FFFD}"` | Full-width ranges
@@ -44,6 +71,8 @@ Or add to your Gemfile:
44
71
 
45
72
  ## Usage
46
73
 
74
+ ### Classic API
75
+
47
76
  ```ruby
48
77
  require 'unicode/display_width'
49
78
 
@@ -51,7 +80,7 @@ Unicode::DisplayWidth.of("⚀") # => 1
51
80
  Unicode::DisplayWidth.of("一") # => 2
52
81
  ```
53
82
 
54
- ### Ambiguous Characters
83
+ #### Ambiguous Characters
55
84
 
56
85
  The second parameter defines the value returned by characters defined as ambiguous:
57
86
 
@@ -60,42 +89,59 @@ Unicode::DisplayWidth.of("·", 1) # => 1
60
89
  Unicode::DisplayWidth.of("·", 2) # => 2
61
90
  ```
62
91
 
63
- ### Custom Overwrites
92
+ #### Custom Overwrites
64
93
 
65
94
  You can overwrite how to handle specific code points by passing a hash (or even a proc) as third parameter:
66
95
 
67
96
  ```ruby
68
- Unicode::DisplayWidth.of("a\tb", 1, 0x09 => 10)) # => 12
97
+ Unicode::DisplayWidth.of("a\tb", 1, "\t".ord => 10)) # => tab counted as 10, so result is 12
69
98
  ```
70
99
 
71
- ### Emoji Support
100
+ Please note that using overwrites disables some perfomance optimizations of this gem.
101
+
72
102
 
73
- Experimental emoji support is included. It will adjust the string's size for modifier and zero-width joiner sequences. You will need to add the [unicode-emoji](https://github.com/janlelis/unicode-emoji) gem to your Gemfile:
103
+ #### Emoji Support
104
+
105
+ Emoji width support is included, but in must be activated manually. It will adjust the string's size for modifier and zero-width joiner sequences. You also need to add the [unicode-emoji](https://github.com/janlelis/unicode-emoji) gem to your Gemfile:
74
106
 
75
107
  ```ruby
76
108
  gem 'unicode-display_width'
77
109
  gem 'unicode-emoji'
78
110
  ```
79
111
 
80
- You can then activate the emoji string width adjustments by passing `emoji: true` as fourth parameter:
112
+ Enable the emoji string width adjustments by passing `emoji: true` as fourth parameter:
81
113
 
82
114
  ```ruby
83
115
  Unicode::DisplayWidth.of "🤾🏽‍♀️" # => 5
84
116
  Unicode::DisplayWidth.of "🤾🏽‍♀️", 1, {}, emoji: true # => 2
85
117
  ```
86
118
 
87
- ### Usage with String Extension
88
-
89
- Activated by default. Will be deactivated in version 2.0:
119
+ #### Usage with String Extension
90
120
 
91
121
  ```ruby
92
122
  require 'unicode/display_width/string_ext'
93
123
 
94
- "⚀".display_width #=> 1
95
- '一'.display_width #=> 2
124
+ "⚀".display_width # => 1
125
+ '一'.display_width # => 2
96
126
  ```
97
127
 
98
- You can actively opt-out from the string extension with: `require 'unicode/display_width/no_string_ext'`
128
+ ### Modern API: Keyword-arguments Based Config Object
129
+
130
+ Version 2.0 introduces a keyword-argument based API, which allows you to save your configuration for later-reuse. This requires an extra line of code, but has the advantage that you'll need to define your string-width options only once:
131
+
132
+ ```ruby
133
+ require 'unicode/display_width'
134
+
135
+ display_width = Unicode::DisplayWidth.new(
136
+ # ambiguous: 1,
137
+ overwrite: { "A".ord => 100 },
138
+ emoji: true,
139
+ )
140
+
141
+ display_width.of "⚀" # => 1
142
+ display_width.of "🤾🏽‍♀️" # => 2
143
+ display_width.of "A" # => 100
144
+ ```
99
145
 
100
146
  ### Usage From the CLI
101
147
 
@@ -113,12 +159,13 @@ Replace "一" with the actual string to measure
113
159
  - JavaScript: https://github.com/mycoboco/wcwidth.js
114
160
  - C: https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
115
161
  - C for Julia: https://github.com/JuliaLang/utf8proc/issues/2
162
+ - Golang: https://github.com/rivo/uniseg
116
163
 
117
164
  See [unicode-x](https://github.com/janlelis/unicode-x) for more Unicode related micro libraries.
118
165
 
119
166
  ## Copyright & Info
120
167
 
121
- - Copyright (c) 2011, 2015-2020 Jan Lelis, https://janlelis.com, released under the MIT
168
+ - Copyright (c) 2011, 2015-2024 Jan Lelis, https://janlelis.com, released under the MIT
122
169
  license
123
170
  - Early versions based on runpaint's unicode-data interface: Copyright (c) 2009 Run Paint Run Run
124
171
  - Unicode data: https://www.unicode.org/copyright.html#Exhibit1
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Unicode
4
+ class DisplayWidth
5
+ VERSION = "2.6.0"
6
+ UNICODE_VERSION = "16.0.0"
7
+ DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + "/../../../data/")
8
+ INDEX_FILENAME = DATA_DIRECTORY + "/display_width.marshal.gz"
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "zlib"
4
+ require_relative "constants"
5
+
6
+ module Unicode
7
+ class DisplayWidth
8
+ File.open(INDEX_FILENAME, "rb") do |file|
9
+ serialized_data = Zlib::GzipReader.new(file).read
10
+ serialized_data.force_encoding Encoding::BINARY
11
+ INDEX = Marshal.load(serialized_data)
12
+ end
13
+
14
+ def self.decompress_index(index, level)
15
+ index.flat_map{ |value|
16
+ if level > 0
17
+ if value.instance_of?(Array)
18
+ value[15] ||= nil
19
+ decompress_index(value, level - 1)
20
+ else
21
+ decompress_index([value] * 16, level - 1)
22
+ end
23
+ else
24
+ if value.instance_of?(Array)
25
+ value[15] ||= nil
26
+ value
27
+ else
28
+ [value] * 16
29
+ end
30
+ end
31
+ }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ warn "You are loading 'unicode-display_width/no_string_ext'\n" \
4
+ "Beginning with version 2.0, this is not necessary anymore\n"\
5
+ "You can just require 'unicode-display_width' now and no\n"\
6
+ "string extension will be loaded"
7
+
8
+ require_relative "../display_width"
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../display_width" unless defined? Unicode::DisplayWidth
4
+
5
+ class String
6
+ def display_width(ambiguous = 1, overwrite = {}, options = {})
7
+ Unicode::DisplayWidth.of(self, ambiguous, overwrite, options)
8
+ end
9
+ end
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "display_width/constants"
4
+ require_relative "display_width/index"
5
+
6
+ module Unicode
7
+ class DisplayWidth
8
+ INITIAL_DEPTH = 0x10000
9
+ ASCII_NON_ZERO_REGEX = /[\0\x05\a\b\n\v\f\r\x0E\x0F]/
10
+ FIRST_4096 = decompress_index(INDEX[0][0], 1)
11
+
12
+ def self.of(string, ambiguous = 1, overwrite = {}, options = {})
13
+ if overwrite.empty?
14
+ # Optimization for ASCII-only strings without certain control symbols
15
+ if string.ascii_only?
16
+ if string.match?(ASCII_NON_ZERO_REGEX)
17
+ res = string.gsub(ASCII_NON_ZERO_REGEX, "").size - string.count("\b")
18
+ res < 0 ? 0 : res
19
+ else
20
+ string.size
21
+ end
22
+ else
23
+ width_no_overwrite(string, ambiguous, options)
24
+ end
25
+ else
26
+ width_all_features(string, ambiguous, overwrite, options)
27
+ end
28
+ end
29
+
30
+ def self.width_no_overwrite(string, ambiguous, options = {})
31
+ # Sum of all chars widths
32
+ res = string.codepoints.sum{ |codepoint|
33
+ if codepoint > 15 && codepoint < 161 # very common
34
+ next 1
35
+ elsif codepoint < 0x1001
36
+ width = FIRST_4096[codepoint]
37
+ else
38
+ width = INDEX
39
+ depth = INITIAL_DEPTH
40
+ while (width = width[codepoint / depth]).instance_of? Array
41
+ codepoint %= depth
42
+ depth /= 16
43
+ end
44
+ end
45
+
46
+ width == :A ? ambiguous : (width || 1)
47
+ }
48
+
49
+ # Substract emoji error
50
+ res -= emoji_extra_width_of(string, ambiguous) if options[:emoji]
51
+
52
+ # Return result + prevent negative lengths
53
+ res < 0 ? 0 : res
54
+ end
55
+
56
+ # Same as .width_no_overwrite - but with applying overwrites for each char
57
+ def self.width_all_features(string, ambiguous, overwrite, options)
58
+ # Sum of all chars widths
59
+ res = string.codepoints.sum{ |codepoint|
60
+ next overwrite[codepoint] if overwrite[codepoint]
61
+
62
+ if codepoint > 15 && codepoint < 161 # very common
63
+ next 1
64
+ elsif codepoint < 0x1001
65
+ width = FIRST_4096[codepoint]
66
+ else
67
+ width = INDEX
68
+ depth = INITIAL_DEPTH
69
+ while (width = width[codepoint / depth]).instance_of? Array
70
+ codepoint %= depth
71
+ depth /= 16
72
+ end
73
+ end
74
+
75
+ width == :A ? ambiguous : (width || 1)
76
+ }
77
+
78
+ # Substract emoji error
79
+ res -= emoji_extra_width_of(string, ambiguous, overwrite) if options[:emoji]
80
+
81
+ # Return result + prevent negative lengths
82
+ res < 0 ? 0 : res
83
+ end
84
+
85
+
86
+ def self.emoji_extra_width_of(string, ambiguous = 1, overwrite = {}, _ = {})
87
+ require "unicode/emoji"
88
+
89
+ extra_width = 0
90
+ modifier_regex = /[#{ Unicode::Emoji::EMOJI_MODIFIERS.pack("U*") }]/
91
+ zwj_regex = /(?<=#{ [Unicode::Emoji::ZWJ].pack("U") })./
92
+
93
+ string.scan(Unicode::Emoji::REGEX){ |emoji|
94
+ extra_width += 2 * emoji.scan(modifier_regex).size
95
+
96
+ emoji.scan(zwj_regex){ |zwj_succ|
97
+ extra_width += self.of(zwj_succ, ambiguous, overwrite)
98
+ }
99
+ }
100
+
101
+ extra_width
102
+ end
103
+
104
+ def initialize(ambiguous: 1, overwrite: {}, emoji: false)
105
+ @ambiguous = ambiguous
106
+ @overwrite = overwrite
107
+ @emoji = emoji
108
+ end
109
+
110
+ def get_config(**kwargs)
111
+ [
112
+ kwargs[:ambiguous] || @ambiguous,
113
+ kwargs[:overwrite] || @overwrite,
114
+ { emoji: kwargs[:emoji] || @emoji },
115
+ ]
116
+ end
117
+
118
+ def of(string, **kwargs)
119
+ self.class.of(string, *get_config(**kwargs))
120
+ end
121
+ end
122
+ end
123
+
@@ -22,6 +22,8 @@ module Brakeman
22
22
  init_options[:additional_libs_path] = options[:additional_libs_path]
23
23
  init_options[:engine_paths] = options[:engine_paths]
24
24
  init_options[:skip_vendor] = options[:skip_vendor]
25
+ init_options[:follow_symlinks] = options[:follow_symlinks]
26
+
25
27
  new(root, init_options)
26
28
  end
27
29
 
@@ -64,6 +66,7 @@ module Brakeman
64
66
  @absolute_engine_paths = @engine_paths.select { |path| path.start_with?(File::SEPARATOR) }
65
67
  @relative_engine_paths = @engine_paths - @absolute_engine_paths
66
68
  @skip_vendor = init_options[:skip_vendor]
69
+ @follow_symlinks = init_options[:follow_symlinks]
67
70
  @gemspec = nil
68
71
  @root_search_pattern = nil
69
72
  end
@@ -161,21 +164,26 @@ module Brakeman
161
164
  end
162
165
 
163
166
  def glob_files(directory, name, extensions = ".rb")
164
- root_directory = "#{root_search_pattern}#{directory}"
165
- patterns = ["#{root_directory}/**/#{name}#{extensions}"]
166
-
167
- Dir.glob("#{root_directory}/**/*", File::FNM_DOTMATCH).each do |path|
168
- if File.symlink?(path) && File.directory?(path)
169
- symlink_target = File.readlink(path)
170
- if Pathname.new(symlink_target).relative?
171
- symlink_target = File.join(File.dirname(path), symlink_target)
167
+ if @follow_symlinks
168
+ root_directory = "#{root_search_pattern}#{directory}"
169
+ patterns = ["#{root_directory}/**/#{name}#{extensions}"]
170
+
171
+ Dir.glob("#{root_directory}/**/*", File::FNM_DOTMATCH).each do |path|
172
+ if File.symlink?(path) && File.directory?(path)
173
+ symlink_target = File.readlink(path)
174
+ if Pathname.new(symlink_target).relative?
175
+ symlink_target = File.join(File.dirname(path), symlink_target)
176
+ end
177
+ patterns << "#{search_pattern(symlink_target)}/**/#{name}#{extensions}"
172
178
  end
173
- patterns << "#{search_pattern(symlink_target)}/**/#{name}#{extensions}"
174
179
  end
175
- end
176
180
 
177
- files = patterns.flat_map { |pattern| Dir.glob(pattern) }
178
- files.uniq
181
+ files = patterns.flat_map { |pattern| Dir.glob(pattern) }
182
+ files.uniq
183
+ else
184
+ pattern = "#{root_search_pattern}#{directory}/**/#{name}#{extensions}"
185
+ Dir.glob(pattern)
186
+ end
179
187
  end
180
188
 
181
189
  def select_files(paths)
@@ -201,15 +209,14 @@ module Brakeman
201
209
  end
202
210
  end
203
211
 
204
- EXCLUDED_PATHS = %w[
205
- /generators/
212
+ EXCLUDED_PATHS = regex_for_paths %w[
213
+ generators/
206
214
  lib/tasks/
207
215
  lib/templates/
208
216
  db/
209
217
  spec/
210
218
  test/
211
219
  tmp/
212
- log/
213
220
  ]
214
221
 
215
222
  def reject_global_excludes(paths)
@@ -219,9 +226,7 @@ module Brakeman
219
226
  if @skip_vendor and relative_path.include? 'vendor/' and !in_engine_paths?(path) and !in_add_libs_paths?(path)
220
227
  true
221
228
  else
222
- EXCLUDED_PATHS.any? do |excluded|
223
- relative_path.include? excluded
224
- end
229
+ match_path EXCLUDED_PATHS, path
225
230
  end
226
231
  end
227
232
  end
@@ -76,10 +76,13 @@ class Brakeman::CheckDeserialize < Brakeman::BaseCheck
76
76
  confidence = :high
77
77
  elsif input = include_user_input?(arg)
78
78
  confidence = :medium
79
+ elsif target == :Marshal
80
+ confidence = :low
81
+ message = msg("Use of ", msg_code("#{target}.#{method}"), " may be dangerous")
79
82
  end
80
83
 
81
84
  if confidence
82
- message = msg(msg_code("#{target}.#{method}"), " called with ", msg_input(input))
85
+ message ||= msg(msg_code("#{target}.#{method}"), " called with ", msg_input(input))
83
86
 
84
87
  warn :result => result,
85
88
  :warning_type => "Remote Code Execution",
@@ -23,13 +23,31 @@ class Brakeman::CheckEvaluation < Brakeman::BaseCheck
23
23
  return unless original? result
24
24
 
25
25
  if input = include_user_input?(result[:call].arglist)
26
+ confidence = :high
27
+ message = msg(msg_input(input), " evaluated as code")
28
+ elsif string_evaluation? result[:call].first_arg
29
+ confidence = :low
30
+ message = "Dynamic string evaluated as code"
31
+ elsif safe_literal? result[:call].first_arg
32
+ # don't warn
33
+ elsif result[:call].method == :eval
34
+ confidence = :low
35
+ message = "Dynamic code evaluation"
36
+ end
37
+
38
+ if confidence
26
39
  warn :result => result,
27
40
  :warning_type => "Dangerous Eval",
28
41
  :warning_code => :code_eval,
29
- :message => "User input in eval",
42
+ :message => message,
30
43
  :user_input => input,
31
- :confidence => :high,
44
+ :confidence => confidence,
32
45
  :cwe_id => [913, 95]
33
46
  end
34
47
  end
48
+
49
+ def string_evaluation? exp
50
+ string_interp? exp or
51
+ (call? exp and string? exp.target)
52
+ end
35
53
  end
@@ -33,6 +33,7 @@ class Brakeman::CheckModelAttrAccessible < Brakeman::BaseCheck
33
33
  :confidence => confidence,
34
34
  :code => Sexp.new(:lit, attribute),
35
35
  :cwe_id => [915]
36
+
36
37
  break # Prevent from matching single attr multiple times
37
38
  end
38
39
  end
@@ -13,8 +13,9 @@ module Brakeman
13
13
  if @use_prism
14
14
  begin
15
15
  require 'prism'
16
+ Brakeman.debug '[Notice] Using Prism parser'
16
17
  rescue LoadError => e
17
- Brakeman.debug "Asked to use Prism, but failed to load: #{e}"
18
+ Brakeman.debug "[Notice] Asked to use Prism, but failed to load: #{e}"
18
19
  @use_prism = false
19
20
  end
20
21
  end
@@ -161,14 +161,13 @@ module Brakeman::Options
161
161
 
162
162
  opts.on "--[no-]prism", "Use the Prism parser" do |use_prism|
163
163
  if use_prism
164
- prism_version = '0.30'
164
+ min_prism_version = '1.0.0'
165
165
 
166
166
  begin
167
- # Specifying minimum version here,
168
- # since it can't be in the gem dependency list because it is optional
169
- gem 'prism', "~>#{prism_version}"
167
+ gem 'prism', ">=#{min_prism_version}"
168
+ require 'prism'
170
169
  rescue Gem::MissingSpecVersionError, Gem::MissingSpecError, Gem::LoadError => e
171
- $stderr.puts "Please install `prism` version #{prism_version} or newer:"
170
+ $stderr.puts "Please install `prism` version #{min_prism_version} or newer:"
172
171
  raise e
173
172
  end
174
173
  end
@@ -223,6 +222,10 @@ module Brakeman::Options
223
222
  options[:engine_paths].merge paths
224
223
  end
225
224
 
225
+ opts.on '--[no-]follow-symlinks', 'Follow symbolic links for directions' do |follow_symlinks|
226
+ options[:follow_symlinks] = follow_symlinks
227
+ end
228
+
226
229
  opts.on "-E", "--enable Check1,Check2,etc", Array, "Enable the specified checks" do |checks|
227
230
  checks.map! do |check|
228
231
  if check.start_with? "Check"
@@ -97,6 +97,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
97
97
  end
98
98
 
99
99
  def process_bracket_call exp
100
+ # TODO: What is even happening in this method?
100
101
  r = replace(exp)
101
102
 
102
103
  if r != exp
@@ -127,7 +128,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
127
128
  return r
128
129
  end
129
130
  else
130
- t = nil
131
+ t = exp.target # put it back?
131
132
  end
132
133
 
133
134
  if hash? t
@@ -242,6 +243,7 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
242
243
  exp = math_op(method, target, first_arg, exp)
243
244
  end
244
245
  when :[]
246
+ # TODO: This might never be used because of process_bracket_call above
245
247
  if array? target
246
248
  exp = process_array_access(target, exp.args, exp)
247
249
  elsif hash? target
@@ -666,7 +668,9 @@ class Brakeman::AliasProcessor < Brakeman::SexpProcessor
666
668
  end
667
669
 
668
670
  unless array? exp[1] and array? exp[2]
669
- return process_default(exp)
671
+ # Already processed RHS, don't do it again
672
+ # https://github.com/presidentbeef/brakeman/issues/1877
673
+ return exp
670
674
  end
671
675
 
672
676
  vars = exp[1].dup
@@ -13,7 +13,7 @@ module Brakeman
13
13
  @file_type = guess_from_path(file.path.relative)
14
14
  end
15
15
 
16
- @file_type || :libs
16
+ @file_type || :lib
17
17
  end
18
18
 
19
19
  MODEL_CLASSES = [
@@ -26,10 +26,10 @@ module Brakeman
26
26
  parent = class_name(exp.parent_name)
27
27
 
28
28
  if name.match(/Controller$/)
29
- @file_type = :controllers
29
+ @file_type = :controller
30
30
  return exp
31
31
  elsif MODEL_CLASSES.include? parent
32
- @file_type = :models
32
+ @file_type = :model
33
33
  return exp
34
34
  end
35
35
 
@@ -39,19 +39,21 @@ module Brakeman
39
39
  def guess_from_path path
40
40
  case
41
41
  when path.include?('app/models')
42
- :models
42
+ :model
43
43
  when path.include?('app/controllers')
44
- :controllers
44
+ :controller
45
45
  when path.include?('config/initializers')
46
- :initializers
46
+ :initializer
47
47
  when path.include?('lib/')
48
- :libs
48
+ :lib
49
49
  when path.match?(%r{config/environments/(?!production\.rb)$})
50
50
  :skip
51
51
  when path.match?(%r{environments/production\.rb$})
52
52
  :skip
53
53
  when path.match?(%r{application\.rb$})
54
54
  :skip
55
+ when path.match?(%r{config/routes\.rb$})
56
+ :skip
55
57
  end
56
58
  end
57
59
 
@@ -130,7 +130,6 @@ module Brakeman
130
130
 
131
131
  output = {
132
132
  :ignored_warnings => warnings,
133
- :updated => Time.now.to_s,
134
133
  :brakeman_version => Brakeman::Version
135
134
  }
136
135