module EhcHardenReport
EhcHardenReport — IRC cards for server harden scans and issue detail. Public: format_summary, format_issue, format_denial, format_issue_not_found, format_target_error Depends: EhcReport, IrcReply Tests: test/lib/ehc_harden_report_test.rb
Constants
- DENIAL_MESSAGE
- ISSUE_TITLE
- MAX_SUMMARY_LINES
- TAG
- TITLE
Public Instance Methods
Source
# File lib/ehc_harden_report.rb, line 64 def format_denial IrcReply.error(tag: TAG, message: DENIAL_MESSAGE) end
Source
# File lib/ehc_harden_report.rb, line 41 def format_issue(issue:, label: nil) row = issue.is_a?(Hash) ? issue : {} id = row["id"] || row[:id] title = row["title"] || row[:title] severity = row["severity"] || row[:severity] summary = row["summary"] || row[:summary] details = Array(row["detail_lines"] || row[:detail_lines]).first(4) body_lines = ["Severity: #{severity}", summary.to_s] body_lines.concat(details) footer_parts = ["##{id} #{title}"] footer_parts << label.to_s unless label.to_s.strip.empty? footer_parts << "!ehc issue <n>" IrcReply.card( tag: TAG, title: ISSUE_TITLE, body_lines: body_lines.reject(&:empty?), footer_parts: footer_parts.compact ) end
Source
# File lib/ehc_harden_report.rb, line 68 def format_issue_not_found(issue_id:) IrcReply.error(tag: TAG, message: "Issue ##{issue_id} not found — run !ehc <url|ip|nick> first.") end
Source
# File lib/ehc_harden_report.rb, line 21 def format_summary(label:, issues:) rows = Array(issues) body_lines = if rows.empty? ["No issues found — baseline checks passed."] else rows.first(MAX_SUMMARY_LINES).map { |row| "##{row[:id] || row['id']} \u2014 #{row[:title] || row['title']}" } end footer_parts = [label.to_s, "#{rows.length} issues", "!ehc issue <n>"] footer_parts << EhcReport::FOOTER_HINT IrcReply.card( tag: TAG, title: TITLE, body_lines: body_lines, footer_parts: footer_parts.compact ) end
Source
# File lib/ehc_harden_report.rb, line 72 def format_target_error(error) case error when :unsafe EhcReport.format_unsafe_url when :usage EhcReport.format_usage when :host IrcReply.error(tag: TAG, message: "Could not resolve a public IP from that nick's host mask.") else EhcReport.format_usage end end