Class: SeccompTools::Audit::Report
- Inherits:
-
Object
- Object
- SeccompTools::Audit::Report
- Defined in:
- lib/seccomp-tools/audit/report.rb
Overview
The findings for one filter, rendered either as a human report or a JSON-ready hash.
Constant Summary collapse
- SEVERITY_THEME =
Severity => Util.colorize theme for the
[SEVERITY]tag. { high: :error, medium: :warn, low: :info }.freeze
- WIDTH =
Widest a rendered line may get, so a finding reads without wrapping on a standard terminal.
120
Instance Attribute Summary collapse
-
#arches ⇒ Array<String>
readonly
The architectures covered.
- #findings ⇒ Array<Finding> readonly
Instance Method Summary collapse
-
#initialize(source:, arches:, findings:, truncated:) ⇒ Report
constructor
A new instance of Report.
-
#to_h ⇒ Hash
JSON-ready shape for one filter.
-
#to_s ⇒ String
The human report.
Constructor Details
#initialize(source:, arches:, findings:, truncated:) ⇒ Report
Returns a new instance of Report.
20 21 22 23 24 25 |
# File 'lib/seccomp-tools/audit/report.rb', line 20 def initialize(source:, arches:, findings:, truncated:) @source = source @arches = arches @findings = findings.sort_by(&:rank) @truncated = truncated end |
Instance Attribute Details
#arches ⇒ Array<String> (readonly)
Returns The architectures covered.
30 31 32 |
# File 'lib/seccomp-tools/audit/report.rb', line 30 def arches @arches end |
#findings ⇒ Array<Finding> (readonly)
28 29 30 |
# File 'lib/seccomp-tools/audit/report.rb', line 28 def findings @findings end |
Instance Method Details
#to_h ⇒ Hash
Returns JSON-ready shape for one filter.
48 49 50 |
# File 'lib/seccomp-tools/audit/report.rb', line 48 def to_h { source: @source, arches: @arches, truncated: @truncated, findings: @findings.map(&:to_h) } end |
#to_s ⇒ String
The human report.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/seccomp-tools/audit/report.rb', line 34 def to_s out = +'' out << "Seccomp audit of #{@source}\n" if @source out << "Architectures: #{@arches.join(', ')}\n" unless @arches.empty? # A truncated walk can only hide weaknesses, so it qualifies the whole report rather than # being a finding of its own. out << "WARNING: analysis truncated (filter too large); results may be incomplete.\n" if @truncated return out << "\nNo weaknesses found.\n" if @findings.empty? @findings.each { |f| out << render(f) } out end |