Class: Brakeman::Report
Overview
Generates a report based on the Tracker and the results of Tracker#run_checks. Be sure to run_checks
before generating a report.
Constant Summary collapse
- TEXT_CONFIDENCE =
[ "High", "Medium", "Weak" ]
- HTML_CONFIDENCE =
[ "<span class='high-confidence'>High</span>", "<span class='med-confidence'>Medium</span>", "<span class='weak-confidence'>Weak</span>" ]
Constants included from Util
Util::ALL_PARAMETERS, Util::COOKIES, Util::PARAMETERS, Util::PATH_PARAMETERS, Util::QUERY_PARAMETERS, Util::REQUEST_ENV, Util::REQUEST_PARAMETERS, Util::REQUEST_PARAMS, Util::SESSION
Instance Attribute Summary collapse
-
#checks ⇒ Object
readonly
Returns the value of attribute checks.
-
#tracker ⇒ Object
readonly
Returns the value of attribute tracker.
Instance Method Summary collapse
- #all_warnings ⇒ Object
-
#csv_header ⇒ Object
Generate header for CSV output.
-
#generate_controller_warnings(html = false) ⇒ Object
Generate table of controller warnings or nil if no warnings.
-
#generate_controllers(html = false) ⇒ Object
Generate table of controllers and routes found for those controllers.
-
#generate_errors(html = false) ⇒ Object
Generate table of errors or return nil if no errors.
-
#generate_model_warnings(html = false) ⇒ Object
Generate table of model warnings or return nil if no warnings.
-
#generate_overview(html = false) ⇒ Object
Generate summary table of what was parsed.
-
#generate_template_warnings(html = false) ⇒ Object
Generate table of template warnings or return nil if no warnings.
-
#generate_templates(html = false) ⇒ Object
Generate listings of templates and their output.
-
#generate_warning_overview(html = false) ⇒ Object
Generate table of how many warnings of each warning type were reported.
-
#generate_warnings(html = false) ⇒ Object
Generate table of general security warnings.
-
#html_header ⇒ Object
Return header for HTML output.
-
#html_message(warning, message) ⇒ Object
Escape warning message and highlight user input in HTML output.
-
#initialize(tracker) ⇒ Report
constructor
A new instance of Report.
- #number_of_templates(tracker) ⇒ Object
- #rails_version ⇒ Object
-
#text_header ⇒ Object
Generate header for text output.
-
#text_message(warning, message) ⇒ Object
Escape warning message and highlight user input in text output.
-
#to_csv ⇒ Object
Generate CSV output.
-
#to_html ⇒ Object
Generate HTML output.
- #to_json ⇒ Object
-
#to_pdf ⇒ Object
Not yet implemented.
-
#to_s ⇒ Object
Output text version of the report.
-
#to_tabs ⇒ Object
Generated tab-separated output suitable for the Jenkins Brakeman Plugin: github.com/presidentbeef/brakeman-jenkins-plugin.
- #to_test ⇒ Object
- #warning_file(warning, relative = false) ⇒ Object
-
#warnings_summary ⇒ Object
Return summary of warnings in hash and store in @warnings_summary.
-
#with_context(warning, message) ⇒ Object
Generate HTML for warnings, including context show/hidden via Javascript.
- #with_link(warning, message) ⇒ Object
Methods included from Util
#array?, #call?, #camelize, #contains_class?, #context_for, #cookies?, #false?, #file_by_name, #file_for, #hash?, #hash_access, #hash_insert, #hash_iterate, #integer?, #node_type?, #number?, #params?, #pluralize, #regexp?, #request_env?, #request_value?, #result?, #set_env_defaults, #sexp?, #string?, #symbol?, #table_to_csv, #true?, #truncate_table, #underscore
Constructor Details
#initialize(tracker) ⇒ Report
Returns a new instance of Report.
43 44 45 46 47 48 49 |
# File 'lib/brakeman/report.rb', line 43 def initialize tracker @tracker = tracker @checks = tracker.checks @element_id = 0 #Used for HTML ids @warnings_summary = nil @highlight_user_input = tracker.[:highlight_user_input] end |
Instance Attribute Details
#checks ⇒ Object (readonly)
Returns the value of attribute checks.
36 37 38 |
# File 'lib/brakeman/report.rb', line 36 def checks @checks end |
#tracker ⇒ Object (readonly)
Returns the value of attribute tracker.
36 37 38 |
# File 'lib/brakeman/report.rb', line 36 def tracker @tracker end |
Instance Method Details
#all_warnings ⇒ Object
690 691 692 |
# File 'lib/brakeman/report.rb', line 690 def all_warnings @all_warnings ||= @checks.all_warnings end |
#csv_header ⇒ Object
Generate header for CSV output
482 483 484 485 486 |
# File 'lib/brakeman/report.rb', line 482 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_controller_warnings(html = false) ⇒ Object
Generate table of controller warnings or nil if no warnings
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/brakeman/report.rb', line 216 def generate_controller_warnings html = false unless checks.controller_warnings.empty? warnings = [] checks.controller_warnings.each do |warning| w = warning.to_row :controller if html w["Confidence"] = HTML_CONFIDENCE[w["Confidence"]] w["Message"] = with_context warning, w["Message"] w["Warning Type"] = with_link warning, w["Warning Type"] else w["Confidence"] = TEXT_CONFIDENCE[w["Confidence"]] w["Message"] = warning, w["Message"] end warnings << w end return nil if warnings.empty? stabilizer = 0 warnings = warnings.sort_by{|row| stabilizer +=1; [row["Confidence"], row["Warning Type"], row["Controller"], stabilizer]} if html load_and_render_erb('controller_warnings', binding) else Terminal::Table.new(:headings => ["Confidence", "Controller", "Warning Type", "Message"]) do |t| warnings.each do |warning| t.add_row [warning["Confidence"], warning["Controller"], warning["Warning Type"], warning["Message"]] end end end else nil end end |
#generate_controllers(html = false) ⇒ Object
Generate table of controllers and routes found for those controllers
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/brakeman/report.rb', line 254 def generate_controllers html=false controller_rows = [] tracker.controllers.keys.map{|k| k.to_s}.sort.each do |name| name = name.to_sym c = tracker.controllers[name] if tracker.routes[:allow_all_actions] or tracker.routes[name] == :allow_all_actions routes = c[:public].keys.map{|e| e.to_s}.sort.join(", ") elsif tracker.routes[name].nil? #No routes defined for this controller. #This can happen when it is only a parent class #for other controllers, for example. routes = "[None]" else routes = (Set.new(c[:public].keys) & tracker.routes[name.to_sym]). to_a. map {|e| e.to_s}. sort. join(", ") end if routes == "" routes = "[None]" end controller_rows << { "Name" => name.to_s, "Parent" => c[:parent].to_s, "Includes" => c[:includes].join(", "), "Routes" => routes } end controller_rows = controller_rows.sort_by{|row| row['Name']} if html load_and_render_erb('controller_overview', binding) else Terminal::Table.new(:headings => ['Name', 'Parent', 'Includes', 'Routes']) do |t| controller_rows.each do |row| t.add_row [row['Name'], row['Parent'], row['Includes'], row['Routes']] end end end end |
#generate_errors(html = false) ⇒ Object
Generate table of errors or return nil if no errors
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/brakeman/report.rb', line 85 def generate_errors html = false if tracker.errors.any? if html load_and_render_erb('error_overview', binding) else Terminal::Table.new(:headings => ['Error', 'Location']) do |t| tracker.errors.each do |error| t.add_row [error[:error], error[:backtrace][0]] end end end else nil end end |
#generate_model_warnings(html = false) ⇒ Object
Generate table of model warnings or return nil if no warnings
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/brakeman/report.rb', line 179 def generate_model_warnings html = false if checks.model_warnings.any? warnings = [] checks.model_warnings.each do |warning| w = warning.to_row :model if html w["Confidence"] = HTML_CONFIDENCE[w["Confidence"]] w["Message"] = with_context warning, w["Message"] w["Warning Type"] = with_link warning, w["Warning Type"] else w["Confidence"] = TEXT_CONFIDENCE[w["Confidence"]] w["Message"] = warning, w["Message"] end warnings << w end return nil if warnings.empty? stabilizer = 0 warnings = warnings.sort_by{|row| stabilizer +=1; [row["Confidence"],row["Warning Type"], row["Model"], stabilizer]} if html load_and_render_erb('model_warnings', binding) else Terminal::Table.new(:headings => ["Confidence", "Model", "Warning Type", "Message"]) do |t| warnings.each do |warning| t.add_row [warning["Confidence"], warning["Model"], warning["Warning Type"], warning["Message"]] end end end else nil end end |
#generate_overview(html = false) ⇒ Object
Generate summary table of what was parsed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/brakeman/report.rb', line 52 def generate_overview html = false warnings = all_warnings.length if html load_and_render_erb('overview', binding) else Terminal::Table.new(:headings => ['Scanned/Reported', 'Total']) do |t| t.add_row ['Controllers', tracker.controllers.length] t.add_row ['Models', tracker.models.length - 1] t.add_row ['Templates', number_of_templates(@tracker)] t.add_row ['Errors', tracker.errors.length] t.add_row ['Security Warnings', "#{warnings} (#{warnings_summary[:high_confidence]})"] end end end |
#generate_template_warnings(html = false) ⇒ Object
Generate table of template warnings or return nil if no warnings
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/brakeman/report.rb', line 140 def generate_template_warnings html = false if checks.template_warnings.any? warnings = [] checks.template_warnings.each do |warning| w = warning.to_row :template if html w["Confidence"] = HTML_CONFIDENCE[w["Confidence"]] w["Message"] = with_context warning, w["Message"] w["Warning Type"] = with_link warning, w["Warning Type"] w["Called From"] = warning.called_from w["Template Name"] = warning.template[:name] else w["Confidence"] = TEXT_CONFIDENCE[w["Confidence"]] w["Message"] = warning, w["Message"] end warnings << w end return nil if warnings.empty? stabilizer = 0 warnings = warnings.sort_by{|row| stabilizer += 1; [row["Confidence"], row["Warning Type"], row["Template"], stabilizer]} if html load_and_render_erb('view_warnings', binding) else Terminal::Table.new(:headings => ["Confidence", "Template", "Warning Type", "Message"]) do |t| warnings.each do |warning| t.add_row [warning["Confidence"], warning["Template"], warning["Warning Type"], warning["Message"]] end end end else nil end end |
#generate_templates(html = false) ⇒ Object
Generate listings of templates and their output
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/brakeman/report.rb', line 300 def generate_templates html = false out_processor = Brakeman::OutputProcessor.new template_rows = {} tracker.templates.each do |name, template| unless template[:outputs].empty? template[:outputs].each do |out| out = out_processor.format out out = CGI.escapeHTML(out) if html template_rows[name] ||= [] template_rows[name] << out.gsub("\n", ";").gsub(/\s+/, " ") end end end template_rows = template_rows.sort_by{|name, value| name.to_s} if html load_and_render_erb('template_overview', binding) else output = '' template_rows.each do |template| output << template.first.to_s << "\n\n" table = Terminal::Table.new(:headings => ['Output']) do |t| # template[1] is an array of calls template[1].each do |v| t.add_row [v] end end output << table.to_s << "\n\n" end output end end |
#generate_warning_overview(html = false) ⇒ Object
Generate table of how many warnings of each warning type were reported
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/brakeman/report.rb', line 69 def generate_warning_overview html = false types = warnings_summary.keys types.delete :high_confidence if html load_and_render_erb('warning_overview', binding) else Terminal::Table.new(:headings => ['Warning Type', 'Total']) do |t| types.sort.each do |warning_type| t.add_row [warning_type, warnings_summary[warning_type]] end end end end |
#generate_warnings(html = false) ⇒ Object
Generate table of general security warnings
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/brakeman/report.rb', line 102 def generate_warnings html = false = [] checks.warnings.each do |warning| w = warning.to_row if html w["Confidence"] = HTML_CONFIDENCE[w["Confidence"]] w["Message"] = with_context warning, w["Message"] w["Warning Type"] = with_link warning, w["Warning Type"] else w["Confidence"] = TEXT_CONFIDENCE[w["Confidence"]] w["Message"] = warning, w["Message"] end << w end stabilizer = 0 = .sort_by{|row| stabilizer += 1; [row['Confidence'], row['Warning Type'], row['Class'], stabilizer]} if html load_and_render_erb('security_warnings', binding) else if .empty? Terminal::Table.new(:headings => ['General Warnings']) do |t| t.add_row ['[NONE]'] end else Terminal::Table.new(:headings => ["Confidence", "Class", "Method", "Warning Type", "Message"]) do |t| .each do |row| t.add_row [row["Confidence"], row["Class"], row["Method"], row["Warning Type"], row["Message"]] end end end end end |
#html_header ⇒ Object
Return header for HTML output. Uses CSS from tracker.options
466 467 468 469 470 471 472 473 474 |
# File 'lib/brakeman/report.rb', line 466 def html_header if File.exist? tracker.[:html_style] css = File.read tracker.[:html_style] else raise "Cannot find CSS stylesheet for HTML: #{tracker.[:html_style]}" end load_and_render_erb('header', binding) end |
#html_message(warning, message) ⇒ Object
Escape warning message and highlight user input in HTML output
521 522 523 524 525 526 527 528 529 530 531 |
# File 'lib/brakeman/report.rb', line 521 def warning, = CGI.escapeHTML() if @highlight_user_input and warning.user_input user_input = CGI.escapeHTML(warning.format_user_input) .gsub!(user_input, "<span class=\"user_input\">#{user_input}</span>") end end |
#number_of_templates(tracker) ⇒ Object
694 695 696 |
# File 'lib/brakeman/report.rb', line 694 def number_of_templates tracker Set.new(tracker.templates.map {|k,v| v[:name].to_s[/[^.]+/]}).length end |
#rails_version ⇒ Object
455 456 457 458 459 460 461 462 463 |
# File 'lib/brakeman/report.rb', line 455 def rails_version if version = tracker.config[:rails_version] return version elsif tracker.[:rails3] return "3.x" else return "Unknown" end end |
#text_header ⇒ Object
Generate header for text output
477 478 479 |
# File 'lib/brakeman/report.rb', line 477 def text_header "\n+BRAKEMAN REPORT+\n\nApplication path: #{File. tracker.[:app_path]}\nRails version: #{rails_version}\nGenerated at #{Time.now}\nChecks run: #{checks.checks_run.sort.join(", ")}\n" end |
#text_message(warning, message) ⇒ Object
Escape warning message and highlight user input in text output
511 512 513 514 515 516 517 518 |
# File 'lib/brakeman/report.rb', line 511 def warning, if @highlight_user_input and warning.user_input user_input = warning.format_user_input .gsub(user_input, "+#{user_input}+") else end end |
#to_csv ⇒ Object
Generate CSV output
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/brakeman/report.rb', line 406 def to_csv 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 |
#to_html ⇒ Object
Generate HTML output
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/brakeman/report.rb', line 337 def to_html out = html_header << generate_overview(true) << generate_warning_overview(true) # Return early if only summarizing if tracker.[:summary_only] return out end if tracker.[:report_routes] or tracker.[:debug] out << generate_controllers(true).to_s end if tracker.[:debug] out << generate_templates(true).to_s end out << generate_errors(true).to_s out << generate_warnings(true).to_s out << generate_controller_warnings(true).to_s out << generate_model_warnings(true).to_s out << generate_template_warnings(true).to_s out << "</body></html>" end |
#to_json ⇒ Object
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
# File 'lib/brakeman/report.rb', line 659 def to_json errors = tracker.errors.map{|e| { :error => e[:error], :location => e[:backtrace][0] }} app_path = tracker.[:app_path] warnings = all_warnings.map do |w| hash = w.to_hash hash[:file] = warning_file w hash end.sort_by { |w| w[:file] } scan_info = { :app_path => File.(tracker.[:app_path]), :rails_version => rails_version, :security_warnings => all_warnings.length, :timestamp => Time.now.to_s, :checks_performed => checks.checks_run.sort, :number_of_controllers =>tracker.controllers.length, # ignore the "fake" model :number_of_models => tracker.models.length - 1, :number_of_templates => number_of_templates(@tracker), :ruby_version => RUBY_VERSION, :brakeman_version => Brakeman::Version } MultiJson.dump({ :scan_info => scan_info, :warnings => warnings, :errors => errors }, :pretty => true) end |
#to_pdf ⇒ Object
Not yet implemented
451 452 453 |
# File 'lib/brakeman/report.rb', line 451 def to_pdf raise "PDF output is not yet supported." end |
#to_s ⇒ Object
Output text version of the report
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/brakeman/report.rb', line 365 def to_s out = text_header << "\n\n+SUMMARY+\n\n" << truncate_table(generate_overview.to_s) << "\n\n" << truncate_table(generate_warning_overview.to_s) << "\n" #Return output early if only summarizing if tracker.[:summary_only] return out end if tracker.[:report_routes] or tracker.[:debug] out << "\n+CONTROLLERS+\n" << truncate_table(generate_controllers.to_s) << "\n" end if tracker.[:debug] out << "\n+TEMPLATES+\n\n" << truncate_table(generate_templates.to_s) << "\n" end res = generate_errors out << "+Errors+\n" << truncate_table(res.to_s) if res res = generate_warnings out << "\n\n+SECURITY WARNINGS+\n\n" << truncate_table(res.to_s) if res res = generate_controller_warnings out << "\n\n\nController Warnings:\n\n" << truncate_table(res.to_s) if res res = generate_model_warnings out << "\n\n\nModel Warnings:\n\n" << truncate_table(res.to_s) if res res = generate_template_warnings out << "\n\nView Warnings:\n\n" << truncate_table(res.to_s) if res out << "\n" out end |
#to_tabs ⇒ Object
Generated tab-separated output suitable for the Jenkins Brakeman Plugin: github.com/presidentbeef/brakeman-jenkins-plugin
621 622 623 624 625 626 627 628 629 630 631 632 |
# File 'lib/brakeman/report.rb', line 621 def to_tabs [[:warnings, "General"], [:controller_warnings, "Controller"], [:model_warnings, "Model"], [:template_warnings, "Template"]].map do |meth, category| checks.send(meth).map do |w| line = w.line || 0 w.warning_type.gsub!(/[^\w\s]/, ' ') "#{warning_file w}\t#{line}\t#{w.warning_type}\t#{category}\t#{w.}\t#{TEXT_CONFIDENCE[w.confidence]}" end.join "\n" end.join "\n" end |
#to_test ⇒ Object
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 |
# File 'lib/brakeman/report.rb', line 634 def to_test report = { :errors => tracker.errors, :controllers => tracker.controllers, :models => tracker.models, :templates => tracker.templates } [:warnings, :controller_warnings, :model_warnings, :template_warnings].each do |meth| report[meth] = @checks.send(meth) report[meth].each do |w| w. = w. if w.code w.code = w.format_code else w.code = "" end w.context = context_for(w).join("\n") end end report[:config] = tracker.config report end |
#warning_file(warning, relative = false) ⇒ Object
698 699 700 701 702 703 704 705 706 |
# File 'lib/brakeman/report.rb', line 698 def warning_file warning, relative = false return nil if warning.file.nil? if @tracker.[:relative_paths] or relative Pathname.new(warning.file).relative_path_from(Pathname.new(tracker.[:app_path])).to_s else warning.file end end |
#warnings_summary ⇒ Object
Return summary of warnings in hash and store in @warnings_summary
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/brakeman/report.rb', line 489 def warnings_summary return @warnings_summary if @warnings_summary summary = Hash.new(0) high_confidence_warnings = 0 [all_warnings].each do |warnings| warnings.each do |warning| summary[warning.warning_type.to_s] += 1 if warning.confidence == 0 high_confidence_warnings += 1 end end end summary[:high_confidence] = high_confidence_warnings @warnings_summary = summary end |
#with_context(warning, message) ⇒ Object
Generate HTML for warnings, including context show/hidden via Javascript
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
# File 'lib/brakeman/report.rb', line 534 def with_context warning, context = context_for warning = nil if tracker.[:message_limit] and tracker.[:message_limit] > 0 and .length > tracker.[:message_limit] = (warning, ) = [0..tracker.[:message_limit]] << "..." end = (warning, ) if context.empty? and not return end @element_id += 1 code_id = "context#@element_id" = "message#@element_id" = "full_message#@element_id" alt = false output = "<div class='warning_message' onClick=\"toggle('#{code_id}');toggle('#{}');toggle('#{}')\" >" << if "<span id='#{}' style='display:block' >#{}</span>" << "<span id='#{}' style='display:none'>#{}</span>" else end << "<table id='#{code_id}' class='context' style='display:none'>" << "<caption>#{warning_file(warning, :relative) || ''}</caption>" unless context.empty? if warning.line - 1 == 1 or warning.line + 1 == 1 error = " near_error" elsif 1 == warning.line error = " error" else error = "" end output << <<-HTML <tr class='context first#{error}'> <td class='context_line'> <pre class='context'>#{context.first[0]}</pre> </td> <td class='context'> <pre class='context'>#{CGI.escapeHTML context.first[1].chomp}</pre> </td> </tr> HTML if context.length > 1 output << context[1..-1].map do |code| alt = !alt if code[0] == warning.line - 1 or code[0] == warning.line + 1 error = " near_error" elsif code[0] == warning.line error = " error" else error = "" end <<-HTML <tr class='context#{alt ? ' alt' : ''}#{error}'> <td class='context_line'> <pre class='context'>#{code[0]}</pre> </td> <td class='context'> <pre class='context'>#{CGI.escapeHTML code[1].chomp}</pre> </td> </tr> HTML end.join end end output << "</table></div>" end |
#with_link(warning, message) ⇒ Object
615 616 617 |
# File 'lib/brakeman/report.rb', line 615 def with_link warning, "<a href=\"#{warning.link}\">#{}</a>" end |