Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shows ignored warnings on markdown output #1712

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/brakeman/report/report_markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def generate_report
output_table("Controller Warnings:", generate_controller_warnings, out)
output_table("Model Warnings:", generate_model_warnings, out)
output_table("View Warnings:", generate_template_warnings, out)
output_table("Ignored Warnings:", generate_ignored_warnings, out)

out
end
Expand Down Expand Up @@ -82,12 +83,27 @@ def generate_checks
t.add_row([checks.checks_run.sort.join(", ")])
end
end

def generate_ignored_warnings
render_warnings ignored_warnings,
:ignored,
'ignored_warnings',
['Confidence', 'Warning Type', 'File', 'Message', 'Note'],
'Warning Type'
end

def convert_warning warning, original
warning["Message"] = markdown_message original, warning["Message"]
warning["Warning Type"] = "[#{warning['Warning Type']}](#{original.link})" if original.link
warning
end

def convert_ignored_warning warning, original
warning = convert_warning(warning, original)
warning['File'] = original.file.relative
warning['Note'] = CGI.escapeHTML(@ignore_filter.note_for(original) || "")
warning
end

# Escape and code format warning message
def markdown_message warning, message
Expand Down