brakeman 7.1.2 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +11 -0
- data/README.md +1 -1
- data/bundle/load.rb +2 -2
- data/bundle/ruby/3.2.0/gems/erubi-1.13.1/CHANGELOG +111 -0
- data/bundle/ruby/3.2.0/gems/{erubis-2.7.0 → erubi-1.13.1}/MIT-LICENSE +1 -0
- data/bundle/ruby/3.2.0/gems/erubi-1.13.1/README.rdoc +151 -0
- data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_block.rb +91 -0
- data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_end.rb +58 -0
- data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi.rb +299 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/asciidoc.rb +12 -5
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/babel.rb +5 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/builder.rb +4 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/coffee.rb +14 -4
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/commonmarker.rb +41 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/csv.rb +63 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/erb.rb +130 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/erubi.rb +41 -8
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/etanni.rb +7 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/haml.rb +67 -1
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/kramdown.rb +59 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/liquid.rb +93 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/livescript.rb +11 -4
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/mapping.rb +8 -8
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/markaby.rb +11 -2
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/nokogiri.rb +13 -2
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/pandoc.rb +81 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/pipeline.rb +6 -1
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/plain.rb +5 -1
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/prawn.rb +17 -6
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/radius.rb +96 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rdiscount.rb +82 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rdoc.rb +33 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/redcarpet.rb +73 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/redcloth.rb +40 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rst-pandoc.rb +33 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/sass.rb +16 -3
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/slim.rb +18 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/string.rb +10 -2
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/template.rb +5 -5
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/typescript.rb +5 -0
- data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/yajl.rb +91 -0
- data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt.rb +1 -2
- data/lib/brakeman/app_tree.rb +7 -2
- data/lib/brakeman/checks/check_model_attributes.rb +1 -1
- data/lib/brakeman/checks/check_render.rb +1 -27
- data/lib/brakeman/checks/check_render_rce.rb +43 -0
- data/lib/brakeman/checks/check_session_settings.rb +1 -1
- data/lib/brakeman/checks.rb +31 -25
- data/lib/brakeman/commandline.rb +6 -1
- data/lib/brakeman/file_parser.rb +3 -2
- data/lib/brakeman/logger.rb +264 -0
- data/lib/brakeman/options.rb +0 -9
- data/lib/brakeman/parsers/rails_erubi.rb +82 -0
- data/lib/brakeman/parsers/template_parser.rb +7 -15
- data/lib/brakeman/processor.rb +2 -2
- data/lib/brakeman/processors/controller_alias_processor.rb +1 -1
- data/lib/brakeman/processors/controller_processor.rb +3 -3
- data/lib/brakeman/processors/{erubis_template_processor.rb → erubi_template_procesor.rb} +3 -3
- data/lib/brakeman/processors/lib/rails2_config_processor.rb +4 -3
- data/lib/brakeman/processors/lib/rails2_route_processor.rb +1 -1
- data/lib/brakeman/processors/lib/render_helper.rb +1 -1
- data/lib/brakeman/processors/lib/render_path.rb +1 -1
- data/lib/brakeman/processors/model_processor.rb +1 -1
- data/lib/brakeman/report/ignore/config.rb +1 -1
- data/lib/brakeman/scanner.rb +25 -49
- data/lib/brakeman/tracker/collection.rb +12 -2
- data/lib/brakeman/tracker/config.rb +17 -13
- data/lib/brakeman/tracker/constants.rb +17 -2
- data/lib/brakeman/tracker/controller.rb +1 -1
- data/lib/brakeman/tracker.rb +7 -15
- data/lib/brakeman/version.rb +1 -1
- data/lib/brakeman.rb +89 -49
- metadata +51 -80
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/CHANGES.txt +0 -828
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/README.txt +0 -102
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis +0 -3468
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis-run.rb +0 -132
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/inline-require +0 -179
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/context.rb +0 -83
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/converter.rb +0 -357
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ec.rb +0 -117
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ecpp.rb +0 -113
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejava.rb +0 -110
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejavascript.rb +0 -119
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/enhanced.rb +0 -126
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eperl.rb +0 -95
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb +0 -99
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eruby.rb +0 -125
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/escheme.rb +0 -114
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/optimized.rb +0 -127
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine.rb +0 -120
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/enhancer.rb +0 -723
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/error.rb +0 -23
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb +0 -88
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/generator.rb +0 -85
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helper.rb +0 -47
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_form_helper.rb +0 -197
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_helper.rb +0 -353
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/local-setting.rb +0 -9
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/main.rb +0 -516
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb +0 -58
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/tiny.rb +0 -144
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/util.rb +0 -22
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis.rb +0 -73
- data/bundle/ruby/3.2.0/gems/erubis-2.7.0/setup.rb +0 -1331
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/creole.rb +0 -16
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/csv.rb +0 -53
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/erb.rb +0 -65
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/kramdown.rb +0 -13
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/liquid.rb +0 -37
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/pandoc.rb +0 -39
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/radius.rb +0 -41
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdiscount.rb +0 -23
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdoc.rb +0 -11
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcarpet.rb +0 -31
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcloth.rb +0 -13
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rst-pandoc.rb +0 -10
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/slim.rb +0 -5
- data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/yajl.rb +0 -81
- data/lib/brakeman/parsers/erubis_patch.rb +0 -11
- data/lib/brakeman/parsers/rails2_erubis.rb +0 -9
- data/lib/brakeman/parsers/rails2_xss_plugin_erubis.rb +0 -52
- data/lib/brakeman/parsers/rails3_erubis.rb +0 -85
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/COPYING +0 -0
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_emacs_org.rb +0 -0
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_handlebars.rb +0 -0
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_jbuilder.rb +0 -0
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_org.rb +0 -0
- /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/cli.rb +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = RDoc (<tt>rdoc</tt>)
|
|
4
|
+
#
|
|
5
|
+
# {RDoc}[http://rdoc.rubyforge.org] is the simple text markup system that comes with Ruby's standard
|
|
6
|
+
# library.
|
|
7
|
+
#
|
|
8
|
+
# === Example
|
|
9
|
+
#
|
|
10
|
+
# = Hello RDoc Templates
|
|
11
|
+
#
|
|
12
|
+
# Hello World. This is a paragraph.
|
|
13
|
+
#
|
|
14
|
+
# === Usage
|
|
15
|
+
#
|
|
16
|
+
# __NOTE:__ It's suggested that your program <tt>require 'rdoc'</tt>,
|
|
17
|
+
# <tt>require 'rdoc/markup'</tt>, and <tt>require 'rdoc/markup/to_html'</tt> at load time
|
|
18
|
+
# when using this template engine in a threaded environment.
|
|
19
|
+
#
|
|
20
|
+
# === See also
|
|
21
|
+
#
|
|
22
|
+
# * {RDoc}[http://rdoc.rubyforge.org]
|
|
23
|
+
# * {RDoc Github}[https://github.com/ruby/rdoc]
|
|
24
|
+
|
|
25
|
+
require_relative 'template'
|
|
26
|
+
require 'rdoc'
|
|
27
|
+
require 'rdoc/markup'
|
|
28
|
+
require 'rdoc/markup/to_html'
|
|
29
|
+
require 'rdoc/options'
|
|
30
|
+
|
|
31
|
+
Tilt::RDocTemplate = Tilt::StaticTemplate.subclass do
|
|
32
|
+
RDoc::Markup::ToHtml.new(RDoc::Options.new, nil).convert(@data).to_s
|
|
33
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Markdown (<tt>markdown</tt>, <tt>md</tt>, <tt>mkd</tt>)
|
|
4
|
+
#
|
|
5
|
+
# {Markdown}[http://daringfireball.net/projects/markdown/syntax] is a
|
|
6
|
+
# lightweight markup language, created by John Gruber and Aaron Swartz.
|
|
7
|
+
# For any markup that is not covered by Markdown’s syntax, HTML is used.
|
|
8
|
+
# Marking up plain text with Markdown markup is easy and Markdown
|
|
9
|
+
# formatted texts are readable.
|
|
10
|
+
#
|
|
11
|
+
# === Example
|
|
12
|
+
#
|
|
13
|
+
# Hello Markdown Templates
|
|
14
|
+
# ========================
|
|
15
|
+
#
|
|
16
|
+
# Hello World. This is a paragraph.
|
|
17
|
+
#
|
|
18
|
+
# === Usage
|
|
19
|
+
#
|
|
20
|
+
# To wrap a Markdown formatted document with a layout:
|
|
21
|
+
#
|
|
22
|
+
# layout = Tilt['erb'].new do
|
|
23
|
+
# "<!doctype html><title></title><%= yield %>"
|
|
24
|
+
# end
|
|
25
|
+
# data = Tilt['md'].new { "# hello tilt" }
|
|
26
|
+
# layout.render { data.render }
|
|
27
|
+
# # => "<!doctype html><title></title><h1>hello tilt</h1>\n"
|
|
28
|
+
#
|
|
29
|
+
# === Options
|
|
30
|
+
#
|
|
31
|
+
# ==== <tt>:smartypants => true|false</tt>
|
|
32
|
+
#
|
|
33
|
+
# Set <tt>true</tt> to enable [Smarty Pants][smartypants] style punctuation replacement.
|
|
34
|
+
#
|
|
35
|
+
# ==== <tt>:escape_html => true|false</tt>
|
|
36
|
+
#
|
|
37
|
+
# Set <tt>true</tt> disallow raw HTML in Markdown contents. HTML is converted to
|
|
38
|
+
# literal text by escaping <tt><</tt> characters.
|
|
39
|
+
#
|
|
40
|
+
# === See also
|
|
41
|
+
#
|
|
42
|
+
# * {Markdown Syntax Documentation}[http://daringfireball.net/projects/markdown/syntax]
|
|
43
|
+
|
|
44
|
+
require_relative 'template'
|
|
45
|
+
require 'redcarpet'
|
|
46
|
+
|
|
47
|
+
aliases = {:escape_html => :filter_html, :smartypants => :smart}.freeze
|
|
48
|
+
|
|
49
|
+
Tilt::RedcarpetTemplate = Tilt::StaticTemplate.subclass do
|
|
50
|
+
aliases.each do |opt, aka|
|
|
51
|
+
if options.key?(aka) || !@options.key?(opt)
|
|
52
|
+
@options[opt] = @options.delete(aka)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# only raise an exception if someone is trying to enable :escape_html
|
|
57
|
+
@options.delete(:escape_html) unless @options[:escape_html]
|
|
58
|
+
|
|
59
|
+
renderer = @options.delete(:renderer) || ::Redcarpet::Render::HTML.new(@options)
|
|
60
|
+
if options.delete(:smartypants) && !(renderer.is_a?(Class) && renderer <= ::Redcarpet::Render::SmartyPants)
|
|
61
|
+
renderer = if renderer == ::Redcarpet::Render::XHTML
|
|
62
|
+
::Redcarpet::Render::SmartyHTML.new(:xhtml => true)
|
|
63
|
+
elsif renderer == ::Redcarpet::Render::HTML
|
|
64
|
+
::Redcarpet::Render::SmartyHTML
|
|
65
|
+
elsif renderer.is_a? Class
|
|
66
|
+
Class.new(renderer) { include ::Redcarpet::Render::SmartyPants }
|
|
67
|
+
else
|
|
68
|
+
renderer.extend ::Redcarpet::Render::SmartyPants
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
Redcarpet::Markdown.new(renderer, @options).render(@data)
|
|
73
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Textile (<tt>textile</tt>)
|
|
4
|
+
#
|
|
5
|
+
# Textile is a lightweight markup language originally developed by Dean Allen and
|
|
6
|
+
# billed as a "humane Web text generator". Textile converts its marked-up text
|
|
7
|
+
# input to valid, well-formed XHTML and also inserts character entity references
|
|
8
|
+
# for apostrophes, opening and closing single and double quotation marks,
|
|
9
|
+
# ellipses and em dashes.
|
|
10
|
+
#
|
|
11
|
+
# Textile formatted texts are converted to HTML with the {RedCloth}[http://redcloth.org]
|
|
12
|
+
# engine, which is a Ruby extension written in C.
|
|
13
|
+
#
|
|
14
|
+
# === Example
|
|
15
|
+
#
|
|
16
|
+
# h1. Hello Textile Templates
|
|
17
|
+
#
|
|
18
|
+
# Hello World. This is a paragraph.
|
|
19
|
+
#
|
|
20
|
+
# === Usage
|
|
21
|
+
#
|
|
22
|
+
# __NOTE:__ It's suggested that your program <tt>require 'redcloth'</tt> at load time
|
|
23
|
+
# when using this template engine in a threaded environment.
|
|
24
|
+
#
|
|
25
|
+
# === See Also
|
|
26
|
+
#
|
|
27
|
+
# * {RedCloth}[http://redcloth.org]
|
|
28
|
+
# * https://github.com/jgarber/redcloth
|
|
29
|
+
|
|
30
|
+
require_relative 'template'
|
|
31
|
+
require 'redcloth'
|
|
32
|
+
|
|
33
|
+
Tilt::RedClothTemplate = Tilt::StaticTemplate.subclass do
|
|
34
|
+
engine = RedCloth.new(@data)
|
|
35
|
+
@options.each do |k, v|
|
|
36
|
+
m = :"#{k}="
|
|
37
|
+
engine.send(m, v) if engine.respond_to? m
|
|
38
|
+
end
|
|
39
|
+
engine.to_html
|
|
40
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = reStructuredText (<tt>rst</tt>)
|
|
4
|
+
#
|
|
5
|
+
# reStructuredText is a lightweight markup language originally developed by David Goodger,
|
|
6
|
+
# based on StructuredText and Setext. reStructuredText is primarily used for technical
|
|
7
|
+
# documentation in the Python programming language community, e.g. by the
|
|
8
|
+
# {Sphinx}[http://www.sphinx-doc.org/en/stable/rest.html] Python documentation generator.
|
|
9
|
+
#
|
|
10
|
+
# reStructuredText formatted texts are converted to HTML with {Pandoc}[http://pandoc.org/], which
|
|
11
|
+
# is an application written in Haskell, with a Ruby wrapper provided by the
|
|
12
|
+
# {pandoc-ruby}[https://github.com/alphabetum/pandoc-ruby] gem.
|
|
13
|
+
#
|
|
14
|
+
# === Example
|
|
15
|
+
#
|
|
16
|
+
# Hello Rst Templates
|
|
17
|
+
# ===================
|
|
18
|
+
#
|
|
19
|
+
# Hello World. This is a paragraph.
|
|
20
|
+
#
|
|
21
|
+
# === See Also
|
|
22
|
+
#
|
|
23
|
+
# * {Pandoc}[http://pandoc.org/]
|
|
24
|
+
# * {pandoc-ruby}[https://github.com/alphabetum/pandoc-ruby]
|
|
25
|
+
|
|
26
|
+
require_relative 'template'
|
|
27
|
+
require_relative 'pandoc'
|
|
28
|
+
|
|
29
|
+
rst = {:f => "rst"}.freeze
|
|
30
|
+
|
|
31
|
+
Tilt::RstPandocTemplate = Tilt::StaticTemplate.subclass do
|
|
32
|
+
PandocRuby.new(@data, rst).to_html.strip
|
|
33
|
+
end
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Sass / Scss
|
|
4
|
+
#
|
|
5
|
+
# Sass/Scss template implementation for generating CSS.
|
|
6
|
+
#
|
|
7
|
+
# Sass templates do not support object scopes, locals, or yield.
|
|
8
|
+
#
|
|
9
|
+
# === See also
|
|
10
|
+
#
|
|
11
|
+
# * https://sass-lang.com/
|
|
12
|
+
#
|
|
13
|
+
# === Related modules
|
|
14
|
+
#
|
|
15
|
+
# * Tilt::SassTemplate
|
|
16
|
+
# * Tilt::ScssTemplate
|
|
17
|
+
|
|
2
18
|
require_relative 'template'
|
|
3
19
|
|
|
4
20
|
module Tilt
|
|
5
|
-
# Sass template implementation for generating CSS. See: https://sass-lang.com/
|
|
6
|
-
#
|
|
7
|
-
# Sass templates do not support object scopes, locals, or yield.
|
|
8
21
|
class SassTemplate < StaticTemplate
|
|
9
22
|
self.default_mime_type = 'text/css'
|
|
10
23
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Slim (<tt>slim</tt>)
|
|
4
|
+
#
|
|
5
|
+
# === Embedded locals
|
|
6
|
+
#
|
|
7
|
+
# In slim templates, the comment format looks like this:
|
|
8
|
+
#
|
|
9
|
+
# //# locals: ()
|
|
10
|
+
#
|
|
11
|
+
# === See also
|
|
12
|
+
#
|
|
13
|
+
# * https://slim-template.github.io
|
|
14
|
+
|
|
15
|
+
require_relative 'template'
|
|
16
|
+
require 'slim'
|
|
17
|
+
|
|
18
|
+
Tilt::SlimTemplate = Slim::Template
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = String
|
|
4
|
+
#
|
|
5
|
+
# The template source is evaluated as a Ruby string. The #{} interpolation
|
|
6
|
+
# syntax can be used to generated dynamic output.
|
|
7
|
+
#
|
|
8
|
+
# === Related module
|
|
9
|
+
#
|
|
10
|
+
# * Tilt::StringTemplate
|
|
11
|
+
|
|
2
12
|
require_relative 'template'
|
|
3
13
|
|
|
4
14
|
module Tilt
|
|
5
|
-
# The template source is evaluated as a Ruby string. The #{} interpolation
|
|
6
|
-
# syntax can be used to generated dynamic output.
|
|
7
15
|
class StringTemplate < Template
|
|
8
16
|
def prepare
|
|
9
17
|
hash = "TILT#{@data.hash.abs}"
|
|
@@ -41,12 +41,12 @@ module Tilt
|
|
|
41
41
|
@metadata ||= {}
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
# Use
|
|
44
|
+
# Use <tt>.metadata[:mime_type]</tt> instead.
|
|
45
45
|
def default_mime_type
|
|
46
46
|
metadata[:mime_type]
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
# Use
|
|
49
|
+
# Use <tt>.metadata[:mime_type] = val</tt> instead.
|
|
50
50
|
def default_mime_type=(value)
|
|
51
51
|
metadata[:mime_type] = value
|
|
52
52
|
end
|
|
@@ -376,10 +376,10 @@ module Tilt
|
|
|
376
376
|
|
|
377
377
|
s = "locals = locals[:locals]"
|
|
378
378
|
if assignments.delete(s)
|
|
379
|
-
# If there is a locals key itself named
|
|
379
|
+
# If there is a locals key itself named <tt>locals</tt>, delete it from the ordered keys so we can
|
|
380
380
|
# assign it last. This is important because the assignment of all other locals depends on the
|
|
381
|
-
#
|
|
382
|
-
# created in
|
|
381
|
+
# <tt>locals</tt> local variable still matching the <tt>locals</tt> method argument given to the method
|
|
382
|
+
# created in <tt>#compile_template_method</tt>.
|
|
383
383
|
assignments << s
|
|
384
384
|
end
|
|
385
385
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Yajl
|
|
4
|
+
#
|
|
5
|
+
# Yajl Template implementation
|
|
6
|
+
#
|
|
7
|
+
# Yajl is a fast JSON parsing and encoding library for Ruby
|
|
8
|
+
#
|
|
9
|
+
# The template source is evaluated as a Ruby string,
|
|
10
|
+
# and the result is converted #to_json.
|
|
11
|
+
#
|
|
12
|
+
# === Example
|
|
13
|
+
#
|
|
14
|
+
# # This is a template example.
|
|
15
|
+
# # The template can contain any Ruby statement.
|
|
16
|
+
# tpl <<-EOS
|
|
17
|
+
# @counter = 0
|
|
18
|
+
#
|
|
19
|
+
# # The json variable represents the buffer
|
|
20
|
+
# # and holds the data to be serialized into json.
|
|
21
|
+
# # It defaults to an empty hash, but you can override it at any time.
|
|
22
|
+
# json = {
|
|
23
|
+
# :"user#{@counter += 1}" => { :name => "Joshua Peek", :id => @counter },
|
|
24
|
+
# :"user#{@counter += 1}" => { :name => "Ryan Tomayko", :id => @counter },
|
|
25
|
+
# :"user#{@counter += 1}" => { :name => "Simone Carletti", :id => @counter },
|
|
26
|
+
# }
|
|
27
|
+
#
|
|
28
|
+
# # Since the json variable is a Hash,
|
|
29
|
+
# # you can use conditional statements or any other Ruby statement
|
|
30
|
+
# # to populate it.
|
|
31
|
+
# json[:"user#{@counter += 1}"] = { :name => "Unknown" } if 1 == 2
|
|
32
|
+
#
|
|
33
|
+
# # The last line doesn't affect the returned value.
|
|
34
|
+
# nil
|
|
35
|
+
# EOS
|
|
36
|
+
#
|
|
37
|
+
# template = Tilt::YajlTemplate.new { tpl }
|
|
38
|
+
# template.render(self)
|
|
39
|
+
#
|
|
40
|
+
# === See also
|
|
41
|
+
#
|
|
42
|
+
# * https://github.com/brianmario/yajl-ruby
|
|
43
|
+
#
|
|
44
|
+
# === Related module
|
|
45
|
+
#
|
|
46
|
+
# * Tilt::YajlTemplate
|
|
47
|
+
|
|
48
|
+
require_relative 'template'
|
|
49
|
+
require 'yajl'
|
|
50
|
+
|
|
51
|
+
module Tilt
|
|
52
|
+
class YajlTemplate < Template
|
|
53
|
+
self.default_mime_type = 'application/json'
|
|
54
|
+
|
|
55
|
+
def evaluate(scope, locals, &block)
|
|
56
|
+
decorate(super)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def precompiled_preamble(locals)
|
|
60
|
+
return super if locals.include? :json
|
|
61
|
+
"json = {}\n#{super}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def precompiled_postamble(locals)
|
|
65
|
+
"Yajl::Encoder.new.encode(json)"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def precompiled_template(locals)
|
|
69
|
+
@data.to_str
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Decorates the +json+ input according to given +options+.
|
|
73
|
+
#
|
|
74
|
+
# json - The json String to decorate.
|
|
75
|
+
# options - The option Hash to customize the behavior.
|
|
76
|
+
#
|
|
77
|
+
# Returns the decorated String.
|
|
78
|
+
def decorate(json)
|
|
79
|
+
callback, variable = @options[:callback], @options[:variable]
|
|
80
|
+
if callback && variable
|
|
81
|
+
"var #{variable} = #{json}; #{callback}(#{variable});"
|
|
82
|
+
elsif variable
|
|
83
|
+
"var #{variable} = #{json};"
|
|
84
|
+
elsif callback
|
|
85
|
+
"#{callback}(#{json});"
|
|
86
|
+
else
|
|
87
|
+
json
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -5,7 +5,7 @@ require_relative 'tilt/template'
|
|
|
5
5
|
# Namespace for Tilt. This module is not intended to be included anywhere.
|
|
6
6
|
module Tilt
|
|
7
7
|
# Current version.
|
|
8
|
-
VERSION = '2.
|
|
8
|
+
VERSION = '2.7.0'
|
|
9
9
|
|
|
10
10
|
EMPTY_ARRAY = [].freeze
|
|
11
11
|
private_constant :EMPTY_ARRAY
|
|
@@ -163,7 +163,6 @@ module Tilt
|
|
|
163
163
|
register_lazy :CSVTemplate, 'tilt/csv', 'rcsv'
|
|
164
164
|
register_lazy :CoffeeScriptTemplate, 'tilt/coffee', 'coffee'
|
|
165
165
|
register_lazy :CoffeeScriptLiterateTemplate, 'tilt/coffee', 'litcoffee'
|
|
166
|
-
register_lazy :CreoleTemplate, 'tilt/creole', 'wiki', 'creole'
|
|
167
166
|
register_lazy :EtanniTemplate, 'tilt/etanni', 'etn', 'etanni'
|
|
168
167
|
register_lazy :HamlTemplate, 'tilt/haml', 'haml'
|
|
169
168
|
register_lazy :LiquidTemplate, 'tilt/liquid', 'liquid'
|
data/lib/brakeman/app_tree.rb
CHANGED
|
@@ -120,7 +120,7 @@ module Brakeman
|
|
|
120
120
|
|
|
121
121
|
def template_paths
|
|
122
122
|
@template_paths ||= find_paths(".", "*.{#{VIEW_EXTENSIONS}}") +
|
|
123
|
-
find_paths("
|
|
123
|
+
find_paths(".", "*.{erb,haml,slim}").reject { |path| File.basename(path).count(".") > 1 }
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
def layout_exists?(name)
|
|
@@ -213,13 +213,17 @@ module Brakeman
|
|
|
213
213
|
end
|
|
214
214
|
|
|
215
215
|
def reject_directories(paths)
|
|
216
|
-
paths.reject
|
|
216
|
+
paths.reject do |path|
|
|
217
|
+
Brakeman.logger.spin
|
|
218
|
+
File.directory?(path)
|
|
219
|
+
end
|
|
217
220
|
end
|
|
218
221
|
|
|
219
222
|
def select_only_files(paths)
|
|
220
223
|
return paths unless @only_files
|
|
221
224
|
|
|
222
225
|
paths.select do |path|
|
|
226
|
+
Brakeman.logger.spin
|
|
223
227
|
match_path @only_files, path
|
|
224
228
|
end
|
|
225
229
|
end
|
|
@@ -228,6 +232,7 @@ module Brakeman
|
|
|
228
232
|
return paths unless @skip_files
|
|
229
233
|
|
|
230
234
|
paths.reject do |path|
|
|
235
|
+
Brakeman.logger.spin
|
|
231
236
|
match_path @skip_files, path
|
|
232
237
|
end
|
|
233
238
|
end
|
|
@@ -12,7 +12,7 @@ class Brakeman::CheckModelAttributes < Brakeman::BaseCheck
|
|
|
12
12
|
|
|
13
13
|
#Roll warnings into one warning for all models
|
|
14
14
|
if tracker.options[:collapse_mass_assignment]
|
|
15
|
-
Brakeman.
|
|
15
|
+
Brakeman.alert "The `collapse_mass_assignment` option has been removed."
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
check_models do |name, model|
|
|
@@ -17,8 +17,7 @@ class Brakeman::CheckRender < Brakeman::BaseCheck
|
|
|
17
17
|
|
|
18
18
|
case result[:call].render_type
|
|
19
19
|
when :partial, :template, :action, :file
|
|
20
|
-
|
|
21
|
-
check_for_dynamic_path(result)
|
|
20
|
+
check_for_dynamic_path(result)
|
|
22
21
|
when :inline
|
|
23
22
|
when :js
|
|
24
23
|
when :json
|
|
@@ -41,8 +40,6 @@ class Brakeman::CheckRender < Brakeman::BaseCheck
|
|
|
41
40
|
else
|
|
42
41
|
confidence = :high
|
|
43
42
|
end
|
|
44
|
-
elsif input = include_user_input?(view)
|
|
45
|
-
confidence = :weak
|
|
46
43
|
else
|
|
47
44
|
return
|
|
48
45
|
end
|
|
@@ -62,29 +59,6 @@ class Brakeman::CheckRender < Brakeman::BaseCheck
|
|
|
62
59
|
end
|
|
63
60
|
end
|
|
64
61
|
|
|
65
|
-
def check_for_rce result
|
|
66
|
-
return unless version_between? "0.0.0", "3.2.22" or
|
|
67
|
-
version_between? "4.0.0", "4.1.14" or
|
|
68
|
-
version_between? "4.2.0", "4.2.5"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
view = result[:call][2]
|
|
72
|
-
if sexp? view and not duplicate? result
|
|
73
|
-
if params? view
|
|
74
|
-
add_result result
|
|
75
|
-
return if safe_param? view
|
|
76
|
-
|
|
77
|
-
warn :result => result,
|
|
78
|
-
:warning_type => "Remote Code Execution",
|
|
79
|
-
:warning_code => :dynamic_render_path_rce,
|
|
80
|
-
:message => msg("Passing query parameters to ", msg_code("render"), " is vulnerable in ", msg_version(rails_version), " ", msg_cve("CVE-2016-0752")),
|
|
81
|
-
:user_input => view,
|
|
82
|
-
:confidence => :high,
|
|
83
|
-
:cwe_id => [22]
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
62
|
def safe_param? exp
|
|
89
63
|
if params? exp and call? exp
|
|
90
64
|
method_name = exp.method
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'brakeman/checks/check_render'
|
|
2
|
+
|
|
3
|
+
class Brakeman::CheckRenderRCE < Brakeman::CheckRender
|
|
4
|
+
Brakeman::Checks.add self
|
|
5
|
+
|
|
6
|
+
@description = "Finds calls to render that might be vulnerable to CVE-2016-0752"
|
|
7
|
+
|
|
8
|
+
def run_check
|
|
9
|
+
tracker.find_call(:target => nil, :method => :render).each do |result|
|
|
10
|
+
process_render_result result
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def process_render_result result
|
|
15
|
+
return unless node_type? result[:call], :render
|
|
16
|
+
|
|
17
|
+
case result[:call].render_type
|
|
18
|
+
when :partial, :template, :action, :file
|
|
19
|
+
check_for_rce(result)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def check_for_rce result
|
|
24
|
+
return unless version_between? "0.0.0", "3.2.22" or
|
|
25
|
+
version_between? "4.0.0", "4.1.14" or
|
|
26
|
+
version_between? "4.2.0", "4.2.5"
|
|
27
|
+
|
|
28
|
+
view = result[:call][2]
|
|
29
|
+
if sexp? view and not duplicate? result
|
|
30
|
+
if params? view and not safe_param? view
|
|
31
|
+
add_result result
|
|
32
|
+
|
|
33
|
+
warn :result => result,
|
|
34
|
+
:warning_type => "Remote Code Execution",
|
|
35
|
+
:warning_code => :dynamic_render_path_rce,
|
|
36
|
+
:message => msg("Passing query parameters to ", msg_code("render"), " is vulnerable in ", msg_version(rails_version), " ", msg_cve("CVE-2016-0752")),
|
|
37
|
+
:user_input => view,
|
|
38
|
+
:confidence => :high,
|
|
39
|
+
:cwe_id => [22]
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -120,7 +120,7 @@ class Brakeman::CheckSessionSettings < Brakeman::BaseCheck
|
|
|
120
120
|
begin
|
|
121
121
|
secrets = YAML.safe_load yaml, aliases: true
|
|
122
122
|
rescue Psych::SyntaxError, RuntimeError => e
|
|
123
|
-
Brakeman.
|
|
123
|
+
Brakeman.alert "#{self.class}: Unable to parse `#{secrets_file}`"
|
|
124
124
|
Brakeman.debug "Failed to parse #{secrets_file}: #{e.inspect}"
|
|
125
125
|
return
|
|
126
126
|
end
|
data/lib/brakeman/checks.rb
CHANGED
|
@@ -121,37 +121,43 @@ class Brakeman::Checks
|
|
|
121
121
|
parallel = tracker.options[:parallel_checks]
|
|
122
122
|
error_mutex = Mutex.new
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
message = if parallel
|
|
125
|
+
"Running #{checks.length} checks in parallel"
|
|
126
|
+
else
|
|
127
|
+
"Running #{checks.length} checks"
|
|
128
|
+
end
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
Brakeman.process_step(message) do
|
|
131
|
+
checks.each do |c|
|
|
132
|
+
check_name = get_check_name c
|
|
133
|
+
Brakeman.debug " - #{check_name}"
|
|
134
|
+
|
|
135
|
+
if parallel
|
|
136
|
+
threads << Thread.new do
|
|
137
|
+
self.run_a_check(c, error_mutex, tracker)
|
|
138
|
+
end
|
|
139
|
+
else
|
|
140
|
+
results << self.run_a_check(c, error_mutex, tracker)
|
|
131
141
|
end
|
|
132
|
-
else
|
|
133
|
-
results << self.run_a_check(c, error_mutex, tracker)
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
#Maintain list of which checks were run
|
|
137
|
-
#mainly for reporting purposes
|
|
138
|
-
check_runner.checks_run << check_name[5..-1]
|
|
139
|
-
end
|
|
140
142
|
|
|
141
|
-
|
|
143
|
+
#Maintain list of which checks were run
|
|
144
|
+
#mainly for reporting purposes
|
|
145
|
+
check_runner.checks_run << check_name[5..-1]
|
|
146
|
+
end
|
|
142
147
|
|
|
143
|
-
|
|
148
|
+
threads.each { |t| t.join }
|
|
144
149
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
if parallel
|
|
151
|
+
threads.each do |thread|
|
|
152
|
+
thread.value.each do |warning|
|
|
153
|
+
check_runner.add_warning warning
|
|
154
|
+
end
|
|
149
155
|
end
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
156
|
+
else
|
|
157
|
+
results.each do |warnings|
|
|
158
|
+
warnings.each do |warning|
|
|
159
|
+
check_runner.add_warning warning
|
|
160
|
+
end
|
|
155
161
|
end
|
|
156
162
|
end
|
|
157
163
|
end
|
data/lib/brakeman/commandline.rb
CHANGED
|
@@ -54,11 +54,13 @@ module Brakeman
|
|
|
54
54
|
f.puts JSON.pretty_generate(vulns)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
Brakeman.
|
|
57
|
+
Brakeman.announce "Comparison saved in '#{options[:comparison_output_file]}'"
|
|
58
58
|
else
|
|
59
59
|
puts JSON.pretty_generate(vulns)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
Brakeman.cleanup(false)
|
|
63
|
+
|
|
62
64
|
if options[:exit_on_warn] && vulns[:new].count > 0
|
|
63
65
|
quit Brakeman::Warnings_Found_Exit_Code
|
|
64
66
|
end
|
|
@@ -117,6 +119,7 @@ module Brakeman
|
|
|
117
119
|
# Override this method for different behavior.
|
|
118
120
|
def quit exit_code = 0, message = nil
|
|
119
121
|
warn message if message
|
|
122
|
+
Brakeman.cleanup
|
|
120
123
|
exit exit_code
|
|
121
124
|
end
|
|
122
125
|
|
|
@@ -186,6 +189,8 @@ module Brakeman
|
|
|
186
189
|
warn caller
|
|
187
190
|
end
|
|
188
191
|
|
|
192
|
+
Brakeman.cleanup
|
|
193
|
+
|
|
189
194
|
exit!
|
|
190
195
|
end
|
|
191
196
|
end
|
data/lib/brakeman/file_parser.rb
CHANGED
|
@@ -13,9 +13,9 @@ module Brakeman
|
|
|
13
13
|
if @use_prism
|
|
14
14
|
begin
|
|
15
15
|
require 'prism'
|
|
16
|
-
Brakeman.debug '
|
|
16
|
+
Brakeman.debug 'Using Prism parser'
|
|
17
17
|
rescue LoadError => e
|
|
18
|
-
Brakeman.debug "
|
|
18
|
+
Brakeman.debug "Asked to use Prism, but failed to load: #{e}"
|
|
19
19
|
@use_prism = false
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -46,6 +46,7 @@ module Brakeman
|
|
|
46
46
|
#
|
|
47
47
|
# Note this method no longer uses read_files
|
|
48
48
|
@file_list, new_errors = Parallel.map(list, parallel_options) do |file_name|
|
|
49
|
+
Brakeman.logger.spin
|
|
49
50
|
file_path = @app_tree.file_path(file_name)
|
|
50
51
|
contents = file_path.read
|
|
51
52
|
|