Class: SeccompTools::Audit
- Inherits:
-
Object
- Object
- SeccompTools::Audit
- Defined in:
- lib/seccomp-tools/audit.rb,
lib/seccomp-tools/audit/checks.rb,
lib/seccomp-tools/audit/policy.rb,
lib/seccomp-tools/audit/report.rb,
lib/seccomp-tools/audit/catalog.rb,
lib/seccomp-tools/audit/finding.rb,
lib/seccomp-tools/audit/checks/orw_chain.rb,
lib/seccomp-tools/audit/checks/x32_guard.rb,
lib/seccomp-tools/audit/checks/arch_unchecked.rb,
lib/seccomp-tools/audit/checks/dangerous_allow.rb,
lib/seccomp-tools/audit/checks/syscall_alt_gap.rb,
lib/seccomp-tools/audit/checks/permissive_default.rb
Overview
Assesses a seccomp filter for weaknesses / escape routes and reports them as a Report.
It runs the generic Symbolic::Executor over the filter (the same walk Explain uses), splits the leaves per architecture with Explain::Analysis, and runs each Checks rule against the per-arch Policy. Every supported architecture is assessed; architecture-specific quirks (e.g. amd64's x32 ABI) are registered per arch in Checks, never special-cased inline.
Defined Under Namespace
Modules: Catalog, Checks Classes: Finding, Policy, Report
Constant Summary collapse
- SEVERITIES =
Severities, most to least severe. Drives ordering and (for
humanoutput) coloring. %i[high medium low].freeze
Instance Method Summary collapse
-
#audit ⇒ Report
Walks the filter, runs every check, and returns the Report.
-
#initialize(instructions, arch:, source: nil) ⇒ Audit
constructor
A new instance of Audit.
Constructor Details
#initialize(instructions, arch:, source: nil) ⇒ Audit
Returns a new instance of Audit.
27 28 29 30 31 |
# File 'lib/seccomp-tools/audit.rb', line 27 def initialize(instructions, arch:, source: nil) @instructions = instructions @arch = arch @source = source end |
Instance Method Details
#audit ⇒ Report
Walks the filter, runs every check, and returns the Report.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/seccomp-tools/audit.rb', line 35 def audit leaves, truncated = Symbolic::Executor.new(@instructions).run analysis = Explain::Analysis.new(leaves) policies = analysis.sections(@arch).map { |section| Policy.new(analysis, section) } findings = Checks::FILTER.flat_map { |check| check.call(analysis) } policies.each do |policy| Checks.section_checks(policy.arch_sym).each { |check| findings.concat(check.call(policy)) } end Report.new(source: @source, arches: policies.map(&:arch_name), findings:, truncated:) end |