Class: SeccompTools::Explain::PathFacts
- Inherits:
-
Object
- Object
- SeccompTools::Explain::PathFacts
- Defined in:
- lib/seccomp-tools/explain/path_facts.rb
Overview
The seccomp reading of one leaf's path condition: which syscall number it pins or bounds,
which architecture value it pins, and which facts remain for the rule's when clause. The
path is immutable, so every query is derived once, eagerly.
Constant Summary collapse
- SYS =
Const::BPF::SeccompData::SYS_NUMBER
- ARCH =
Const::BPF::SeccompData::ARCH
- U32_MAX =
Largest 32-bit value, the upper end of an unconstrained syscall-number range.
0xffffffff
Instance Attribute Summary collapse
-
#arch_eq ⇒ Integer?
readonly
The architecture value the path pins with
==, ornil. -
#residual ⇒ Array<Symbolic::Constraint>
readonly
Constraints not already conveyed by the syscall-number / architecture presentation.
-
#sys_eq ⇒ Integer?
readonly
The syscall number the path pins with
==, ornil. -
#sys_range ⇒ Array(Integer, Integer?)?
readonly
The
[lo, hi]range (inclusive;hiisnilwhen unbounded) all bound facts restrict the syscall number to, ornilwhen there is no lower bound.
Instance Method Summary collapse
-
#arch_consistent?(val) ⇒ Boolean
Is the path consistent with the architecture being
val? Every constant arch fact is evaluated againstval. -
#catch_all? ⇒ Boolean
Does the path match no syscall, no range, and no arguments - i.e.
-
#initialize(path) ⇒ PathFacts
constructor
A new instance of PathFacts.
Constructor Details
Instance Attribute Details
#arch_eq ⇒ Integer? (readonly)
The architecture value the path pins with ==, or nil.
22 23 24 |
# File 'lib/seccomp-tools/explain/path_facts.rb', line 22 def arch_eq @arch_eq end |
#residual ⇒ Array<Symbolic::Constraint> (readonly)
Constraints not already conveyed by the syscall-number / architecture presentation.
Dropped where the presentation already conveys them: ==, != and range facts on
sys_number, +==+/+!=+ facts on arch, and any non-+==+ fact about a value some ==
already pins - that last rule reading a transform of a word as a value of its own.
Everything else is kept, so a kernel-valid check is never silently dropped.
42 43 44 |
# File 'lib/seccomp-tools/explain/path_facts.rb', line 42 def residual @residual end |
#sys_eq ⇒ Integer? (readonly)
The syscall number the path pins with ==, or nil.
19 20 21 |
# File 'lib/seccomp-tools/explain/path_facts.rb', line 19 def sys_eq @sys_eq end |
#sys_range ⇒ Array(Integer, Integer?)? (readonly)
The [lo, hi] range (inclusive; hi is nil when unbounded) all bound facts restrict the
syscall number to, or nil when there is no lower bound. An upper bound alone does not
make a range rule: it is the complement of one (e.g. the sys < 0x40000000 side of an x32
guard) and reads naturally as part of the default bucket.
28 29 30 |
# File 'lib/seccomp-tools/explain/path_facts.rb', line 28 def sys_range @sys_range end |
Instance Method Details
#arch_consistent?(val) ⇒ Boolean
Is the path consistent with the architecture being val? Every constant arch fact is
evaluated against val.
57 58 59 60 61 62 63 |
# File 'lib/seccomp-tools/explain/path_facts.rb', line 57 def arch_consistent?(val) @path.all? do |c| next true unless c.plain_data_fact?(ARCH) Symbolic::Constraint.evaluate(val, c.op, c.rhs.val) end end |
#catch_all? ⇒ Boolean
Does the path match no syscall, no range, and no arguments - i.e. describe the filter's catch-all behavior?
68 69 70 |
# File 'lib/seccomp-tools/explain/path_facts.rb', line 68 def catch_all? sys_eq.nil? && sys_range.nil? && residual.empty? end |