Class: Brakeman::Report::Markdown
- Defined in:
- lib/brakeman/report/report_markdown.rb
Defined Under Namespace
Classes: MarkdownTable
Constant Summary
Constants included from Util
Util::ALL_COOKIES, Util::ALL_PARAMETERS, Util::COOKIES, Util::COOKIES_SEXP, Util::DIR_CONST, Util::LITERALS, Util::PARAMETERS, Util::PARAMS_SEXP, Util::PATH_PARAMETERS, Util::QUERY_PARAMETERS, Util::REQUEST_COOKIES, Util::REQUEST_ENV, Util::REQUEST_PARAMETERS, Util::REQUEST_PARAMS, Util::REQUEST_REQUEST_PARAMETERS, Util::SAFE_LITERAL, Util::SESSION, Util::SESSION_SEXP, Util::SIMPLE_LITERALS
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #convert_warning(warning, original) ⇒ Object
- #generate_checks ⇒ Object
- #generate_metadata ⇒ Object
- #generate_report ⇒ Object
-
#initialize(*args) ⇒ Markdown
constructor
A new instance of Markdown.
-
#markdown_message(warning, message) ⇒ Object
Escape and code format warning message.
- #output_table(title, result, output) ⇒ Object
Methods inherited from Table
#convert_ignored_warning, #convert_template_warning, #convert_to_rows, #generate_controller_warnings, #generate_controllers, #generate_errors, #generate_ignored_warnings, #generate_model_warnings, #generate_obsolete, #generate_overview, #generate_template_warnings, #generate_templates, #generate_warning_overview, #generate_warnings, #render_array, #render_warnings, #sort, #text_header, #text_message, #truncate_table
Methods inherited from Base
#absolute_paths?, #all_warnings, #context_for, #controller_information, #controller_warnings, #filter_warnings, #generic_warnings, #github_url, #ignored_warnings, #model_warnings, #number_of_templates, #rails_version, #template_warnings, #warning_file, #warnings_summary
Methods included from Util
#all_literals?, #array?, #block?, #call?, #camelize, #class_name, #constant?, #contains_class?, #cookies?, #dir_glob?, #false?, #hash?, #hash_access, #hash_insert, #hash_iterate, #hash_values, #integer?, #kwsplat?, #literal?, #make_call, #node_type?, #number?, #params?, #pluralize, #rails_version, #recurse_check?, #regexp?, #remove_kwsplat, #request_headers?, #request_value?, #result?, #safe_literal, #safe_literal?, #safe_literal_target?, #set_env_defaults, #sexp?, #simple_literal?, #string?, #string_interp?, #symbol?, #template_path_to_name, #true?, #underscore
Constructor Details
#initialize(*args) ⇒ Markdown
Returns a new instance of Markdown.
24 25 26 27 |
# File 'lib/brakeman/report/report_markdown.rb', line 24 def initialize *args super @table = MarkdownTable end |
Instance Method Details
#convert_warning(warning, original) ⇒ Object
86 87 88 89 90 |
# File 'lib/brakeman/report/report_markdown.rb', line 86 def convert_warning warning, original warning["Message"] = original, warning["Message"] warning["Warning Type"] = "[#{warning['Warning Type']}](#{original.link})" if original.link warning end |
#generate_checks ⇒ Object
80 81 82 83 84 |
# File 'lib/brakeman/report/report_markdown.rb', line 80 def generate_checks MarkdownTable.new(:headings => ['Checks performed']) do |t| t.add_row([checks.checks_run.sort.join(", ")]) end end |
#generate_metadata ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/brakeman/report/report_markdown.rb', line 65 def MarkdownTable.new( :headings => ['Application path', 'Rails version', 'Brakeman version', 'Started at', 'Duration'] ) do |t| t.add_row([ tracker.app_path, rails_version, Brakeman::Version, tracker.start_time, "#{tracker.duration} seconds", ]) end end |
#generate_report ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/brakeman/report/report_markdown.rb', line 29 def generate_report out = "# BRAKEMAN REPORT\n\n" << .to_s << "\n\n" << generate_checks.to_s << "\n\n" << "### SUMMARY\n\n" << generate_overview.to_s << "\n\n" << generate_warning_overview.to_s << "\n\n" #Return output early if only summarizing return out if tracker.[:summary_only] if tracker.[:report_routes] or tracker.[:debug] out << "### CONTROLLERS" << "\n\n" << generate_controllers.to_s << "\n\n" end if tracker.[:debug] out << "### TEMPLATES\n\n" << generate_templates.to_s << "\n\n" end output_table("Errors", generate_errors, out) output_table("SECURITY WARNINGS", generate_warnings, out) output_table("Controller Warnings:", generate_controller_warnings, out) output_table("Model Warnings:", generate_model_warnings, out) output_table("View Warnings:", generate_template_warnings, out) out end |
#markdown_message(warning, message) ⇒ Object
Escape and code format warning message
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/brakeman/report/report_markdown.rb', line 93 def warning, = .to_s if warning.file github_url = github_url warning.file, warning.line if github_url << " near line [#{warning.line}](#{github_url})" elsif warning.line << " near line #{warning.line}" end end if warning.code code = warning.format_code.gsub('`','``').gsub(/\A``|``\z/, '` `') << ": `#{code}`" end end |
#output_table(title, result, output) ⇒ Object
59 60 61 62 63 |
# File 'lib/brakeman/report/report_markdown.rb', line 59 def output_table title, result, output return unless result output << "### #{title}\n\n#{result.to_s}\n\n" end |