Class: Brakeman::Report::CSV
- Defined in:
- lib/brakeman/report/report_csv.rb
Constant Summary
Constants inherited from Base
Constants included from Util
Util::ALL_COOKIES, Util::ALL_PARAMETERS, Util::COOKIES, Util::COOKIES_SEXP, 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
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#csv_header ⇒ Object
Generate header for CSV output.
- #generate_report ⇒ Object
-
#table_to_csv(table) ⇒ Object
rely on Terminal::Table to build the structure, extract the data out in CSV format.
Methods inherited from Table
#convert_ignored_warning, #convert_template_warning, #convert_to_rows, #convert_warning, #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, #initialize, #output_table, #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, #initialize, #model_warnings, #number_of_templates, #rails_version, #template_warnings, #warning_file, #warnings_summary
Methods included from Util
#array?, #block?, #call?, #camelize, #class_name, #constant?, #contains_class?, #cookies?, #false?, #hash?, #hash_access, #hash_insert, #hash_iterate, #integer?, #kwsplat?, #make_call, #node_type?, #number?, #params?, #pluralize, #rails_version, #regexp?, #remove_kwsplat, #request_env?, #request_value?, #result?, #safe_literal, #safe_literal?, #safe_literal_target?, #set_env_defaults, #sexp?, #string?, #string_interp?, #symbol?, #template_path_to_name, #true?, #underscore
Constructor Details
This class inherits a constructor from Brakeman::Report::Table
Instance Method Details
#csv_header ⇒ Object
Generate header for CSV output
50 51 52 53 54 |
# File 'lib/brakeman/report/report_csv.rb', line 50 def csv_header header = CSV.generate_line(["Application Path", "Report Generation Time", "Checks Performed", "Rails Version"]) header << CSV.generate_line([File.(tracker.app_path), Time.now.to_s, checks.checks_run.sort.join(", "), rails_version]) "BRAKEMAN REPORT\n\n" + header end |
#generate_report ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/brakeman/report/report_csv.rb', line 5 def generate_report output = csv_header output << "\nSUMMARY\n" output << table_to_csv(generate_overview) << "\n" output << table_to_csv(generate_warning_overview) << "\n" #Return output early if only summarizing if tracker.[:summary_only] return output end if tracker.[:report_routes] or tracker.[:debug] output << "CONTROLLERS\n" output << table_to_csv(generate_controllers) << "\n" end if tracker.[:debug] output << "TEMPLATES\n\n" output << table_to_csv(generate_templates) << "\n" end res = generate_errors output << "ERRORS\n" << table_to_csv(res) << "\n" if res res = generate_warnings output << "SECURITY WARNINGS\n" << table_to_csv(res) << "\n" if res output << "Controller Warnings\n" res = generate_controller_warnings output << table_to_csv(res) << "\n" if res output << "Model Warnings\n" res = generate_model_warnings output << table_to_csv(res) << "\n" if res res = generate_template_warnings output << "Template Warnings\n" output << table_to_csv(res) << "\n" if res output end |
#table_to_csv(table) ⇒ Object
rely on Terminal::Table to build the structure, extract the data out in CSV format
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/brakeman/report/report_csv.rb', line 57 def table_to_csv table return "" unless table Brakeman.load_brakeman_dependency 'terminal-table' headings = table.headings if headings.is_a? Array headings = headings.first end output = CSV.generate_line(headings.cells.map{|cell| cell.to_s.strip}) table.rows.each do |row| output << CSV.generate_line(row.cells.map{|cell| cell.to_s.strip}) end output end |